From f3798f4638f00dc91f384149f0b0310dd85774a0 Mon Sep 17 00:00:00 2001 From: Parth Bansal Date: Fri, 17 Apr 2026 11:09:41 +0000 Subject: [PATCH] Regenerate SDK with FieldMask, JsonValue, JsonObject well-known types Uses FieldMask from @databricks/sdk-core/wkt for google.protobuf.FieldMask fields. Uses JsonValue/JsonObject types from core/wkt with inline jsonValueSchema/jsonObjectSchema Zod declarations per model file for google.protobuf.Value, ListValue, Struct fields. Co-authored-by: Isaac --- packages/abacpolicies/package.json | 1 + packages/abacpolicies/src/v1/client.ts | 79 +- packages/abacpolicies/src/v1/index.ts | 6 +- packages/abacpolicies/src/v1/model.ts | 102 +- packages/abacpolicies/src/v1/utils.ts | 6 +- packages/abacpolicies/tsconfig.json | 2 +- packages/accountaccesscontrol/package.json | 1 + .../accountaccesscontrol/src/v1/client.ts | 48 +- packages/accountaccesscontrol/src/v1/index.ts | 4 +- packages/accountaccesscontrol/src/v1/model.ts | 86 +- packages/accountaccesscontrol/src/v1/utils.ts | 6 +- packages/accountaccesscontrol/tsconfig.json | 2 +- .../accountaccesscontrolproxy/package.json | 1 + .../src/v1/client.ts | 48 +- .../accountaccesscontrolproxy/src/v1/index.ts | 4 +- .../accountaccesscontrolproxy/src/v1/model.ts | 86 +- .../accountaccesscontrolproxy/src/v1/utils.ts | 6 +- .../accountaccesscontrolproxy/tsconfig.json | 2 +- packages/alerts/package.json | 1 + packages/alerts/src/v1/client.ts | 75 +- packages/alerts/src/v1/index.ts | 7 +- packages/alerts/src/v1/model.ts | 423 ++-- packages/alerts/src/v1/utils.ts | 6 +- packages/alerts/src/v2/client.ts | 77 +- packages/alerts/src/v2/index.ts | 1 + packages/alerts/src/v2/model.ts | 128 +- packages/alerts/src/v2/utils.ts | 6 +- packages/alerts/tsconfig.json | 2 +- packages/artifactallowlists/package.json | 1 + packages/artifactallowlists/src/v1/client.ts | 31 +- packages/artifactallowlists/src/v1/index.ts | 6 +- packages/artifactallowlists/src/v1/model.ts | 85 +- packages/artifactallowlists/src/v1/utils.ts | 6 +- packages/artifactallowlists/tsconfig.json | 2 +- packages/billableusagedownload/package.json | 1 + .../billableusagedownload/src/v1/client.ts | 27 +- .../billableusagedownload/src/v1/index.ts | 9 +- .../billableusagedownload/src/v1/utils.ts | 6 +- packages/billableusagedownload/tsconfig.json | 2 +- packages/catalogs/package.json | 1 + packages/catalogs/src/v1/client.ts | 79 +- packages/catalogs/src/v1/index.ts | 1 + packages/catalogs/src/v1/model.ts | 327 +-- packages/catalogs/src/v1/utils.ts | 6 +- packages/catalogs/tsconfig.json | 2 +- packages/clusterpolicies/package.json | 38 + packages/clusterpolicies/src/v2/client.ts | 145 ++ packages/clusterpolicies/src/v2/index.ts | 26 + packages/clusterpolicies/src/v2/model.ts | 598 +++++ packages/clusterpolicies/src/v2/utils.ts | 130 + packages/clusterpolicies/tsconfig.json | 10 + packages/connections/package.json | 1 + packages/connections/src/v1/client.ts | 84 +- packages/connections/src/v1/index.ts | 1 + packages/connections/src/v1/model.ts | 286 ++- packages/connections/src/v1/utils.ts | 6 +- packages/connections/tsconfig.json | 2 +- packages/credentials/package.json | 1 + packages/credentials/src/v1/client.ts | 274 +-- packages/credentials/src/v1/index.ts | 1 + packages/credentials/src/v1/model.ts | 1421 +++++------ packages/credentials/src/v1/utils.ts | 6 +- packages/credentials/tsconfig.json | 2 +- packages/dataclassification/package.json | 1 + packages/dataclassification/src/v1/client.ts | 59 +- packages/dataclassification/src/v1/index.ts | 5 +- packages/dataclassification/src/v1/model.ts | 122 +- packages/dataclassification/src/v1/utils.ts | 6 +- packages/dataclassification/tsconfig.json | 2 +- packages/dataquality/package.json | 1 + packages/dataquality/src/v1/client.ts | 193 +- packages/dataquality/src/v1/index.ts | 1 + packages/dataquality/src/v1/model.ts | 704 +++--- packages/dataquality/src/v1/utils.ts | 6 +- packages/dataquality/tsconfig.json | 2 +- packages/entitytagassignments/package.json | 1 + .../entitytagassignments/src/v1/client.ts | 112 +- packages/entitytagassignments/src/v1/index.ts | 5 +- packages/entitytagassignments/src/v1/model.ts | 201 +- packages/entitytagassignments/src/v1/utils.ts | 6 +- packages/entitytagassignments/tsconfig.json | 2 +- packages/environments/package.json | 1 + packages/environments/src/v1/client.ts | 243 +- packages/environments/src/v1/index.ts | 8 +- packages/environments/src/v1/model.ts | 499 ++-- packages/environments/src/v1/utils.ts | 6 +- packages/environments/tsconfig.json | 2 +- packages/externallocations/package.json | 1 + packages/externallocations/src/v1/client.ts | 89 +- packages/externallocations/src/v1/index.ts | 6 +- packages/externallocations/src/v1/model.ts | 453 ++-- packages/externallocations/src/v1/utils.ts | 6 +- packages/externallocations/tsconfig.json | 2 +- packages/features/package.json | 1 + packages/features/src/v1/client.ts | 260 +- packages/features/src/v1/index.ts | 1 + packages/features/src/v1/model.ts | 759 +++--- packages/features/src/v1/utils.ts | 6 +- packages/features/tsconfig.json | 2 +- packages/featurestore/package.json | 1 + packages/featurestore/src/v1/client.ts | 101 +- packages/featurestore/src/v1/index.ts | 6 +- packages/featurestore/src/v1/model.ts | 187 +- packages/featurestore/src/v1/utils.ts | 6 +- packages/featurestore/tsconfig.json | 2 +- packages/files/package.json | 25 +- packages/files/src/v2/client.ts | 330 +++ packages/files/src/v2/index.ts | 31 + packages/files/src/v2/model.ts | 505 ++++ packages/files/src/v2/utils.ts | 130 + packages/files/tsconfig.json | 2 +- packages/functions/package.json | 1 + packages/functions/src/v1/client.ts | 83 +- packages/functions/src/v1/index.ts | 3 + packages/functions/src/v1/model.ts | 267 +- packages/functions/src/v1/utils.ts | 6 +- packages/functions/tsconfig.json | 2 +- packages/genie/package.json | 1 + packages/genie/src/v1/client.ts | 715 +++--- packages/genie/src/v1/index.ts | 3 +- packages/genie/src/v1/model.ts | 1775 +++++++------- packages/genie/src/v1/utils.ts | 6 +- packages/genie/tsconfig.json | 2 +- packages/globalinitscripts/package.json | 38 + packages/globalinitscripts/src/v2/client.ts | 134 + packages/globalinitscripts/src/v2/index.ts | 20 + packages/globalinitscripts/src/v2/model.ts | 295 +++ packages/globalinitscripts/src/v2/utils.ts | 130 + packages/globalinitscripts/tsconfig.json | 10 + packages/grants/package.json | 1 + packages/grants/src/v1/client.ts | 133 +- packages/grants/src/v1/index.ts | 4 +- packages/grants/src/v1/model.ts | 369 ++- packages/grants/src/v1/utils.ts | 6 +- packages/grants/tsconfig.json | 2 +- packages/iam/package.json | 1 + packages/iam/src/v2/client.ts | 965 ++------ packages/iam/src/v2/index.ts | 5 + packages/iam/src/v2/model.ts | 2150 ++++++++-------- packages/iam/src/v2/utils.ts | 6 +- packages/iam/tsconfig.json | 2 +- packages/instancepools/package.json | 38 + packages/instancepools/src/v2/client.ts | 136 ++ packages/instancepools/src/v2/index.ts | 44 + packages/instancepools/src/v2/model.ts | 1607 ++++++++++++ packages/instancepools/src/v2/utils.ts | 130 + packages/instancepools/tsconfig.json | 10 + packages/instanceprofiles/package.json | 38 + packages/instanceprofiles/src/v2/client.ts | 138 ++ packages/instanceprofiles/src/v2/index.ts | 19 + packages/instanceprofiles/src/v2/model.ts | 249 ++ packages/instanceprofiles/src/v2/utils.ts | 130 + packages/instanceprofiles/tsconfig.json | 10 + packages/materializedfeatures/package.json | 1 + .../materializedfeatures/src/v1/client.ts | 89 +- packages/materializedfeatures/src/v1/index.ts | 4 +- packages/materializedfeatures/src/v1/model.ts | 249 +- packages/materializedfeatures/src/v1/utils.ts | 6 +- packages/materializedfeatures/tsconfig.json | 2 +- packages/metastores/package.json | 1 + packages/metastores/src/v1/client.ts | 159 +- packages/metastores/src/v1/index.ts | 5 +- packages/metastores/src/v1/model.ts | 290 +-- packages/metastores/src/v1/utils.ts | 6 +- packages/metastores/tsconfig.json | 2 +- .../notificationdestinations/package.json | 1 + .../notificationdestinations/src/v1/client.ts | 96 +- .../notificationdestinations/src/v1/index.ts | 5 +- .../notificationdestinations/src/v1/model.ts | 288 ++- .../notificationdestinations/src/v1/utils.ts | 6 +- .../notificationdestinations/tsconfig.json | 2 +- .../oauthcustomappintegration/package.json | 1 + .../src/v1/client.ts | 229 +- .../oauthcustomappintegration/src/v1/index.ts | 4 +- .../oauthcustomappintegration/src/v1/model.ts | 551 ++--- .../oauthcustomappintegration/src/v1/utils.ts | 6 +- .../oauthcustomappintegration/tsconfig.json | 2 +- packages/oauthpublishedapp/package.json | 1 + packages/oauthpublishedapp/src/v1/client.ts | 29 +- packages/oauthpublishedapp/src/v1/index.ts | 4 +- packages/oauthpublishedapp/src/v1/model.ts | 42 +- packages/oauthpublishedapp/src/v1/utils.ts | 6 +- packages/oauthpublishedapp/tsconfig.json | 2 +- packages/permissions/package.json | 1 + packages/permissions/src/v1/client.ts | 60 +- packages/permissions/src/v1/index.ts | 5 +- packages/permissions/src/v1/model.ts | 237 +- packages/permissions/src/v1/utils.ts | 6 +- packages/permissions/tsconfig.json | 2 +- packages/policyfamilies/package.json | 38 + packages/policyfamilies/src/v2/client.ts | 98 + packages/policyfamilies/src/v2/index.ts | 14 + packages/policyfamilies/src/v2/model.ts | 128 + packages/policyfamilies/src/v2/utils.ts | 130 + packages/policyfamilies/tsconfig.json | 10 + packages/postgres/package.json | 1 + packages/postgres/src/v1/client.ts | 989 +++----- packages/postgres/src/v1/index.ts | 25 +- packages/postgres/src/v1/model.ts | 2151 +++++++---------- packages/postgres/src/v1/utils.ts | 6 +- packages/postgres/tsconfig.json | 2 +- packages/qualitymonitor/package.json | 1 + packages/qualitymonitor/src/v2/client.ts | 85 +- packages/qualitymonitor/src/v2/index.ts | 1 + packages/qualitymonitor/src/v2/model.ts | 343 ++- packages/qualitymonitor/src/v2/utils.ts | 6 +- packages/qualitymonitor/tsconfig.json | 2 +- packages/qualitymonitors/package.json | 1 + packages/qualitymonitors/src/v1/client.ts | 156 +- packages/qualitymonitors/src/v1/index.ts | 1 + packages/qualitymonitors/src/v1/model.ts | 258 +- packages/qualitymonitors/src/v1/utils.ts | 6 +- packages/qualitymonitors/tsconfig.json | 2 +- packages/queries/package.json | 1 + packages/queries/src/v1/client.ts | 106 +- packages/queries/src/v1/index.ts | 1 + packages/queries/src/v1/model.ts | 538 ++--- packages/queries/src/v1/utils.ts | 6 +- packages/queries/tsconfig.json | 2 +- packages/queryhistory/package.json | 1 + packages/queryhistory/src/v1/client.ts | 32 +- packages/queryhistory/src/v1/index.ts | 1 + packages/queryhistory/src/v1/model.ts | 122 +- packages/queryhistory/src/v1/utils.ts | 6 +- packages/queryhistory/tsconfig.json | 2 +- packages/registeredmodels/package.json | 1 + packages/registeredmodels/src/v1/client.ts | 225 +- packages/registeredmodels/src/v1/index.ts | 7 +- packages/registeredmodels/src/v1/model.ts | 741 +++--- packages/registeredmodels/src/v1/utils.ts | 6 +- packages/registeredmodels/tsconfig.json | 2 +- packages/resourcequotas/package.json | 1 + packages/resourcequotas/src/v1/client.ts | 34 +- packages/resourcequotas/src/v1/index.ts | 5 +- packages/resourcequotas/src/v1/model.ts | 19 +- packages/resourcequotas/src/v1/utils.ts | 6 +- packages/resourcequotas/tsconfig.json | 2 +- packages/rfa/package.json | 1 + packages/rfa/src/v1/client.ts | 66 +- packages/rfa/src/v1/index.ts | 1 + packages/rfa/src/v1/model.ts | 252 +- packages/rfa/src/v1/utils.ts | 6 +- packages/rfa/tsconfig.json | 2 +- packages/schemas/package.json | 1 + packages/schemas/src/v1/client.ts | 79 +- packages/schemas/src/v1/index.ts | 5 +- packages/schemas/src/v1/model.ts | 221 +- packages/schemas/src/v1/utils.ts | 6 +- packages/schemas/tsconfig.json | 2 +- packages/sdk/package.json | 1 + packages/sdk/src/index.ts | 5 +- packages/sdk/src/model.ts | 305 ++- packages/sdk/tsconfig.json | 2 +- packages/secrets/package.json | 38 + packages/secrets/src/v1/client.ts | 543 +++++ packages/secrets/src/v1/index.ts | 37 + packages/secrets/src/v1/model.ts | 631 +++++ packages/secrets/src/v1/utils.ts | 130 + packages/secrets/tsconfig.json | 10 + packages/serviceprincipalsecrets/package.json | 1 + .../serviceprincipalsecrets/src/v1/client.ts | 72 +- .../serviceprincipalsecrets/src/v1/index.ts | 4 +- .../serviceprincipalsecrets/src/v1/model.ts | 211 +- .../serviceprincipalsecrets/src/v1/utils.ts | 6 +- .../serviceprincipalsecrets/tsconfig.json | 2 +- .../serviceprincipalsecretsproxy/package.json | 1 + .../src/v1/client.ts | 72 +- .../src/v1/index.ts | 4 +- .../src/v1/model.ts | 211 +- .../src/v1/utils.ts | 6 +- .../tsconfig.json | 2 +- packages/settings/package.json | 1 + packages/settings/src/v2/client.ts | 178 +- packages/settings/src/v2/index.ts | 1 + packages/settings/src/v2/model.ts | 811 +++---- packages/settings/src/v2/utils.ts | 6 +- packages/settings/tsconfig.json | 2 +- packages/statementexecution/package.json | 1 + packages/statementexecution/src/v1/client.ts | 85 +- packages/statementexecution/src/v1/index.ts | 1 + packages/statementexecution/src/v1/model.ts | 228 +- packages/statementexecution/src/v1/utils.ts | 6 +- packages/statementexecution/tsconfig.json | 2 +- packages/systemschemas/package.json | 1 + packages/systemschemas/src/v1/client.ts | 65 +- packages/systemschemas/src/v1/index.ts | 4 +- packages/systemschemas/src/v1/model.ts | 85 +- packages/systemschemas/src/v1/utils.ts | 6 +- packages/systemschemas/tsconfig.json | 2 +- packages/tables/package.json | 1 + packages/tables/src/v1/client.ts | 192 +- packages/tables/src/v1/index.ts | 3 + packages/tables/src/v1/model.ts | 777 +++--- packages/tables/src/v1/utils.ts | 6 +- packages/tables/tsconfig.json | 2 +- packages/tagassignments/package.json | 1 + packages/tagassignments/src/v1/client.ts | 77 +- packages/tagassignments/src/v1/index.ts | 4 +- packages/tagassignments/src/v1/model.ts | 145 +- packages/tagassignments/src/v1/utils.ts | 6 +- packages/tagassignments/tsconfig.json | 2 +- packages/tagpolicies/package.json | 1 + packages/tagpolicies/src/v1/client.ts | 77 +- packages/tagpolicies/src/v1/index.ts | 4 +- packages/tagpolicies/src/v1/model.ts | 188 +- packages/tagpolicies/src/v1/utils.ts | 6 +- packages/tagpolicies/tsconfig.json | 2 +- packages/tokenmanagement/package.json | 38 + packages/tokenmanagement/src/v1/client.ts | 137 ++ packages/tokenmanagement/src/v1/index.ts | 21 + packages/tokenmanagement/src/v1/model.ts | 349 +++ packages/tokenmanagement/src/v1/utils.ts | 130 + packages/tokenmanagement/tsconfig.json | 10 + packages/tokens/package.json | 38 + packages/tokens/src/v1/client.ts | 123 + packages/tokens/src/v1/index.ts | 20 + packages/tokens/src/v1/model.ts | 277 +++ packages/tokens/src/v1/utils.ts | 130 + packages/tokens/tsconfig.json | 10 + packages/volumes/package.json | 1 + packages/volumes/src/v1/client.ts | 95 +- packages/volumes/src/v1/index.ts | 6 +- packages/volumes/src/v1/model.ts | 73 +- packages/volumes/src/v1/utils.ts | 6 +- packages/volumes/tsconfig.json | 2 +- packages/warehouses/package.json | 1 + packages/warehouses/src/v1/client.ts | 664 +++-- packages/warehouses/src/v1/index.ts | 3 +- packages/warehouses/src/v1/model.ts | 823 +++---- packages/warehouses/src/v1/utils.ts | 6 +- packages/warehouses/tsconfig.json | 2 +- packages/workspaceassignment/package.json | 38 + packages/workspaceassignment/src/v1/client.ts | 134 + packages/workspaceassignment/src/v1/index.ts | 21 + packages/workspaceassignment/src/v1/model.ts | 345 +++ packages/workspaceassignment/src/v1/utils.ts | 130 + packages/workspaceassignment/tsconfig.json | 10 + packages/workspacebindings/package.json | 1 + packages/workspacebindings/src/v1/client.ts | 92 +- packages/workspacebindings/src/v1/index.ts | 5 +- packages/workspacebindings/src/v1/model.ts | 191 +- packages/workspacebindings/src/v1/utils.ts | 6 +- packages/workspacebindings/tsconfig.json | 2 +- packages/workspaceconf/package.json | 1 + packages/workspaceconf/src/v1/client.ts | 36 +- packages/workspaceconf/src/v1/index.ts | 9 +- packages/workspaceconf/src/v1/model.ts | 15 +- packages/workspaceconf/src/v1/utils.ts | 6 +- packages/workspaceconf/tsconfig.json | 2 +- 349 files changed, 21022 insertions(+), 17247 deletions(-) create mode 100644 packages/clusterpolicies/package.json create mode 100644 packages/clusterpolicies/src/v2/client.ts create mode 100644 packages/clusterpolicies/src/v2/index.ts create mode 100644 packages/clusterpolicies/src/v2/model.ts create mode 100644 packages/clusterpolicies/src/v2/utils.ts create mode 100644 packages/clusterpolicies/tsconfig.json create mode 100644 packages/files/src/v2/client.ts create mode 100644 packages/files/src/v2/index.ts create mode 100644 packages/files/src/v2/model.ts create mode 100644 packages/files/src/v2/utils.ts create mode 100644 packages/globalinitscripts/package.json create mode 100644 packages/globalinitscripts/src/v2/client.ts create mode 100644 packages/globalinitscripts/src/v2/index.ts create mode 100644 packages/globalinitscripts/src/v2/model.ts create mode 100644 packages/globalinitscripts/src/v2/utils.ts create mode 100644 packages/globalinitscripts/tsconfig.json create mode 100644 packages/instancepools/package.json create mode 100644 packages/instancepools/src/v2/client.ts create mode 100644 packages/instancepools/src/v2/index.ts create mode 100644 packages/instancepools/src/v2/model.ts create mode 100644 packages/instancepools/src/v2/utils.ts create mode 100644 packages/instancepools/tsconfig.json create mode 100644 packages/instanceprofiles/package.json create mode 100644 packages/instanceprofiles/src/v2/client.ts create mode 100644 packages/instanceprofiles/src/v2/index.ts create mode 100644 packages/instanceprofiles/src/v2/model.ts create mode 100644 packages/instanceprofiles/src/v2/utils.ts create mode 100644 packages/instanceprofiles/tsconfig.json create mode 100644 packages/policyfamilies/package.json create mode 100644 packages/policyfamilies/src/v2/client.ts create mode 100644 packages/policyfamilies/src/v2/index.ts create mode 100644 packages/policyfamilies/src/v2/model.ts create mode 100644 packages/policyfamilies/src/v2/utils.ts create mode 100644 packages/policyfamilies/tsconfig.json create mode 100644 packages/secrets/package.json create mode 100644 packages/secrets/src/v1/client.ts create mode 100644 packages/secrets/src/v1/index.ts create mode 100644 packages/secrets/src/v1/model.ts create mode 100644 packages/secrets/src/v1/utils.ts create mode 100644 packages/secrets/tsconfig.json create mode 100644 packages/tokenmanagement/package.json create mode 100644 packages/tokenmanagement/src/v1/client.ts create mode 100644 packages/tokenmanagement/src/v1/index.ts create mode 100644 packages/tokenmanagement/src/v1/model.ts create mode 100644 packages/tokenmanagement/src/v1/utils.ts create mode 100644 packages/tokenmanagement/tsconfig.json create mode 100644 packages/tokens/package.json create mode 100644 packages/tokens/src/v1/client.ts create mode 100644 packages/tokens/src/v1/index.ts create mode 100644 packages/tokens/src/v1/model.ts create mode 100644 packages/tokens/src/v1/utils.ts create mode 100644 packages/tokens/tsconfig.json create mode 100644 packages/workspaceassignment/package.json create mode 100644 packages/workspaceassignment/src/v1/client.ts create mode 100644 packages/workspaceassignment/src/v1/index.ts create mode 100644 packages/workspaceassignment/src/v1/model.ts create mode 100644 packages/workspaceassignment/src/v1/utils.ts create mode 100644 packages/workspaceassignment/tsconfig.json diff --git a/packages/abacpolicies/package.json b/packages/abacpolicies/package.json index 799215d3..63ef0628 100644 --- a/packages/abacpolicies/package.json +++ b/packages/abacpolicies/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/abacpolicies/src/v1/client.ts b/packages/abacpolicies/src/v1/client.ts index c4b896a9..d8c4f995 100644 --- a/packages/abacpolicies/src/v1/client.ts +++ b/packages/abacpolicies/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreatePolicy, DeletePolicy, @@ -48,21 +43,13 @@ export class Client { * Creates a new policy on a securable. * The new policy applies to the securable and all its descendants. */ - async createPolicy( - signal: AbortSignal | undefined, - req: CreatePolicy, - options?: Options - ): Promise { + async createPolicy(signal: AbortSignal | undefined, req: CreatePolicy, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/policies`; const body = marshalRequest(req.policyInfo, marshalPolicyInfoSchema); let resp: PolicyInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPolicyInfoSchema); }; await execute(signal, call, options); @@ -73,20 +60,12 @@ export class Client { } /** Delete an ABAC policy defined on a securable. */ - async deletePolicy( - signal: AbortSignal | undefined, - req: DeletePolicy, - options?: Options - ): Promise { + async deletePolicy(signal: AbortSignal | undefined, req: DeletePolicy, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}/${req.name ?? ''}`; let resp: DeletePolicy_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeletePolicy_ResponseSchema); }; await execute(signal, call, options); @@ -97,20 +76,12 @@ export class Client { } /** Get the policy definition on a securable */ - async getPolicy( - signal: AbortSignal | undefined, - req: GetPolicy, - options?: Options - ): Promise { + async getPolicy(signal: AbortSignal | undefined, req: GetPolicy, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}/${req.name ?? ''}`; let resp: PolicyInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPolicyInfoSchema); }; await execute(signal, call, options); @@ -123,15 +94,11 @@ export class Client { /** * List all policies defined on a securable. * Optionally, the list can include inherited policies defined on the securable's parent schema or catalog. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listPolicies( - signal: AbortSignal | undefined, - req: ListPolicies, - options?: Options - ): Promise { + async listPolicies(signal: AbortSignal | undefined, req: ListPolicies, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}`; const params = new URLSearchParams(); if (req.includeInherited !== undefined) { @@ -148,11 +115,7 @@ export class Client { let resp: ListPolicies_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListPolicies_ResponseSchema); }; await execute(signal, call, options); @@ -162,11 +125,8 @@ export class Client { return resp; } - async *listPoliciesIter( - signal: AbortSignal | undefined, - req: ListPolicies, - options?: Options - ): AsyncGenerator { + + async *listPoliciesIter(signal: AbortSignal | undefined, req: ListPolicies, options?: Options): AsyncGenerator { const pageReq: ListPolicies = {...req}; for (;;) { const resp = await this.listPolicies(signal, pageReq, options); @@ -180,16 +140,13 @@ export class Client { } } + /** Update an ABAC policy on a securable. */ - async updatePolicy( - signal: AbortSignal | undefined, - req: UpdatePolicy, - options?: Options - ): Promise { + async updatePolicy(signal: AbortSignal | undefined, req: UpdatePolicy, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/policies/${req.onSecurableType ?? ''}/${req.onSecurableFullname ?? ''}/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -197,11 +154,7 @@ export class Client { let resp: PolicyInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPolicyInfoSchema); }; await execute(signal, call, options); diff --git a/packages/abacpolicies/src/v1/index.ts b/packages/abacpolicies/src/v1/index.ts index a21aad7b..40d17a8a 100644 --- a/packages/abacpolicies/src/v1/index.ts +++ b/packages/abacpolicies/src/v1/index.ts @@ -1,8 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {PolicyType, SecurableType} from './model'; +export { + PolicyType, + SecurableType, +} from './model'; export type { ColumnMaskOptions, diff --git a/packages/abacpolicies/src/v1/model.ts b/packages/abacpolicies/src/v1/model.ts index 383bd2bc..b27e9e1d 100644 --- a/packages/abacpolicies/src/v1/model.ts +++ b/packages/abacpolicies/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export enum PolicyType { @@ -292,7 +293,7 @@ export interface UpdatePolicy { * Optional. The update mask field for specifying user intentions on which * fields to update in the request. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export const unmarshalColumnMaskOptionsSchema: z.ZodType = z @@ -307,16 +308,15 @@ export const unmarshalColumnMaskOptionsSchema: z.ZodType = z using: d.using, })); -export const unmarshalColumnTagValueExtractionSchema: z.ZodType = - z - .object({ - column_alias: z.string().optional(), - tag_key: z.string().optional(), - }) - .transform(d => ({ - columnAlias: d.column_alias, - tagKey: d.tag_key, - })); +export const unmarshalColumnTagValueExtractionSchema: z.ZodType = z + .object({ + column_alias: z.string().optional(), + tag_key: z.string().optional(), + }) + .transform(d => ({ + columnAlias: d.column_alias, + tagKey: d.tag_key, + })); export const unmarshalCreatePolicySchema: z.ZodType = z .object({ @@ -339,8 +339,9 @@ export const unmarshalDeletePolicySchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeletePolicy_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeletePolicy_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalDenyOptionsSchema: z.ZodType = z .object({ @@ -354,9 +355,7 @@ export const unmarshalFunctionArgumentSchema: z.ZodType = z .object({ alias: z.string().optional(), constant: z.string().optional(), - metadata_extraction: z - .lazy(() => unmarshalMetadataExtractionExpressionSchema) - .optional(), + metadata_extraction: z.lazy(() => unmarshalMetadataExtractionExpressionSchema).optional(), }) .transform(d => ({ alias: d.alias, @@ -401,16 +400,15 @@ export const unmarshalListPoliciesSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListPolicies_ResponseSchema: z.ZodType = - z - .object({ - policies: z.array(z.lazy(() => unmarshalPolicyInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - policies: d.policies, - nextPageToken: d.next_page_token, - })); +export const unmarshalListPolicies_ResponseSchema: z.ZodType = z + .object({ + policies: z.array(z.lazy(() => unmarshalPolicyInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + policies: d.policies, + nextPageToken: d.next_page_token, + })); export const unmarshalMatchColumnSchema: z.ZodType = z .object({ @@ -422,18 +420,15 @@ export const unmarshalMatchColumnSchema: z.ZodType = z alias: d.alias, })); -export const unmarshalMetadataExtractionExpressionSchema: z.ZodType = - z - .object({ - tag_value: z.lazy(() => unmarshalTagValueExtractionSchema).optional(), - column_tag_value: z - .lazy(() => unmarshalColumnTagValueExtractionSchema) - .optional(), - }) - .transform(d => ({ - tagValue: d.tag_value, - columnTagValue: d.column_tag_value, - })); +export const unmarshalMetadataExtractionExpressionSchema: z.ZodType = z + .object({ + tag_value: z.lazy(() => unmarshalTagValueExtractionSchema).optional(), + column_tag_value: z.lazy(() => unmarshalColumnTagValueExtractionSchema).optional(), + }) + .transform(d => ({ + tagValue: d.tag_value, + columnTagValue: d.column_tag_value, + })); export const unmarshalPolicyInfoSchema: z.ZodType = z .object({ @@ -491,14 +486,13 @@ export const unmarshalRowFilterOptionsSchema: z.ZodType = z using: d.using, })); -export const unmarshalTagValueExtractionSchema: z.ZodType = - z - .object({ - tag_key: z.string().optional(), - }) - .transform(d => ({ - tagKey: d.tag_key, - })); +export const unmarshalTagValueExtractionSchema: z.ZodType = z + .object({ + tag_key: z.string().optional(), + }) + .transform(d => ({ + tagKey: d.tag_key, + })); export const unmarshalUpdatePolicySchema: z.ZodType = z .object({ @@ -506,7 +500,7 @@ export const unmarshalUpdatePolicySchema: z.ZodType = z on_securable_fullname: z.string().optional(), name: z.string().optional(), policy_info: z.lazy(() => unmarshalPolicyInfoSchema).optional(), - update_mask: z.string().optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), }) .transform(d => ({ onSecurableType: d.on_securable_type, @@ -559,7 +553,9 @@ export const marshalDeletePolicySchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeletePolicy_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeletePolicy_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDenyOptionsSchema: z.ZodType = z .object({ @@ -573,9 +569,7 @@ export const marshalFunctionArgumentSchema: z.ZodType = z .object({ alias: z.string().optional(), constant: z.string().optional(), - metadataExtraction: z - .lazy(() => marshalMetadataExtractionExpressionSchema) - .optional(), + metadataExtraction: z.lazy(() => marshalMetadataExtractionExpressionSchema).optional(), }) .transform(d => ({ alias: d.alias, @@ -643,9 +637,7 @@ export const marshalMatchColumnSchema: z.ZodType = z export const marshalMetadataExtractionExpressionSchema: z.ZodType = z .object({ tagValue: z.lazy(() => marshalTagValueExtractionSchema).optional(), - columnTagValue: z - .lazy(() => marshalColumnTagValueExtractionSchema) - .optional(), + columnTagValue: z.lazy(() => marshalColumnTagValueExtractionSchema).optional(), }) .transform(d => ({ tag_value: d.tagValue, @@ -722,7 +714,7 @@ export const marshalUpdatePolicySchema: z.ZodType = z onSecurableFullname: z.string().optional(), name: z.string().optional(), policyInfo: z.lazy(() => marshalPolicyInfoSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ on_securable_type: d.onSecurableType, diff --git a/packages/abacpolicies/src/v1/utils.ts b/packages/abacpolicies/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/abacpolicies/src/v1/utils.ts +++ b/packages/abacpolicies/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/abacpolicies/tsconfig.json b/packages/abacpolicies/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/abacpolicies/tsconfig.json +++ b/packages/abacpolicies/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/accountaccesscontrol/package.json b/packages/accountaccesscontrol/package.json index 2e3d9a75..e7910e7b 100644 --- a/packages/accountaccesscontrol/package.json +++ b/packages/accountaccesscontrol/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/accountaccesscontrol/src/v1/client.ts b/packages/accountaccesscontrol/src/v1/client.ts index 84357d0e..f118ae70 100644 --- a/packages/accountaccesscontrol/src/v1/client.ts +++ b/packages/accountaccesscontrol/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { GetAssignableRolesForResourceRequest, GetAssignableRolesForResourceResponse, @@ -44,11 +39,7 @@ export class Client { * Gets all the roles that can be granted on an account level resource. A role is grantable if the rule set on the * resource can contain an access rule of the role. */ - async getAssignableRolesForResource( - signal: AbortSignal | undefined, - req: GetAssignableRolesForResourceRequest, - options?: Options - ): Promise { + async getAssignableRolesForResource(signal: AbortSignal | undefined, req: GetAssignableRolesForResourceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/preview/accounts/{account_id}/access-control/assignable-roles`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -62,15 +53,8 @@ export class Client { let resp: GetAssignableRolesForResourceResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetAssignableRolesForResourceResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetAssignableRolesForResourceResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -83,11 +67,7 @@ export class Client { * Get a rule set by its name. A rule set is always attached to a resource and contains a list of access rules on the * said resource. Currently only a default rule set for each resource is supported. */ - async getRuleSet( - signal: AbortSignal | undefined, - req: GetRuleSetRequest, - options?: Options - ): Promise { + async getRuleSet(signal: AbortSignal | undefined, req: GetRuleSetRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/preview/accounts/{account_id}/access-control/rule-sets`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -104,11 +84,7 @@ export class Client { let resp: RuleSet | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRuleSetSchema); }; await execute(signal, call, options); @@ -122,21 +98,13 @@ export class Client { * Replace the rules of a rule set. First, use get to read the current version of the rule set before modifying it. * This pattern helps prevent conflicts between concurrent updates. */ - async updateRuleSet( - signal: AbortSignal | undefined, - req: UpdateRuleSetRequest, - options?: Options - ): Promise { + async updateRuleSet(signal: AbortSignal | undefined, req: UpdateRuleSetRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/preview/accounts/{account_id}/access-control/rule-sets`; const body = marshalRequest(req, marshalUpdateRuleSetRequestSchema); let resp: RuleSet | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRuleSetSchema); }; await execute(signal, call, options); diff --git a/packages/accountaccesscontrol/src/v1/index.ts b/packages/accountaccesscontrol/src/v1/index.ts index b2fe121e..11eb57fd 100644 --- a/packages/accountaccesscontrol/src/v1/index.ts +++ b/packages/accountaccesscontrol/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { GetAssignableRolesForResourceRequest, diff --git a/packages/accountaccesscontrol/src/v1/model.ts b/packages/accountaccesscontrol/src/v1/model.ts index 0be5ac84..568bc9c8 100644 --- a/packages/accountaccesscontrol/src/v1/model.ts +++ b/packages/accountaccesscontrol/src/v1/model.ts @@ -7,7 +7,7 @@ export interface GetAssignableRolesForResourceRequest { accountId?: string | undefined; /** * The resource name for which assignable roles will be listed. - * + * * Examples | Summary * :--- | :--- * `resource=accounts/` | A resource name for the account. @@ -27,7 +27,7 @@ export interface GetRuleSetRequest { accountId?: string | undefined; /** * The ruleset name associated with the request. - * + * * Examples | Summary * :--- | :--- * `name=accounts//ruleSets/default` | A name for a rule set on the account. @@ -42,7 +42,7 @@ export interface GetRuleSetRequest { * 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. @@ -110,25 +110,23 @@ export interface UpdateRuleSetRequest { ruleSet?: RuleSetUpdateRequest | undefined; } -export const unmarshalGetAssignableRolesForResourceRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - resource: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - resource: d.resource, - })); +export const unmarshalGetAssignableRolesForResourceRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + resource: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + resource: d.resource, + })); -export const unmarshalGetAssignableRolesForResourceResponseSchema: z.ZodType = - z - .object({ - roles: z.array(z.lazy(() => unmarshalRoleSchema)).optional(), - }) - .transform(d => ({ - roles: d.roles, - })); +export const unmarshalGetAssignableRolesForResourceResponseSchema: z.ZodType = z + .object({ + roles: z.array(z.lazy(() => unmarshalRoleSchema)).optional(), + }) + .transform(d => ({ + roles: d.roles, + })); export const unmarshalGetRuleSetRequestSchema: z.ZodType = z .object({ @@ -172,31 +170,29 @@ export const unmarshalRuleSetSchema: z.ZodType = z grantRules: d.grant_rules, })); -export const unmarshalRuleSetUpdateRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - etag: z.string().optional(), - grant_rules: z.array(z.lazy(() => unmarshalGrantRuleSchema)).optional(), - }) - .transform(d => ({ - name: d.name, - etag: d.etag, - grantRules: d.grant_rules, - })); +export const unmarshalRuleSetUpdateRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + etag: z.string().optional(), + grant_rules: z.array(z.lazy(() => unmarshalGrantRuleSchema)).optional(), + }) + .transform(d => ({ + name: d.name, + etag: d.etag, + grantRules: d.grant_rules, + })); -export const unmarshalUpdateRuleSetRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - name: z.string().optional(), - rule_set: z.lazy(() => unmarshalRuleSetUpdateRequestSchema).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - name: d.name, - ruleSet: d.rule_set, - })); +export const unmarshalUpdateRuleSetRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + name: z.string().optional(), + rule_set: z.lazy(() => unmarshalRuleSetUpdateRequestSchema).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + name: d.name, + ruleSet: d.rule_set, + })); export const marshalGetAssignableRolesForResourceRequestSchema: z.ZodType = z .object({ diff --git a/packages/accountaccesscontrol/src/v1/utils.ts b/packages/accountaccesscontrol/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/accountaccesscontrol/src/v1/utils.ts +++ b/packages/accountaccesscontrol/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/accountaccesscontrol/tsconfig.json b/packages/accountaccesscontrol/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/accountaccesscontrol/tsconfig.json +++ b/packages/accountaccesscontrol/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/accountaccesscontrolproxy/package.json b/packages/accountaccesscontrolproxy/package.json index fad9da13..90d9740d 100644 --- a/packages/accountaccesscontrolproxy/package.json +++ b/packages/accountaccesscontrolproxy/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/accountaccesscontrolproxy/src/v1/client.ts b/packages/accountaccesscontrolproxy/src/v1/client.ts index 84357d0e..f118ae70 100644 --- a/packages/accountaccesscontrolproxy/src/v1/client.ts +++ b/packages/accountaccesscontrolproxy/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { GetAssignableRolesForResourceRequest, GetAssignableRolesForResourceResponse, @@ -44,11 +39,7 @@ export class Client { * Gets all the roles that can be granted on an account level resource. A role is grantable if the rule set on the * resource can contain an access rule of the role. */ - async getAssignableRolesForResource( - signal: AbortSignal | undefined, - req: GetAssignableRolesForResourceRequest, - options?: Options - ): Promise { + async getAssignableRolesForResource(signal: AbortSignal | undefined, req: GetAssignableRolesForResourceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/preview/accounts/{account_id}/access-control/assignable-roles`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -62,15 +53,8 @@ export class Client { let resp: GetAssignableRolesForResourceResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetAssignableRolesForResourceResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetAssignableRolesForResourceResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -83,11 +67,7 @@ export class Client { * Get a rule set by its name. A rule set is always attached to a resource and contains a list of access rules on the * said resource. Currently only a default rule set for each resource is supported. */ - async getRuleSet( - signal: AbortSignal | undefined, - req: GetRuleSetRequest, - options?: Options - ): Promise { + async getRuleSet(signal: AbortSignal | undefined, req: GetRuleSetRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/preview/accounts/{account_id}/access-control/rule-sets`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -104,11 +84,7 @@ export class Client { let resp: RuleSet | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRuleSetSchema); }; await execute(signal, call, options); @@ -122,21 +98,13 @@ export class Client { * Replace the rules of a rule set. First, use get to read the current version of the rule set before modifying it. * This pattern helps prevent conflicts between concurrent updates. */ - async updateRuleSet( - signal: AbortSignal | undefined, - req: UpdateRuleSetRequest, - options?: Options - ): Promise { + async updateRuleSet(signal: AbortSignal | undefined, req: UpdateRuleSetRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/preview/accounts/{account_id}/access-control/rule-sets`; const body = marshalRequest(req, marshalUpdateRuleSetRequestSchema); let resp: RuleSet | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRuleSetSchema); }; await execute(signal, call, options); diff --git a/packages/accountaccesscontrolproxy/src/v1/index.ts b/packages/accountaccesscontrolproxy/src/v1/index.ts index b2fe121e..11eb57fd 100644 --- a/packages/accountaccesscontrolproxy/src/v1/index.ts +++ b/packages/accountaccesscontrolproxy/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { GetAssignableRolesForResourceRequest, diff --git a/packages/accountaccesscontrolproxy/src/v1/model.ts b/packages/accountaccesscontrolproxy/src/v1/model.ts index 0be5ac84..568bc9c8 100644 --- a/packages/accountaccesscontrolproxy/src/v1/model.ts +++ b/packages/accountaccesscontrolproxy/src/v1/model.ts @@ -7,7 +7,7 @@ export interface GetAssignableRolesForResourceRequest { accountId?: string | undefined; /** * The resource name for which assignable roles will be listed. - * + * * Examples | Summary * :--- | :--- * `resource=accounts/` | A resource name for the account. @@ -27,7 +27,7 @@ export interface GetRuleSetRequest { accountId?: string | undefined; /** * The ruleset name associated with the request. - * + * * Examples | Summary * :--- | :--- * `name=accounts//ruleSets/default` | A name for a rule set on the account. @@ -42,7 +42,7 @@ export interface GetRuleSetRequest { * 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. @@ -110,25 +110,23 @@ export interface UpdateRuleSetRequest { ruleSet?: RuleSetUpdateRequest | undefined; } -export const unmarshalGetAssignableRolesForResourceRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - resource: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - resource: d.resource, - })); +export const unmarshalGetAssignableRolesForResourceRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + resource: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + resource: d.resource, + })); -export const unmarshalGetAssignableRolesForResourceResponseSchema: z.ZodType = - z - .object({ - roles: z.array(z.lazy(() => unmarshalRoleSchema)).optional(), - }) - .transform(d => ({ - roles: d.roles, - })); +export const unmarshalGetAssignableRolesForResourceResponseSchema: z.ZodType = z + .object({ + roles: z.array(z.lazy(() => unmarshalRoleSchema)).optional(), + }) + .transform(d => ({ + roles: d.roles, + })); export const unmarshalGetRuleSetRequestSchema: z.ZodType = z .object({ @@ -172,31 +170,29 @@ export const unmarshalRuleSetSchema: z.ZodType = z grantRules: d.grant_rules, })); -export const unmarshalRuleSetUpdateRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - etag: z.string().optional(), - grant_rules: z.array(z.lazy(() => unmarshalGrantRuleSchema)).optional(), - }) - .transform(d => ({ - name: d.name, - etag: d.etag, - grantRules: d.grant_rules, - })); +export const unmarshalRuleSetUpdateRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + etag: z.string().optional(), + grant_rules: z.array(z.lazy(() => unmarshalGrantRuleSchema)).optional(), + }) + .transform(d => ({ + name: d.name, + etag: d.etag, + grantRules: d.grant_rules, + })); -export const unmarshalUpdateRuleSetRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - name: z.string().optional(), - rule_set: z.lazy(() => unmarshalRuleSetUpdateRequestSchema).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - name: d.name, - ruleSet: d.rule_set, - })); +export const unmarshalUpdateRuleSetRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + name: z.string().optional(), + rule_set: z.lazy(() => unmarshalRuleSetUpdateRequestSchema).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + name: d.name, + ruleSet: d.rule_set, + })); export const marshalGetAssignableRolesForResourceRequestSchema: z.ZodType = z .object({ diff --git a/packages/accountaccesscontrolproxy/src/v1/utils.ts b/packages/accountaccesscontrolproxy/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/accountaccesscontrolproxy/src/v1/utils.ts +++ b/packages/accountaccesscontrolproxy/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/accountaccesscontrolproxy/tsconfig.json b/packages/accountaccesscontrolproxy/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/accountaccesscontrolproxy/tsconfig.json +++ b/packages/accountaccesscontrolproxy/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/alerts/package.json b/packages/alerts/package.json index cb960f55..85502370 100644 --- a/packages/alerts/package.json +++ b/packages/alerts/package.json @@ -31,6 +31,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/alerts/src/v1/client.ts b/packages/alerts/src/v1/client.ts index a25d894f..61853b67 100644 --- a/packages/alerts/src/v1/client.ts +++ b/packages/alerts/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { Alert, CreateAlertRequest, @@ -47,21 +42,13 @@ export class Client { } /** Creates an alert. */ - async createAlert( - signal: AbortSignal | undefined, - req: CreateAlertRequest, - options?: Options - ): Promise { + async createAlert(signal: AbortSignal | undefined, req: CreateAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/alerts`; const body = marshalRequest(req, marshalCreateAlertRequestSchema); let resp: Alert | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAlertSchema); }; await execute(signal, call, options); @@ -72,20 +59,12 @@ export class Client { } /** Gets an alert. */ - async getAlert( - signal: AbortSignal | undefined, - req: GetAlertRequest, - options?: Options - ): Promise { + async getAlert(signal: AbortSignal | undefined, req: GetAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`; let resp: Alert | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAlertSchema); }; await execute(signal, call, options); @@ -96,11 +75,7 @@ export class Client { } /** Gets a list of alerts accessible to the user, ordered by creation time. **Warning:** Calling this API concurrently 10 or more times could result in throttling, service degradation, or a temporary ban. */ - async listAlerts( - signal: AbortSignal | undefined, - req: ListAlertsRequest, - options?: Options - ): Promise { + async listAlerts(signal: AbortSignal | undefined, req: ListAlertsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/alerts`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -114,11 +89,7 @@ export class Client { let resp: ListAlertsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListAlertsResponseSchema); }; await execute(signal, call, options); @@ -128,11 +99,8 @@ export class Client { return resp; } - async *listAlertsIter( - signal: AbortSignal | undefined, - req: ListAlertsRequest, - options?: Options - ): AsyncGenerator { + + async *listAlertsIter(signal: AbortSignal | undefined, req: ListAlertsRequest, options?: Options): AsyncGenerator { const pageReq: ListAlertsRequest = {...req}; for (;;) { const resp = await this.listAlerts(signal, pageReq, options); @@ -146,21 +114,14 @@ export class Client { } } + /** Moves an alert to the trash. Trashed alerts immediately disappear from searches and list views, and can no longer trigger. You can restore a trashed alert through the UI. A trashed alert is permanently deleted after 30 days. */ - async trashAlert( - signal: AbortSignal | undefined, - req: TrashAlertRequest, - options?: Options - ): Promise { + async trashAlert(signal: AbortSignal | undefined, req: TrashAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`; let resp: Empty | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEmptySchema); }; await execute(signal, call, options); @@ -171,21 +132,13 @@ export class Client { } /** Updates an alert. */ - async updateAlert( - signal: AbortSignal | undefined, - req: UpdateAlertRequest, - options?: Options - ): Promise { + async updateAlert(signal: AbortSignal | undefined, req: UpdateAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`; const body = marshalRequest(req, marshalUpdateAlertRequestSchema); let resp: Alert | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAlertSchema); }; await execute(signal, call, options); diff --git a/packages/alerts/src/v1/index.ts b/packages/alerts/src/v1/index.ts index 54f7cfd0..8b10b8d5 100644 --- a/packages/alerts/src/v1/index.ts +++ b/packages/alerts/src/v1/index.ts @@ -1,8 +1,13 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {AlertOperator, AlertState, LifecycleState} from './model'; +export { + AlertOperator, + AlertState, + LifecycleState, +} from './model'; export type { Alert, diff --git a/packages/alerts/src/v1/model.ts b/packages/alerts/src/v1/model.ts index 079f9603..4631353d 100644 --- a/packages/alerts/src/v1/model.ts +++ b/packages/alerts/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export enum AlertOperator { @@ -182,7 +184,7 @@ export interface TrashAlertRequest { export interface UpdateAlertRequest { alert?: UpdateAlertRequestAlert | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; id?: string | undefined; /** 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?: boolean | undefined; @@ -229,23 +231,14 @@ export const unmarshalAlertSchema: z.ZodType = z state: z.enum(AlertState).optional(), seconds_to_retrigger: z.number().optional(), lifecycle_state: z.enum(LifecycleState).optional(), - trigger_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + trigger_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), custom_body: z.string().optional(), custom_subject: z.string().optional(), condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), owner_user_name: z.string().optional(), parent_path: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), notify_on_ok: z.boolean().optional(), }) .transform(d => ({ @@ -290,14 +283,13 @@ export const unmarshalAlertOperandSchema: z.ZodType = z column: d.column, })); -export const unmarshalAlertOperandColumnSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalAlertOperandColumnSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const unmarshalAlertOperandValueSchema: z.ZodType = z .object({ @@ -311,64 +303,55 @@ export const unmarshalAlertOperandValueSchema: z.ZodType = z boolValue: d.bool_value, })); -export const unmarshalCreateAlertRequestSchema: z.ZodType = - z - .object({ - alert: z.lazy(() => unmarshalCreateAlertRequestAlertSchema).optional(), - auto_resolve_display_name: z.boolean().optional(), - }) - .transform(d => ({ - alert: d.alert, - autoResolveDisplayName: d.auto_resolve_display_name, - })); - -export const unmarshalCreateAlertRequestAlertSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - query_id: z.string().optional(), - state: z.enum(AlertState).optional(), - seconds_to_retrigger: z.number().optional(), - lifecycle_state: z.enum(LifecycleState).optional(), - trigger_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - custom_body: z.string().optional(), - custom_subject: z.string().optional(), - condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), - owner_user_name: z.string().optional(), - parent_path: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - notify_on_ok: z.boolean().optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - queryId: d.query_id, - state: d.state, - secondsToRetrigger: d.seconds_to_retrigger, - lifecycleState: d.lifecycle_state, - triggerTime: d.trigger_time, - customBody: d.custom_body, - customSubject: d.custom_subject, - condition: d.condition, - ownerUserName: d.owner_user_name, - parentPath: d.parent_path, - createTime: d.create_time, - updateTime: d.update_time, - notifyOnOk: d.notify_on_ok, - })); - -export const unmarshalEmptySchema: z.ZodType = z.object({}); +export const unmarshalCreateAlertRequestSchema: z.ZodType = z + .object({ + alert: z.lazy(() => unmarshalCreateAlertRequestAlertSchema).optional(), + auto_resolve_display_name: z.boolean().optional(), + }) + .transform(d => ({ + alert: d.alert, + autoResolveDisplayName: d.auto_resolve_display_name, + })); + +export const unmarshalCreateAlertRequestAlertSchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + query_id: z.string().optional(), + state: z.enum(AlertState).optional(), + seconds_to_retrigger: z.number().optional(), + lifecycle_state: z.enum(LifecycleState).optional(), + trigger_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + custom_body: z.string().optional(), + custom_subject: z.string().optional(), + condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), + owner_user_name: z.string().optional(), + parent_path: z.string().optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + notify_on_ok: z.boolean().optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + queryId: d.query_id, + state: d.state, + secondsToRetrigger: d.seconds_to_retrigger, + lifecycleState: d.lifecycle_state, + triggerTime: d.trigger_time, + customBody: d.custom_body, + customSubject: d.custom_subject, + condition: d.condition, + ownerUserName: d.owner_user_name, + parentPath: d.parent_path, + createTime: d.create_time, + updateTime: d.update_time, + notifyOnOk: d.notify_on_ok, + })); + +export const unmarshalEmptySchema: z.ZodType = z + .object({ + }); export const unmarshalGetAlertRequestSchema: z.ZodType = z .object({ @@ -388,64 +371,51 @@ export const unmarshalListAlertsRequestSchema: z.ZodType = z pageSize: d.page_size, })); -export const unmarshalListAlertsResponseSchema: z.ZodType = - z - .object({ - results: z - .array(z.lazy(() => unmarshalListAlertsResponseAlertSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - results: d.results, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListAlertsResponseAlertSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - query_id: z.string().optional(), - state: z.enum(AlertState).optional(), - seconds_to_retrigger: z.number().optional(), - lifecycle_state: z.enum(LifecycleState).optional(), - trigger_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - custom_body: z.string().optional(), - custom_subject: z.string().optional(), - condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), - owner_user_name: z.string().optional(), - parent_path: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - notify_on_ok: z.boolean().optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - queryId: d.query_id, - state: d.state, - secondsToRetrigger: d.seconds_to_retrigger, - lifecycleState: d.lifecycle_state, - triggerTime: d.trigger_time, - customBody: d.custom_body, - customSubject: d.custom_subject, - condition: d.condition, - ownerUserName: d.owner_user_name, - parentPath: d.parent_path, - createTime: d.create_time, - updateTime: d.update_time, - notifyOnOk: d.notify_on_ok, - })); +export const unmarshalListAlertsResponseSchema: z.ZodType = z + .object({ + results: z.array(z.lazy(() => unmarshalListAlertsResponseAlertSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + results: d.results, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListAlertsResponseAlertSchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + query_id: z.string().optional(), + state: z.enum(AlertState).optional(), + seconds_to_retrigger: z.number().optional(), + lifecycle_state: z.enum(LifecycleState).optional(), + trigger_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + custom_body: z.string().optional(), + custom_subject: z.string().optional(), + condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), + owner_user_name: z.string().optional(), + parent_path: z.string().optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + notify_on_ok: z.boolean().optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + queryId: d.query_id, + state: d.state, + secondsToRetrigger: d.seconds_to_retrigger, + lifecycleState: d.lifecycle_state, + triggerTime: d.trigger_time, + customBody: d.custom_body, + customSubject: d.custom_subject, + condition: d.condition, + ownerUserName: d.owner_user_name, + parentPath: d.parent_path, + createTime: d.create_time, + updateTime: d.update_time, + notifyOnOk: d.notify_on_ok, + })); export const unmarshalTrashAlertRequestSchema: z.ZodType = z .object({ @@ -455,66 +425,55 @@ export const unmarshalTrashAlertRequestSchema: z.ZodType = z id: d.id, })); -export const unmarshalUpdateAlertRequestSchema: z.ZodType = - z - .object({ - alert: z.lazy(() => unmarshalUpdateAlertRequestAlertSchema).optional(), - update_mask: z.string().optional(), - id: z.string().optional(), - auto_resolve_display_name: z.boolean().optional(), - }) - .transform(d => ({ - alert: d.alert, - updateMask: d.update_mask, - id: d.id, - autoResolveDisplayName: d.auto_resolve_display_name, - })); - -export const unmarshalUpdateAlertRequestAlertSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - query_id: z.string().optional(), - state: z.enum(AlertState).optional(), - seconds_to_retrigger: z.number().optional(), - lifecycle_state: z.enum(LifecycleState).optional(), - trigger_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - custom_body: z.string().optional(), - custom_subject: z.string().optional(), - condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), - owner_user_name: z.string().optional(), - parent_path: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - notify_on_ok: z.boolean().optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - queryId: d.query_id, - state: d.state, - secondsToRetrigger: d.seconds_to_retrigger, - lifecycleState: d.lifecycle_state, - triggerTime: d.trigger_time, - customBody: d.custom_body, - customSubject: d.custom_subject, - condition: d.condition, - ownerUserName: d.owner_user_name, - parentPath: d.parent_path, - createTime: d.create_time, - updateTime: d.update_time, - notifyOnOk: d.notify_on_ok, - })); +export const unmarshalUpdateAlertRequestSchema: z.ZodType = z + .object({ + alert: z.lazy(() => unmarshalUpdateAlertRequestAlertSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + id: z.string().optional(), + auto_resolve_display_name: z.boolean().optional(), + }) + .transform(d => ({ + alert: d.alert, + updateMask: d.update_mask, + id: d.id, + autoResolveDisplayName: d.auto_resolve_display_name, + })); + +export const unmarshalUpdateAlertRequestAlertSchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + query_id: z.string().optional(), + state: z.enum(AlertState).optional(), + seconds_to_retrigger: z.number().optional(), + lifecycle_state: z.enum(LifecycleState).optional(), + trigger_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + custom_body: z.string().optional(), + custom_subject: z.string().optional(), + condition: z.lazy(() => unmarshalAlertConditionSchema).optional(), + owner_user_name: z.string().optional(), + parent_path: z.string().optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + notify_on_ok: z.boolean().optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + queryId: d.query_id, + state: d.state, + secondsToRetrigger: d.seconds_to_retrigger, + lifecycleState: d.lifecycle_state, + triggerTime: d.trigger_time, + customBody: d.custom_body, + customSubject: d.custom_subject, + condition: d.condition, + ownerUserName: d.owner_user_name, + parentPath: d.parent_path, + createTime: d.create_time, + updateTime: d.update_time, + notifyOnOk: d.notify_on_ok, + })); export const marshalAlertSchema: z.ZodType = z .object({ @@ -524,23 +483,14 @@ export const marshalAlertSchema: z.ZodType = z state: z.enum(AlertState).optional(), secondsToRetrigger: z.number().optional(), lifecycleState: z.enum(LifecycleState).optional(), - triggerTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + triggerTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), customBody: z.string().optional(), customSubject: z.string().optional(), condition: z.lazy(() => marshalAlertConditionSchema).optional(), ownerUserName: z.string().optional(), parentPath: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), notifyOnOk: z.boolean().optional(), }) .transform(d => ({ @@ -623,23 +573,14 @@ export const marshalCreateAlertRequestAlertSchema: z.ZodType = z state: z.enum(AlertState).optional(), secondsToRetrigger: z.number().optional(), lifecycleState: z.enum(LifecycleState).optional(), - triggerTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + triggerTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), customBody: z.string().optional(), customSubject: z.string().optional(), condition: z.lazy(() => marshalAlertConditionSchema).optional(), ownerUserName: z.string().optional(), parentPath: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), notifyOnOk: z.boolean().optional(), }) .transform(d => ({ @@ -660,7 +601,9 @@ export const marshalCreateAlertRequestAlertSchema: z.ZodType = z notify_on_ok: d.notifyOnOk, })); -export const marshalEmptySchema: z.ZodType = z.object({}); +export const marshalEmptySchema: z.ZodType = z + .object({ + }); export const marshalGetAlertRequestSchema: z.ZodType = z .object({ @@ -682,9 +625,7 @@ export const marshalListAlertsRequestSchema: z.ZodType = z export const marshalListAlertsResponseSchema: z.ZodType = z .object({ - results: z - .array(z.lazy(() => marshalListAlertsResponseAlertSchema)) - .optional(), + results: z.array(z.lazy(() => marshalListAlertsResponseAlertSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -700,23 +641,14 @@ export const marshalListAlertsResponseAlertSchema: z.ZodType = z state: z.enum(AlertState).optional(), secondsToRetrigger: z.number().optional(), lifecycleState: z.enum(LifecycleState).optional(), - triggerTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + triggerTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), customBody: z.string().optional(), customSubject: z.string().optional(), condition: z.lazy(() => marshalAlertConditionSchema).optional(), ownerUserName: z.string().optional(), parentPath: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), notifyOnOk: z.boolean().optional(), }) .transform(d => ({ @@ -748,7 +680,7 @@ export const marshalTrashAlertRequestSchema: z.ZodType = z export const marshalUpdateAlertRequestSchema: z.ZodType = z .object({ alert: z.lazy(() => marshalUpdateAlertRequestAlertSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), id: z.string().optional(), autoResolveDisplayName: z.boolean().optional(), }) @@ -767,23 +699,14 @@ export const marshalUpdateAlertRequestAlertSchema: z.ZodType = z state: z.enum(AlertState).optional(), secondsToRetrigger: z.number().optional(), lifecycleState: z.enum(LifecycleState).optional(), - triggerTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + triggerTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), customBody: z.string().optional(), customSubject: z.string().optional(), condition: z.lazy(() => marshalAlertConditionSchema).optional(), ownerUserName: z.string().optional(), parentPath: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), notifyOnOk: z.boolean().optional(), }) .transform(d => ({ diff --git a/packages/alerts/src/v1/utils.ts b/packages/alerts/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/alerts/src/v1/utils.ts +++ b/packages/alerts/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/alerts/src/v2/client.ts b/packages/alerts/src/v2/client.ts index 9b60dc21..779d1e63 100644 --- a/packages/alerts/src/v2/client.ts +++ b/packages/alerts/src/v2/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { Alert, CreateAlertRequest, @@ -45,21 +40,13 @@ export class Client { } /** Create Alert */ - async createAlert( - signal: AbortSignal | undefined, - req: CreateAlertRequest, - options?: Options - ): Promise { + async createAlert(signal: AbortSignal | undefined, req: CreateAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/alerts`; const body = marshalRequest(req.alert, marshalAlertSchema); let resp: Alert | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAlertSchema); }; await execute(signal, call, options); @@ -70,20 +57,12 @@ export class Client { } /** Gets an alert. */ - async getAlert( - signal: AbortSignal | undefined, - req: GetAlertRequest, - options?: Options - ): Promise { + async getAlert(signal: AbortSignal | undefined, req: GetAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/alerts/${req.id ?? ''}`; let resp: Alert | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAlertSchema); }; await execute(signal, call, options); @@ -94,11 +73,7 @@ export class Client { } /** Gets a list of alerts accessible to the user, ordered by creation time. */ - async listAlerts( - signal: AbortSignal | undefined, - req: ListAlertsRequest, - options?: Options - ): Promise { + async listAlerts(signal: AbortSignal | undefined, req: ListAlertsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/alerts`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -112,11 +87,7 @@ export class Client { let resp: ListAlertsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListAlertsResponseSchema); }; await execute(signal, call, options); @@ -126,11 +97,8 @@ export class Client { return resp; } - async *listAlertsIter( - signal: AbortSignal | undefined, - req: ListAlertsRequest, - options?: Options - ): AsyncGenerator { + + async *listAlertsIter(signal: AbortSignal | undefined, req: ListAlertsRequest, options?: Options): AsyncGenerator { const pageReq: ListAlertsRequest = {...req}; for (;;) { const resp = await this.listAlerts(signal, pageReq, options); @@ -144,12 +112,9 @@ export class Client { } } + /** Moves an alert to the trash. Trashed alerts immediately disappear from list views, and can no longer trigger. You can restore a trashed alert through the UI. A trashed alert is permanently deleted after 30 days. */ - async trashAlert( - signal: AbortSignal | undefined, - req: TrashAlertRequest, - options?: Options - ): Promise { + async trashAlert(signal: AbortSignal | undefined, req: TrashAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/alerts/${req.id ?? ''}`; const params = new URLSearchParams(); if (req.purge !== undefined) { @@ -160,11 +125,7 @@ export class Client { let resp: Empty | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEmptySchema); }; await execute(signal, call, options); @@ -175,15 +136,11 @@ export class Client { } /** Update alert */ - async updateAlert( - signal: AbortSignal | undefined, - req: UpdateAlertRequest, - options?: Options - ): Promise { + async updateAlert(signal: AbortSignal | undefined, req: UpdateAlertRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/alerts/${req.alert?.id ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -191,11 +148,7 @@ export class Client { let resp: Alert | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAlertSchema); }; await execute(signal, call, options); diff --git a/packages/alerts/src/v2/index.ts b/packages/alerts/src/v2/index.ts index 06b14f5c..b6d64a87 100644 --- a/packages/alerts/src/v2/index.ts +++ b/packages/alerts/src/v2/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/alerts/src/v2/model.ts b/packages/alerts/src/v2/model.ts index 9d0793e9..8b73950c 100644 --- a/packages/alerts/src/v2/model.ts +++ b/packages/alerts/src/v2/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export enum Aggregation { @@ -209,7 +211,7 @@ export interface TrashAlertRequest { export interface UpdateAlertRequest { alert?: Alert | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export const unmarshalAlertSchema: z.ZodType = z @@ -217,14 +219,8 @@ export const unmarshalAlertSchema: z.ZodType = z id: z.string().optional(), display_name: z.string().optional(), owner_user_name: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), parent_path: z.string().optional(), query_text: z.string().optional(), warehouse_id: z.string().optional(), @@ -265,10 +261,7 @@ export const unmarshalAlertEvaluationSchema: z.ZodType = z threshold: z.lazy(() => unmarshalAlertOperandSchema).optional(), notification: z.lazy(() => unmarshalAlertNotificationSchema).optional(), state: z.enum(AlertEvaluationState).optional(), - last_evaluated_at: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + last_evaluated_at: z.string().transform(s => Temporal.Instant.from(s)).optional(), empty_result_state: z.enum(AlertEvaluationState).optional(), }) .transform(d => ({ @@ -283,9 +276,7 @@ export const unmarshalAlertEvaluationSchema: z.ZodType = z export const unmarshalAlertNotificationSchema: z.ZodType = z .object({ - subscriptions: z - .array(z.lazy(() => unmarshalAlertSubscriptionSchema)) - .optional(), + subscriptions: z.array(z.lazy(() => unmarshalAlertSubscriptionSchema)).optional(), retrigger_seconds: z.number().optional(), notify_on_ok: z.boolean().optional(), }) @@ -305,18 +296,17 @@ export const unmarshalAlertOperandSchema: z.ZodType = z value: d.value, })); -export const unmarshalAlertOperandColumnSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - display: z.string().optional(), - aggregation: z.enum(Aggregation).optional(), - }) - .transform(d => ({ - name: d.name, - display: d.display, - aggregation: d.aggregation, - })); +export const unmarshalAlertOperandColumnSchema: z.ZodType = z + .object({ + name: z.string().optional(), + display: z.string().optional(), + aggregation: z.enum(Aggregation).optional(), + }) + .transform(d => ({ + name: d.name, + display: d.display, + aggregation: d.aggregation, + })); export const unmarshalAlertOperandValueSchema: z.ZodType = z .object({ @@ -350,14 +340,13 @@ export const unmarshalAlertSubscriptionSchema: z.ZodType = z destinationId: d.destination_id, })); -export const unmarshalCreateAlertRequestSchema: z.ZodType = - z - .object({ - alert: z.lazy(() => unmarshalAlertSchema).optional(), - }) - .transform(d => ({ - alert: d.alert, - })); +export const unmarshalCreateAlertRequestSchema: z.ZodType = z + .object({ + alert: z.lazy(() => unmarshalAlertSchema).optional(), + }) + .transform(d => ({ + alert: d.alert, + })); export const unmarshalCronScheduleSchema: z.ZodType = z .object({ @@ -373,7 +362,9 @@ export const unmarshalCronScheduleSchema: z.ZodType = z effectivePauseStatus: d.effective_pause_status, })); -export const unmarshalEmptySchema: z.ZodType = z.object({}); +export const unmarshalEmptySchema: z.ZodType = z + .object({ + }); export const unmarshalGetAlertRequestSchema: z.ZodType = z .object({ @@ -393,16 +384,15 @@ export const unmarshalListAlertsRequestSchema: z.ZodType = z pageSize: d.page_size, })); -export const unmarshalListAlertsResponseSchema: z.ZodType = - z - .object({ - alerts: z.array(z.lazy(() => unmarshalAlertSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - alerts: d.alerts, - nextPageToken: d.next_page_token, - })); +export const unmarshalListAlertsResponseSchema: z.ZodType = z + .object({ + alerts: z.array(z.lazy(() => unmarshalAlertSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + alerts: d.alerts, + nextPageToken: d.next_page_token, + })); export const unmarshalTrashAlertRequestSchema: z.ZodType = z .object({ @@ -414,30 +404,23 @@ export const unmarshalTrashAlertRequestSchema: z.ZodType = z purge: d.purge, })); -export const unmarshalUpdateAlertRequestSchema: z.ZodType = - z - .object({ - alert: z.lazy(() => unmarshalAlertSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - alert: d.alert, - updateMask: d.update_mask, - })); +export const unmarshalUpdateAlertRequestSchema: z.ZodType = z + .object({ + alert: z.lazy(() => unmarshalAlertSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + alert: d.alert, + updateMask: d.update_mask, + })); export const marshalAlertSchema: z.ZodType = z .object({ id: z.string().optional(), displayName: z.string().optional(), ownerUserName: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), parentPath: z.string().optional(), queryText: z.string().optional(), warehouseId: z.string().optional(), @@ -478,10 +461,7 @@ export const marshalAlertEvaluationSchema: z.ZodType = z threshold: z.lazy(() => marshalAlertOperandSchema).optional(), notification: z.lazy(() => marshalAlertNotificationSchema).optional(), state: z.enum(AlertEvaluationState).optional(), - lastEvaluatedAt: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + lastEvaluatedAt: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), emptyResultState: z.enum(AlertEvaluationState).optional(), }) .transform(d => ({ @@ -496,9 +476,7 @@ export const marshalAlertEvaluationSchema: z.ZodType = z export const marshalAlertNotificationSchema: z.ZodType = z .object({ - subscriptions: z - .array(z.lazy(() => marshalAlertSubscriptionSchema)) - .optional(), + subscriptions: z.array(z.lazy(() => marshalAlertSubscriptionSchema)).optional(), retriggerSeconds: z.number().optional(), notifyOnOk: z.boolean().optional(), }) @@ -584,7 +562,9 @@ export const marshalCronScheduleSchema: z.ZodType = z effective_pause_status: d.effectivePauseStatus, })); -export const marshalEmptySchema: z.ZodType = z.object({}); +export const marshalEmptySchema: z.ZodType = z + .object({ + }); export const marshalGetAlertRequestSchema: z.ZodType = z .object({ @@ -627,7 +607,7 @@ export const marshalTrashAlertRequestSchema: z.ZodType = z export const marshalUpdateAlertRequestSchema: z.ZodType = z .object({ alert: z.lazy(() => marshalAlertSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ alert: d.alert, diff --git a/packages/alerts/src/v2/utils.ts b/packages/alerts/src/v2/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/alerts/src/v2/utils.ts +++ b/packages/alerts/src/v2/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/alerts/tsconfig.json b/packages/alerts/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/alerts/tsconfig.json +++ b/packages/alerts/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/artifactallowlists/package.json b/packages/artifactallowlists/package.json index 9f083553..75f3c979 100644 --- a/packages/artifactallowlists/package.json +++ b/packages/artifactallowlists/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/artifactallowlists/src/v1/client.ts b/packages/artifactallowlists/src/v1/client.ts index 18354c1a..d25f9ce3 100644 --- a/packages/artifactallowlists/src/v1/client.ts +++ b/packages/artifactallowlists/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { ArtifactAllowlistInfo, GetArtifactAllowlist, @@ -42,20 +37,12 @@ export class Client { * The caller must be a metastore admin or have the **MANAGE ALLOWLIST** privilege * on the metastore. */ - async getArtifactAllowlist( - signal: AbortSignal | undefined, - req: GetArtifactAllowlist, - options?: Options - ): Promise { + async getArtifactAllowlist(signal: AbortSignal | undefined, req: GetArtifactAllowlist, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/artifact-allowlists/${req.artifactType ?? ''}`; let resp: ArtifactAllowlistInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalArtifactAllowlistInfoSchema); }; await execute(signal, call, options); @@ -71,21 +58,13 @@ export class Client { * The caller must be a metastore admin or have the **MANAGE ALLOWLIST** privilege * on the metastore. */ - async setArtifactAllowlist( - signal: AbortSignal | undefined, - req: SetArtifactAllowlist, - options?: Options - ): Promise { + async setArtifactAllowlist(signal: AbortSignal | undefined, req: SetArtifactAllowlist, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/artifact-allowlists/${req.artifactType ?? ''}`; const body = marshalRequest(req, marshalSetArtifactAllowlistSchema); let resp: ArtifactAllowlistInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalArtifactAllowlistInfoSchema); }; await execute(signal, call, options); diff --git a/packages/artifactallowlists/src/v1/index.ts b/packages/artifactallowlists/src/v1/index.ts index 9246df0e..ea34f900 100644 --- a/packages/artifactallowlists/src/v1/index.ts +++ b/packages/artifactallowlists/src/v1/index.ts @@ -1,8 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {ArtifactType, ArtifactMatcher_MatchType} from './model'; +export { + ArtifactType, + ArtifactMatcher_MatchType, +} from './model'; export type { ArtifactAllowlistInfo, diff --git a/packages/artifactallowlists/src/v1/model.ts b/packages/artifactallowlists/src/v1/model.ts index b8004a3f..63ce8c67 100644 --- a/packages/artifactallowlists/src/v1/model.ts +++ b/packages/artifactallowlists/src/v1/model.ts @@ -54,22 +54,19 @@ export interface SetArtifactAllowlist { createdAt?: number | undefined; } -export const unmarshalArtifactAllowlistInfoSchema: z.ZodType = - z - .object({ - artifact_matchers: z - .array(z.lazy(() => unmarshalArtifactMatcherSchema)) - .optional(), - metastore_id: z.string().optional(), - created_by: z.string().optional(), - created_at: z.number().optional(), - }) - .transform(d => ({ - artifactMatchers: d.artifact_matchers, - metastoreId: d.metastore_id, - createdBy: d.created_by, - createdAt: d.created_at, - })); +export const unmarshalArtifactAllowlistInfoSchema: z.ZodType = z + .object({ + artifact_matchers: z.array(z.lazy(() => unmarshalArtifactMatcherSchema)).optional(), + metastore_id: z.string().optional(), + created_by: z.string().optional(), + created_at: z.number().optional(), + }) + .transform(d => ({ + artifactMatchers: d.artifact_matchers, + metastoreId: d.metastore_id, + createdBy: d.created_by, + createdAt: d.created_at, + })); export const unmarshalArtifactMatcherSchema: z.ZodType = z .object({ @@ -81,39 +78,33 @@ export const unmarshalArtifactMatcherSchema: z.ZodType = z matchType: d.match_type, })); -export const unmarshalGetArtifactAllowlistSchema: z.ZodType = - z - .object({ - artifact_type: z.enum(ArtifactType).optional(), - }) - .transform(d => ({ - artifactType: d.artifact_type, - })); +export const unmarshalGetArtifactAllowlistSchema: z.ZodType = z + .object({ + artifact_type: z.enum(ArtifactType).optional(), + }) + .transform(d => ({ + artifactType: d.artifact_type, + })); -export const unmarshalSetArtifactAllowlistSchema: z.ZodType = - z - .object({ - artifact_type: z.enum(ArtifactType).optional(), - artifact_matchers: z - .array(z.lazy(() => unmarshalArtifactMatcherSchema)) - .optional(), - metastore_id: z.string().optional(), - created_by: z.string().optional(), - created_at: z.number().optional(), - }) - .transform(d => ({ - artifactType: d.artifact_type, - artifactMatchers: d.artifact_matchers, - metastoreId: d.metastore_id, - createdBy: d.created_by, - createdAt: d.created_at, - })); +export const unmarshalSetArtifactAllowlistSchema: z.ZodType = z + .object({ + artifact_type: z.enum(ArtifactType).optional(), + artifact_matchers: z.array(z.lazy(() => unmarshalArtifactMatcherSchema)).optional(), + metastore_id: z.string().optional(), + created_by: z.string().optional(), + created_at: z.number().optional(), + }) + .transform(d => ({ + artifactType: d.artifact_type, + artifactMatchers: d.artifact_matchers, + metastoreId: d.metastore_id, + createdBy: d.created_by, + createdAt: d.created_at, + })); export const marshalArtifactAllowlistInfoSchema: z.ZodType = z .object({ - artifactMatchers: z - .array(z.lazy(() => marshalArtifactMatcherSchema)) - .optional(), + artifactMatchers: z.array(z.lazy(() => marshalArtifactMatcherSchema)).optional(), metastoreId: z.string().optional(), createdBy: z.string().optional(), createdAt: z.number().optional(), @@ -146,9 +137,7 @@ export const marshalGetArtifactAllowlistSchema: z.ZodType = z export const marshalSetArtifactAllowlistSchema: z.ZodType = z .object({ artifactType: z.enum(ArtifactType).optional(), - artifactMatchers: z - .array(z.lazy(() => marshalArtifactMatcherSchema)) - .optional(), + artifactMatchers: z.array(z.lazy(() => marshalArtifactMatcherSchema)).optional(), metastoreId: z.string().optional(), createdBy: z.string().optional(), createdAt: z.number().optional(), diff --git a/packages/artifactallowlists/src/v1/utils.ts b/packages/artifactallowlists/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/artifactallowlists/src/v1/utils.ts +++ b/packages/artifactallowlists/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/artifactallowlists/tsconfig.json b/packages/artifactallowlists/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/artifactallowlists/tsconfig.json +++ b/packages/artifactallowlists/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/billableusagedownload/package.json b/packages/billableusagedownload/package.json index d622703c..70d3fe18 100644 --- a/packages/billableusagedownload/package.json +++ b/packages/billableusagedownload/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/billableusagedownload/src/v1/client.ts b/packages/billableusagedownload/src/v1/client.ts index 91b36da2..e4a3cab9 100644 --- a/packages/billableusagedownload/src/v1/client.ts +++ b/packages/billableusagedownload/src/v1/client.ts @@ -8,8 +8,13 @@ import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; import {buildHttpRequest, executeHttpCall, parseResponse} from './utils'; -import type {DownloadRequest, DownloadResponse} from './model'; -import {unmarshalDownloadResponseSchema} from './model'; +import type { + DownloadRequest, + DownloadResponse, +} from './model'; +import { + unmarshalDownloadResponseSchema, +} from './model'; export class Client { private readonly host: string; @@ -28,22 +33,18 @@ export class Client { /** * Returns billable usage logs in CSV format for the specified account and date range. * For the data schema, see: - * + * * - AWS: [CSV file schema](https://docs.databricks.com/administration-guide/account-settings/usage-analysis.html#schema). * - GCP: [CSV file schema](https://docs.gcp.databricks.com/administration-guide/account-settings/usage-analysis.html#csv-file-schema). - * + * * Note that this method might take multiple minutes to complete. - * + * * **Warning**: Depending on the queried date range, the number of workspaces * in the account, the size of the response and the internet speed of the caller, * this API may hit a timeout after a few minutes. If you experience this, try to mitigate * by calling the API with narrower date ranges. */ - async download( - signal: AbortSignal | undefined, - req: DownloadRequest, - options?: Options - ): Promise { + async download(signal: AbortSignal | undefined, req: DownloadRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts/{account_id}/usage/download`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -63,11 +64,7 @@ export class Client { let resp: DownloadResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDownloadResponseSchema); }; await execute(signal, call, options); diff --git a/packages/billableusagedownload/src/v1/index.ts b/packages/billableusagedownload/src/v1/index.ts index 81163850..43cc0062 100644 --- a/packages/billableusagedownload/src/v1/index.ts +++ b/packages/billableusagedownload/src/v1/index.ts @@ -1,7 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; -export type {DownloadRequest, DownloadResponse} from './model'; +export type { + DownloadRequest, + DownloadResponse, +} from './model'; diff --git a/packages/billableusagedownload/src/v1/utils.ts b/packages/billableusagedownload/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/billableusagedownload/src/v1/utils.ts +++ b/packages/billableusagedownload/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/billableusagedownload/tsconfig.json b/packages/billableusagedownload/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/billableusagedownload/tsconfig.json +++ b/packages/billableusagedownload/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/catalogs/package.json b/packages/catalogs/package.json index 58bac5fa..9c0a129b 100644 --- a/packages/catalogs/package.json +++ b/packages/catalogs/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/catalogs/src/v1/client.ts b/packages/catalogs/src/v1/client.ts index 0a1e2ae2..61765f15 100644 --- a/packages/catalogs/src/v1/client.ts +++ b/packages/catalogs/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CatalogInfo, CreateCatalog, @@ -46,21 +41,13 @@ export class Client { } /** Creates a new catalog instance in the parent metastore if the caller is a metastore admin or has the **CREATE_CATALOG** privilege. */ - async createCatalog( - signal: AbortSignal | undefined, - req: CreateCatalog, - options?: Options - ): Promise { + async createCatalog(signal: AbortSignal | undefined, req: CreateCatalog, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/catalogs`; const body = marshalRequest(req, marshalCreateCatalogSchema); let resp: CatalogInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogInfoSchema); }; await execute(signal, call, options); @@ -71,11 +58,7 @@ export class Client { } /** Deletes the catalog that matches the supplied name. The caller must be a metastore admin or the owner of the catalog. */ - async deleteCatalog( - signal: AbortSignal | undefined, - req: DeleteCatalog, - options?: Options - ): Promise { + async deleteCatalog(signal: AbortSignal | undefined, req: DeleteCatalog, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/catalogs/${req.nameArg ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -86,11 +69,7 @@ export class Client { let resp: DeleteCatalog_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteCatalog_ResponseSchema); }; await execute(signal, call, options); @@ -104,11 +83,7 @@ export class Client { * Gets the specified catalog in a metastore. * The caller must be a metastore admin, the owner of the catalog, or a user that has the **USE_CATALOG** privilege set for their account. */ - async getCatalog( - signal: AbortSignal | undefined, - req: GetCatalog, - options?: Options - ): Promise { + async getCatalog(signal: AbortSignal | undefined, req: GetCatalog, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/catalogs/${req.nameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -119,11 +94,7 @@ export class Client { let resp: CatalogInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogInfoSchema); }; await execute(signal, call, options); @@ -138,17 +109,13 @@ export class Client { * If the caller is the metastore admin, all catalogs will be retrieved. * Otherwise, only catalogs owned by the caller (or for which the caller has the **USE_CATALOG** privilege) will be retrieved. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listCatalogs( - signal: AbortSignal | undefined, - req: ListCatalogs, - options?: Options - ): Promise { + async listCatalogs(signal: AbortSignal | undefined, req: ListCatalogs, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/catalogs`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -168,11 +135,7 @@ export class Client { let resp: ListCatalogs_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListCatalogs_ResponseSchema); }; await execute(signal, call, options); @@ -182,11 +145,8 @@ export class Client { return resp; } - async *listCatalogsIter( - signal: AbortSignal | undefined, - req: ListCatalogs, - options?: Options - ): AsyncGenerator { + + async *listCatalogsIter(signal: AbortSignal | undefined, req: ListCatalogs, options?: Options): AsyncGenerator { const pageReq: ListCatalogs = {...req}; for (;;) { const resp = await this.listCatalogs(signal, pageReq, options); @@ -200,25 +160,18 @@ export class Client { } } + /** * Updates the catalog that matches the supplied name. * The caller must be either the owner of the catalog, or a metastore admin (when changing the owner field of the catalog). */ - async updateCatalog( - signal: AbortSignal | undefined, - req: UpdateCatalog, - options?: Options - ): Promise { + async updateCatalog(signal: AbortSignal | undefined, req: UpdateCatalog, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/catalogs/${req.nameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateCatalogSchema); let resp: CatalogInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogInfoSchema); }; await execute(signal, call, options); diff --git a/packages/catalogs/src/v1/index.ts b/packages/catalogs/src/v1/index.ts index 300c76ef..ba67876d 100644 --- a/packages/catalogs/src/v1/index.ts +++ b/packages/catalogs/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/catalogs/src/v1/model.ts b/packages/catalogs/src/v1/model.ts index 36b1be49..d7614a20 100644 --- a/packages/catalogs/src/v1/model.ts +++ b/packages/catalogs/src/v1/model.ts @@ -84,7 +84,7 @@ export interface CatalogInfo { catalogType?: CatalogType | undefined; /** * 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 | undefined; @@ -106,9 +106,7 @@ export interface CatalogInfo { storageLocation?: string | undefined; /** Whether the current securable is accessible from all workspaces or a specific set of workspaces. */ isolationMode?: CatalogIsolationMode | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** 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?: boolean | undefined; provisioningInfo?: ProvisioningInfo | undefined; @@ -159,7 +157,7 @@ export interface CreateCatalog { catalogType?: CatalogType | undefined; /** * 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 | undefined; @@ -181,9 +179,7 @@ export interface CreateCatalog { storageLocation?: string | undefined; /** Whether the current securable is accessible from all workspaces or a specific set of workspaces. */ isolationMode?: CatalogIsolationMode | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** 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?: boolean | undefined; provisioningInfo?: ProvisioningInfo | undefined; @@ -317,7 +313,7 @@ export interface UpdateCatalog { catalogType?: CatalogType | undefined; /** * 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 | undefined; @@ -339,9 +335,7 @@ export interface UpdateCatalog { storageLocation?: string | undefined; /** Whether the current securable is accessible from all workspaces or a specific set of workspaces. */ isolationMode?: CatalogIsolationMode | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** 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?: boolean | undefined; provisioningInfo?: ProvisioningInfo | undefined; @@ -372,18 +366,17 @@ export interface UpdateCatalog_PropertiesEntry { value?: string | undefined; } -export const unmarshalAzureEncryptionSettingsSchema: z.ZodType = - z - .object({ - azure_tenant_id: z.string().optional(), - azure_cmk_access_connector_id: z.string().optional(), - azure_cmk_managed_identity_id: z.string().optional(), - }) - .transform(d => ({ - azureTenantId: d.azure_tenant_id, - azureCmkAccessConnectorId: d.azure_cmk_access_connector_id, - azureCmkManagedIdentityId: d.azure_cmk_managed_identity_id, - })); +export const unmarshalAzureEncryptionSettingsSchema: z.ZodType = z + .object({ + azure_tenant_id: z.string().optional(), + azure_cmk_access_connector_id: z.string().optional(), + azure_cmk_managed_identity_id: z.string().optional(), + }) + .transform(d => ({ + azureTenantId: d.azure_tenant_id, + azureCmkAccessConnectorId: d.azure_cmk_access_connector_id, + azureCmkManagedIdentityId: d.azure_cmk_managed_identity_id, + })); export const unmarshalCatalogInfoSchema: z.ZodType = z .object({ @@ -403,20 +396,14 @@ export const unmarshalCatalogInfoSchema: z.ZodType = z updated_by: z.string().optional(), storage_location: z.string().optional(), isolation_mode: z.enum(CatalogIsolationMode).optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), browse_only: z.boolean().optional(), provisioning_info: z.lazy(() => unmarshalProvisioningInfoSchema).optional(), full_name: z.string().optional(), securable_type: z.enum(SecurableType).optional(), conversion_info: z.lazy(() => unmarshalConversionInfoSchema).optional(), - dr_replication_info: z - .lazy(() => unmarshalDrReplicationInfoSchema) - .optional(), - managed_encryption_settings: z - .lazy(() => unmarshalEncryptionSettingsSchema) - .optional(), + dr_replication_info: z.lazy(() => unmarshalDrReplicationInfoSchema).optional(), + managed_encryption_settings: z.lazy(() => unmarshalEncryptionSettingsSchema).optional(), properties: z.record(z.string(), z.string()).optional(), options: z.record(z.string(), z.string()).optional(), }) @@ -437,8 +424,7 @@ export const unmarshalCatalogInfoSchema: z.ZodType = z updatedBy: d.updated_by, storageLocation: d.storage_location, isolationMode: d.isolation_mode, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, browseOnly: d.browse_only, provisioningInfo: d.provisioning_info, fullName: d.full_name, @@ -451,28 +437,26 @@ export const unmarshalCatalogInfoSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCatalogInfo_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCatalogInfo_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCatalogInfo_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCatalogInfo_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalConversionInfoSchema: z.ZodType = z .object({ @@ -500,20 +484,14 @@ export const unmarshalCreateCatalogSchema: z.ZodType = z updated_by: z.string().optional(), storage_location: z.string().optional(), isolation_mode: z.enum(CatalogIsolationMode).optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), browse_only: z.boolean().optional(), provisioning_info: z.lazy(() => unmarshalProvisioningInfoSchema).optional(), full_name: z.string().optional(), securable_type: z.enum(SecurableType).optional(), conversion_info: z.lazy(() => unmarshalConversionInfoSchema).optional(), - dr_replication_info: z - .lazy(() => unmarshalDrReplicationInfoSchema) - .optional(), - managed_encryption_settings: z - .lazy(() => unmarshalEncryptionSettingsSchema) - .optional(), + dr_replication_info: z.lazy(() => unmarshalDrReplicationInfoSchema).optional(), + managed_encryption_settings: z.lazy(() => unmarshalEncryptionSettingsSchema).optional(), properties: z.record(z.string(), z.string()).optional(), options: z.record(z.string(), z.string()).optional(), }) @@ -534,8 +512,7 @@ export const unmarshalCreateCatalogSchema: z.ZodType = z updatedBy: d.updated_by, storageLocation: d.storage_location, isolationMode: d.isolation_mode, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, browseOnly: d.browse_only, provisioningInfo: d.provisioning_info, fullName: d.full_name, @@ -548,28 +525,26 @@ export const unmarshalCreateCatalogSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateCatalog_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCreateCatalog_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateCatalog_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCreateCatalog_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalDeleteCatalogSchema: z.ZodType = z .object({ @@ -582,49 +557,43 @@ export const unmarshalDeleteCatalogSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteCatalog_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteCatalog_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalDrReplicationInfoSchema: z.ZodType = z .object({ status: z.enum(DrReplicationStatus).optional(), - replicated_entities: z - .string() - .transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))) - .optional(), + replicated_entities: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), }) .transform(d => ({ status: d.status, replicatedEntities: d.replicated_entities, })); -export const unmarshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = - z - .object({ - value: z.string().optional(), - inherited_from_type: z.string().optional(), - inherited_from_name: z.string().optional(), - }) - .transform(d => ({ - value: d.value, - inheritedFromType: d.inherited_from_type, - inheritedFromName: d.inherited_from_name, - })); - -export const unmarshalEncryptionSettingsSchema: z.ZodType = - z - .object({ - customer_managed_key_id: z.string().optional(), - azure_key_vault_key_id: z.string().optional(), - azure_encryption_settings: z - .lazy(() => unmarshalAzureEncryptionSettingsSchema) - .optional(), - }) - .transform(d => ({ - customerManagedKeyId: d.customer_managed_key_id, - azureKeyVaultKeyId: d.azure_key_vault_key_id, - azureEncryptionSettings: d.azure_encryption_settings, - })); +export const unmarshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = z + .object({ + value: z.string().optional(), + inherited_from_type: z.string().optional(), + inherited_from_name: z.string().optional(), + }) + .transform(d => ({ + value: d.value, + inheritedFromType: d.inherited_from_type, + inheritedFromName: d.inherited_from_name, + })); + +export const unmarshalEncryptionSettingsSchema: z.ZodType = z + .object({ + customer_managed_key_id: z.string().optional(), + azure_key_vault_key_id: z.string().optional(), + azure_encryption_settings: z.lazy(() => unmarshalAzureEncryptionSettingsSchema).optional(), + }) + .transform(d => ({ + customerManagedKeyId: d.customer_managed_key_id, + azureKeyVaultKeyId: d.azure_key_vault_key_id, + azureEncryptionSettings: d.azure_encryption_settings, + })); export const unmarshalGetCatalogSchema: z.ZodType = z .object({ @@ -651,16 +620,15 @@ export const unmarshalListCatalogsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListCatalogs_ResponseSchema: z.ZodType = - z - .object({ - catalogs: z.array(z.lazy(() => unmarshalCatalogInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - catalogs: d.catalogs, - nextPageToken: d.next_page_token, - })); +export const unmarshalListCatalogs_ResponseSchema: z.ZodType = z + .object({ + catalogs: z.array(z.lazy(() => unmarshalCatalogInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + catalogs: d.catalogs, + nextPageToken: d.next_page_token, + })); export const unmarshalProvisioningInfoSchema: z.ZodType = z .object({ @@ -690,20 +658,14 @@ export const unmarshalUpdateCatalogSchema: z.ZodType = z updated_by: z.string().optional(), storage_location: z.string().optional(), isolation_mode: z.enum(CatalogIsolationMode).optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), browse_only: z.boolean().optional(), provisioning_info: z.lazy(() => unmarshalProvisioningInfoSchema).optional(), full_name: z.string().optional(), securable_type: z.enum(SecurableType).optional(), conversion_info: z.lazy(() => unmarshalConversionInfoSchema).optional(), - dr_replication_info: z - .lazy(() => unmarshalDrReplicationInfoSchema) - .optional(), - managed_encryption_settings: z - .lazy(() => unmarshalEncryptionSettingsSchema) - .optional(), + dr_replication_info: z.lazy(() => unmarshalDrReplicationInfoSchema).optional(), + managed_encryption_settings: z.lazy(() => unmarshalEncryptionSettingsSchema).optional(), properties: z.record(z.string(), z.string()).optional(), options: z.record(z.string(), z.string()).optional(), }) @@ -726,8 +688,7 @@ export const unmarshalUpdateCatalogSchema: z.ZodType = z updatedBy: d.updated_by, storageLocation: d.storage_location, isolationMode: d.isolation_mode, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, browseOnly: d.browse_only, provisioningInfo: d.provisioning_info, fullName: d.full_name, @@ -740,28 +701,26 @@ export const unmarshalUpdateCatalogSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateCatalog_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalUpdateCatalog_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateCatalog_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalUpdateCatalog_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const marshalAzureEncryptionSettingsSchema: z.ZodType = z .object({ @@ -793,18 +752,14 @@ export const marshalCatalogInfoSchema: z.ZodType = z updatedBy: z.string().optional(), storageLocation: z.string().optional(), isolationMode: z.enum(CatalogIsolationMode).optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), browseOnly: z.boolean().optional(), provisioningInfo: z.lazy(() => marshalProvisioningInfoSchema).optional(), fullName: z.string().optional(), securableType: z.enum(SecurableType).optional(), conversionInfo: z.lazy(() => marshalConversionInfoSchema).optional(), drReplicationInfo: z.lazy(() => marshalDrReplicationInfoSchema).optional(), - managedEncryptionSettings: z - .lazy(() => marshalEncryptionSettingsSchema) - .optional(), + managedEncryptionSettings: z.lazy(() => marshalEncryptionSettingsSchema).optional(), properties: z.record(z.string(), z.string()).optional(), options: z.record(z.string(), z.string()).optional(), }) @@ -825,8 +780,7 @@ export const marshalCatalogInfoSchema: z.ZodType = z updated_by: d.updatedBy, storage_location: d.storageLocation, isolation_mode: d.isolationMode, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, browse_only: d.browseOnly, provisioning_info: d.provisioningInfo, full_name: d.fullName, @@ -886,18 +840,14 @@ export const marshalCreateCatalogSchema: z.ZodType = z updatedBy: z.string().optional(), storageLocation: z.string().optional(), isolationMode: z.enum(CatalogIsolationMode).optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), browseOnly: z.boolean().optional(), provisioningInfo: z.lazy(() => marshalProvisioningInfoSchema).optional(), fullName: z.string().optional(), securableType: z.enum(SecurableType).optional(), conversionInfo: z.lazy(() => marshalConversionInfoSchema).optional(), drReplicationInfo: z.lazy(() => marshalDrReplicationInfoSchema).optional(), - managedEncryptionSettings: z - .lazy(() => marshalEncryptionSettingsSchema) - .optional(), + managedEncryptionSettings: z.lazy(() => marshalEncryptionSettingsSchema).optional(), properties: z.record(z.string(), z.string()).optional(), options: z.record(z.string(), z.string()).optional(), }) @@ -918,8 +868,7 @@ export const marshalCreateCatalogSchema: z.ZodType = z updated_by: d.updatedBy, storage_location: d.storageLocation, isolation_mode: d.isolationMode, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, browse_only: d.browseOnly, provisioning_info: d.provisioningInfo, full_name: d.fullName, @@ -964,17 +913,14 @@ export const marshalDeleteCatalogSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteCatalog_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteCatalog_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDrReplicationInfoSchema: z.ZodType = z .object({ status: z.enum(DrReplicationStatus).optional(), - replicatedEntities: z - .any() - .transform((d: Uint8Array) => - btoa(Array.from(d, b => String.fromCharCode(b)).join('')) - ) - .optional(), + replicatedEntities: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), }) .transform(d => ({ status: d.status, @@ -997,9 +943,7 @@ export const marshalEncryptionSettingsSchema: z.ZodType = z .object({ customerManagedKeyId: z.string().optional(), azureKeyVaultKeyId: z.string().optional(), - azureEncryptionSettings: z - .lazy(() => marshalAzureEncryptionSettingsSchema) - .optional(), + azureEncryptionSettings: z.lazy(() => marshalAzureEncryptionSettingsSchema).optional(), }) .transform(d => ({ customer_managed_key_id: d.customerManagedKeyId, @@ -1070,18 +1014,14 @@ export const marshalUpdateCatalogSchema: z.ZodType = z updatedBy: z.string().optional(), storageLocation: z.string().optional(), isolationMode: z.enum(CatalogIsolationMode).optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), browseOnly: z.boolean().optional(), provisioningInfo: z.lazy(() => marshalProvisioningInfoSchema).optional(), fullName: z.string().optional(), securableType: z.enum(SecurableType).optional(), conversionInfo: z.lazy(() => marshalConversionInfoSchema).optional(), drReplicationInfo: z.lazy(() => marshalDrReplicationInfoSchema).optional(), - managedEncryptionSettings: z - .lazy(() => marshalEncryptionSettingsSchema) - .optional(), + managedEncryptionSettings: z.lazy(() => marshalEncryptionSettingsSchema).optional(), properties: z.record(z.string(), z.string()).optional(), options: z.record(z.string(), z.string()).optional(), }) @@ -1104,8 +1044,7 @@ export const marshalUpdateCatalogSchema: z.ZodType = z updated_by: d.updatedBy, storage_location: d.storageLocation, isolation_mode: d.isolationMode, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, browse_only: d.browseOnly, provisioning_info: d.provisioningInfo, full_name: d.fullName, diff --git a/packages/catalogs/src/v1/utils.ts b/packages/catalogs/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/catalogs/src/v1/utils.ts +++ b/packages/catalogs/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/catalogs/tsconfig.json b/packages/catalogs/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/catalogs/tsconfig.json +++ b/packages/catalogs/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/clusterpolicies/package.json b/packages/clusterpolicies/package.json new file mode 100644 index 00000000..4c443259 --- /dev/null +++ b/packages/clusterpolicies/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-clusterpolicies", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v2": { + "types": "./dist/v2/index.d.ts", + "import": "./dist/v2/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/clusterpolicies/src/v2/client.ts b/packages/clusterpolicies/src/v2/client.ts new file mode 100644 index 00000000..b30db438 --- /dev/null +++ b/packages/clusterpolicies/src/v2/client.ts @@ -0,0 +1,145 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + CreatePolicy, + CreatePolicy_Response, + DeletePolicy, + DeletePolicy_Response, + EditPolicy, + EditPolicy_Response, + GetPolicy, + ListPolicies, + ListPolicies_Response, + Policy, +} from './model'; +import { + marshalCreatePolicySchema, + marshalDeletePolicySchema, + marshalEditPolicySchema, + unmarshalCreatePolicy_ResponseSchema, + unmarshalDeletePolicy_ResponseSchema, + unmarshalEditPolicy_ResponseSchema, + unmarshalListPolicies_ResponseSchema, + unmarshalPolicySchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** Creates a new policy with prescribed settings. */ + async createPolicy(signal: AbortSignal | undefined, req: CreatePolicy, options?: Options): Promise { + const url = `${this.host}/api/2.0/policies/clusters/create`; + const body = marshalRequest(req, marshalCreatePolicySchema); + let resp: CreatePolicy_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreatePolicy_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Delete a policy for a cluster. Clusters governed by this policy can still run, but cannot be edited. */ + async deletePolicy(signal: AbortSignal | undefined, req: DeletePolicy, options?: Options): Promise { + const url = `${this.host}/api/2.0/policies/clusters/delete`; + const body = marshalRequest(req, marshalDeletePolicySchema); + let resp: DeletePolicy_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeletePolicy_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Update an existing policy for cluster. This operation may make some clusters governed by the previous policy invalid. */ + async editPolicy(signal: AbortSignal | undefined, req: EditPolicy, options?: Options): Promise { + const url = `${this.host}/api/2.0/policies/clusters/edit`; + const body = marshalRequest(req, marshalEditPolicySchema); + let resp: EditPolicy_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalEditPolicy_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Get a cluster policy entity. Creation and editing is available to admins only. */ + async getPolicy(signal: AbortSignal | undefined, req: GetPolicy, options?: Options): Promise { + const url = `${this.host}/api/2.0/policies/clusters/get`; + const params = new URLSearchParams(); + if (req.policyId !== undefined) { + params.append('policy_id', req.policyId); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: Policy | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalPolicySchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Returns a list of policies accessible by the requesting user. */ + async listPolicies(signal: AbortSignal | undefined, req: ListPolicies, options?: Options): Promise { + const url = `${this.host}/api/2.0/policies/clusters/list`; + const params = new URLSearchParams(); + if (req.sortOrder !== undefined) { + params.append('sort_order', req.sortOrder); + } + if (req.sortColumn !== undefined) { + params.append('sort_column', req.sortColumn); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListPolicies_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListPolicies_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/clusterpolicies/src/v2/index.ts b/packages/clusterpolicies/src/v2/index.ts new file mode 100644 index 00000000..b7ecbb20 --- /dev/null +++ b/packages/clusterpolicies/src/v2/index.ts @@ -0,0 +1,26 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { + ListOrder, + PolicySortColumn, +} from './model'; + +export type { + CreatePolicy, + CreatePolicy_Response, + DeletePolicy, + DeletePolicy_Response, + EditPolicy, + EditPolicy_Response, + GetPolicy, + Library, + ListPolicies, + ListPolicies_Response, + MavenLibrary, + Policy, + PythonPyPiLibrary, + RCranLibrary, +} from './model'; diff --git a/packages/clusterpolicies/src/v2/model.ts b/packages/clusterpolicies/src/v2/model.ts new file mode 100644 index 00000000..b3849651 --- /dev/null +++ b/packages/clusterpolicies/src/v2/model.ts @@ -0,0 +1,598 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +export enum ListOrder { + DESC = 'DESC', + ASC = 'ASC', +} + +export enum PolicySortColumn { + /** Sort result list by policy creation time. */ + POLICY_CREATION_TIME = 'POLICY_CREATION_TIME', + /** Sort result list by policy name. */ + POLICY_NAME = 'POLICY_NAME', +} + +export interface CreatePolicy { + /** + * Cluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 + * characters. + */ + name?: string | undefined; + /** Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). */ + definition?: string | undefined; + /** Additional human-readable description of the cluster policy. */ + description?: string | undefined; + /** + * 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 | undefined; + /** + * Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). + * 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. + */ + policyFamilyDefinitionOverrides?: string | undefined; + /** Max number of clusters per user that can be active using this policy. If not present, there is no max limit. */ + maxClustersPerUser?: number | undefined; + /** 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[] | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface CreatePolicy_Response { + /** Canonical unique identifier for the cluster policy. */ + policyId?: string | undefined; +} + +export interface DeletePolicy { + /** The ID of the policy to delete. */ + policyId?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeletePolicy_Response {} + +export interface EditPolicy { + /** The ID of the policy to update. */ + policyId?: string | undefined; + /** + * Cluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 + * characters. + */ + name?: string | undefined; + /** Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). */ + definition?: string | undefined; + /** Additional human-readable description of the cluster policy. */ + description?: string | undefined; + /** + * 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 | undefined; + /** + * Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). + * 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. + */ + policyFamilyDefinitionOverrides?: string | undefined; + /** Max number of clusters per user that can be active using this policy. If not present, there is no max limit. */ + maxClustersPerUser?: number | undefined; + /** 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[] | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface EditPolicy_Response {} + +export interface GetPolicy { + /** Canonical unique identifier for the Cluster Policy. */ + policyId?: string | undefined; +} + +export interface Library { + /** + * URI of the JAR library to install. Supported URIs include Workspace paths, Unity Catalog Volumes paths, and S3 URIs. + * For example: `{ "jar": "/Workspace/path/to/library.jar" }`, `{ "jar" : "/Volumes/path/to/library.jar" }` or + * `{ "jar": "s3://my-bucket/library.jar" }`. + * If S3 is used, please make sure the cluster has read access on the library. You may need to + * launch the cluster with an IAM role to access the S3 URI. + */ + jar?: string | undefined; + /** Deprecated. URI of the egg library to install. Installing Python egg files is deprecated and is not supported in Databricks Runtime 14.0 and above. */ + egg?: string | undefined; + /** + * Specification of a PyPi library to be installed. For example: + * `{ "package": "simplejson" }` + */ + pypi?: PythonPyPiLibrary | undefined; + /** + * Specification of a maven library to be installed. For example: + * `{ "coordinates": "org.jsoup:jsoup:1.7.2" }` + */ + maven?: MavenLibrary | undefined; + /** Specification of a CRAN library to be installed as part of the library */ + cran?: RCranLibrary | undefined; + /** + * URI of the wheel library to install. Supported URIs include Workspace paths, Unity Catalog Volumes paths, and S3 URIs. + * For example: `{ "whl": "/Workspace/path/to/library.whl" }`, `{ "whl" : "/Volumes/path/to/library.whl" }` or + * `{ "whl": "s3://my-bucket/library.whl" }`. + * If S3 is used, please make sure the cluster has read access on the library. You may need to + * launch the cluster with an IAM role to access the S3 URI. + */ + whl?: string | undefined; + /** + * URI of the requirements.txt file to install. Only Workspace paths and Unity Catalog Volumes paths are supported. + * For example: `{ "requirements": "/Workspace/path/to/requirements.txt" }` or `{ "requirements" : "/Volumes/path/to/requirements.txt" }` + */ + requirements?: string | undefined; +} + +export interface ListPolicies { + /** + * The order in which the policies get listed. + * * `DESC` - Sort result list in descending order. + * * `ASC` - Sort result list in ascending order. + */ + sortOrder?: ListOrder | undefined; + /** + * 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 | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListPolicies_Response { + /** List of policies. */ + policies?: Policy[] | undefined; +} + +export interface MavenLibrary { + /** Gradle-style maven coordinates. For example: "org.jsoup:jsoup:1.7.2". */ + coordinates?: string | undefined; + /** + * Maven repo to install the Maven package from. If omitted, both Maven Central Repository + * and Spark Packages are searched. + */ + repo?: string | undefined; + /** + * 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[] | undefined; +} + +/** Describes a Cluster Policy entity. */ +export interface Policy { + /** Canonical unique identifier for the Cluster Policy. */ + policyId?: string | undefined; + /** + * Creator user name. + * The field won't be included in the response if the user has already been deleted. + */ + creatorUserName?: string | undefined; + /** Creation time. The timestamp (in millisecond) when this Cluster Policy was created. */ + createdAtTimestamp?: number | undefined; + /** + * If true, policy is a default policy created and managed by . + * Default policies cannot be deleted, and their policy families cannot be changed. + */ + isDefault?: boolean | undefined; + /** + * Cluster Policy name requested by the user. This has to be unique. Length must be between 1 and 100 + * characters. + */ + name?: string | undefined; + /** Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). */ + definition?: string | undefined; + /** Additional human-readable description of the cluster policy. */ + description?: string | undefined; + /** + * 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 | undefined; + /** + * Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). + * 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. + */ + policyFamilyDefinitionOverrides?: string | undefined; + /** Max number of clusters per user that can be active using this policy. If not present, there is no max limit. */ + maxClustersPerUser?: number | undefined; + /** 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[] | undefined; +} + +export interface PythonPyPiLibrary { + /** + * 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 | undefined; + /** + * The repository where the package can be found. If not specified, the default pip index is + * used. + */ + repo?: string | undefined; +} + +export interface RCranLibrary { + /** The name of the CRAN package to install. */ + package?: string | undefined; + /** The repository where the package can be found. If not specified, the default CRAN repo is used. */ + repo?: string | undefined; +} + +export const unmarshalCreatePolicySchema: z.ZodType = z + .object({ + name: z.string().optional(), + definition: z.string().optional(), + description: z.string().optional(), + policy_family_id: z.string().optional(), + policy_family_definition_overrides: z.string().optional(), + max_clusters_per_user: z.number().optional(), + libraries: z.array(z.lazy(() => unmarshalLibrarySchema)).optional(), + }) + .transform(d => ({ + name: d.name, + definition: d.definition, + description: d.description, + policyFamilyId: d.policy_family_id, + policyFamilyDefinitionOverrides: d.policy_family_definition_overrides, + maxClustersPerUser: d.max_clusters_per_user, + libraries: d.libraries, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreatePolicy_ResponseSchema: z.ZodType = z + .object({ + policy_id: z.string().optional(), + }) + .transform(d => ({ + policyId: d.policy_id, + })); + +export const unmarshalDeletePolicySchema: z.ZodType = z + .object({ + policy_id: z.string().optional(), + }) + .transform(d => ({ + policyId: d.policy_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeletePolicy_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalEditPolicySchema: z.ZodType = z + .object({ + policy_id: z.string().optional(), + name: z.string().optional(), + definition: z.string().optional(), + description: z.string().optional(), + policy_family_id: z.string().optional(), + policy_family_definition_overrides: z.string().optional(), + max_clusters_per_user: z.number().optional(), + libraries: z.array(z.lazy(() => unmarshalLibrarySchema)).optional(), + }) + .transform(d => ({ + policyId: d.policy_id, + name: d.name, + definition: d.definition, + description: d.description, + policyFamilyId: d.policy_family_id, + policyFamilyDefinitionOverrides: d.policy_family_definition_overrides, + maxClustersPerUser: d.max_clusters_per_user, + libraries: d.libraries, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalEditPolicy_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalGetPolicySchema: z.ZodType = z + .object({ + policy_id: z.string().optional(), + }) + .transform(d => ({ + policyId: d.policy_id, + })); + +export const unmarshalLibrarySchema: z.ZodType = z + .object({ + jar: z.string().optional(), + egg: z.string().optional(), + pypi: z.lazy(() => unmarshalPythonPyPiLibrarySchema).optional(), + maven: z.lazy(() => unmarshalMavenLibrarySchema).optional(), + cran: z.lazy(() => unmarshalRCranLibrarySchema).optional(), + whl: z.string().optional(), + requirements: z.string().optional(), + }) + .transform(d => ({ + jar: d.jar, + egg: d.egg, + pypi: d.pypi, + maven: d.maven, + cran: d.cran, + whl: d.whl, + requirements: d.requirements, + })); + +export const unmarshalListPoliciesSchema: z.ZodType = z + .object({ + sort_order: z.enum(ListOrder).optional(), + sort_column: z.enum(PolicySortColumn).optional(), + }) + .transform(d => ({ + sortOrder: d.sort_order, + sortColumn: d.sort_column, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListPolicies_ResponseSchema: z.ZodType = z + .object({ + policies: z.array(z.lazy(() => unmarshalPolicySchema)).optional(), + }) + .transform(d => ({ + policies: d.policies, + })); + +export const unmarshalMavenLibrarySchema: z.ZodType = z + .object({ + coordinates: z.string().optional(), + repo: z.string().optional(), + exclusions: z.array(z.string()).optional(), + }) + .transform(d => ({ + coordinates: d.coordinates, + repo: d.repo, + exclusions: d.exclusions, + })); + +export const unmarshalPolicySchema: z.ZodType = z + .object({ + policy_id: z.string().optional(), + creator_user_name: z.string().optional(), + created_at_timestamp: z.number().optional(), + is_default: z.boolean().optional(), + name: z.string().optional(), + definition: z.string().optional(), + description: z.string().optional(), + policy_family_id: z.string().optional(), + policy_family_definition_overrides: z.string().optional(), + max_clusters_per_user: z.number().optional(), + libraries: z.array(z.lazy(() => unmarshalLibrarySchema)).optional(), + }) + .transform(d => ({ + policyId: d.policy_id, + creatorUserName: d.creator_user_name, + createdAtTimestamp: d.created_at_timestamp, + isDefault: d.is_default, + name: d.name, + definition: d.definition, + description: d.description, + policyFamilyId: d.policy_family_id, + policyFamilyDefinitionOverrides: d.policy_family_definition_overrides, + maxClustersPerUser: d.max_clusters_per_user, + libraries: d.libraries, + })); + +export const unmarshalPythonPyPiLibrarySchema: z.ZodType = z + .object({ + package: z.string().optional(), + repo: z.string().optional(), + }) + .transform(d => ({ + package: d.package, + repo: d.repo, + })); + +export const unmarshalRCranLibrarySchema: z.ZodType = z + .object({ + package: z.string().optional(), + repo: z.string().optional(), + }) + .transform(d => ({ + package: d.package, + repo: d.repo, + })); + +export const marshalCreatePolicySchema: z.ZodType = z + .object({ + name: z.string().optional(), + definition: z.string().optional(), + description: z.string().optional(), + policyFamilyId: z.string().optional(), + policyFamilyDefinitionOverrides: z.string().optional(), + maxClustersPerUser: z.number().optional(), + libraries: z.array(z.lazy(() => marshalLibrarySchema)).optional(), + }) + .transform(d => ({ + name: d.name, + definition: d.definition, + description: d.description, + policy_family_id: d.policyFamilyId, + policy_family_definition_overrides: d.policyFamilyDefinitionOverrides, + max_clusters_per_user: d.maxClustersPerUser, + libraries: d.libraries, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreatePolicy_ResponseSchema: z.ZodType = z + .object({ + policyId: z.string().optional(), + }) + .transform(d => ({ + policy_id: d.policyId, + })); + +export const marshalDeletePolicySchema: z.ZodType = z + .object({ + policyId: z.string().optional(), + }) + .transform(d => ({ + policy_id: d.policyId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeletePolicy_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalEditPolicySchema: z.ZodType = z + .object({ + policyId: z.string().optional(), + name: z.string().optional(), + definition: z.string().optional(), + description: z.string().optional(), + policyFamilyId: z.string().optional(), + policyFamilyDefinitionOverrides: z.string().optional(), + maxClustersPerUser: z.number().optional(), + libraries: z.array(z.lazy(() => marshalLibrarySchema)).optional(), + }) + .transform(d => ({ + policy_id: d.policyId, + name: d.name, + definition: d.definition, + description: d.description, + policy_family_id: d.policyFamilyId, + policy_family_definition_overrides: d.policyFamilyDefinitionOverrides, + max_clusters_per_user: d.maxClustersPerUser, + libraries: d.libraries, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalEditPolicy_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalGetPolicySchema: z.ZodType = z + .object({ + policyId: z.string().optional(), + }) + .transform(d => ({ + policy_id: d.policyId, + })); + +export const marshalLibrarySchema: z.ZodType = z + .object({ + jar: z.string().optional(), + egg: z.string().optional(), + pypi: z.lazy(() => marshalPythonPyPiLibrarySchema).optional(), + maven: z.lazy(() => marshalMavenLibrarySchema).optional(), + cran: z.lazy(() => marshalRCranLibrarySchema).optional(), + whl: z.string().optional(), + requirements: z.string().optional(), + }) + .transform(d => ({ + jar: d.jar, + egg: d.egg, + pypi: d.pypi, + maven: d.maven, + cran: d.cran, + whl: d.whl, + requirements: d.requirements, + })); + +export const marshalListPoliciesSchema: z.ZodType = z + .object({ + sortOrder: z.enum(ListOrder).optional(), + sortColumn: z.enum(PolicySortColumn).optional(), + }) + .transform(d => ({ + sort_order: d.sortOrder, + sort_column: d.sortColumn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListPolicies_ResponseSchema: z.ZodType = z + .object({ + policies: z.array(z.lazy(() => marshalPolicySchema)).optional(), + }) + .transform(d => ({ + policies: d.policies, + })); + +export const marshalMavenLibrarySchema: z.ZodType = z + .object({ + coordinates: z.string().optional(), + repo: z.string().optional(), + exclusions: z.array(z.string()).optional(), + }) + .transform(d => ({ + coordinates: d.coordinates, + repo: d.repo, + exclusions: d.exclusions, + })); + +export const marshalPolicySchema: z.ZodType = z + .object({ + policyId: z.string().optional(), + creatorUserName: z.string().optional(), + createdAtTimestamp: z.number().optional(), + isDefault: z.boolean().optional(), + name: z.string().optional(), + definition: z.string().optional(), + description: z.string().optional(), + policyFamilyId: z.string().optional(), + policyFamilyDefinitionOverrides: z.string().optional(), + maxClustersPerUser: z.number().optional(), + libraries: z.array(z.lazy(() => marshalLibrarySchema)).optional(), + }) + .transform(d => ({ + policy_id: d.policyId, + creator_user_name: d.creatorUserName, + created_at_timestamp: d.createdAtTimestamp, + is_default: d.isDefault, + name: d.name, + definition: d.definition, + description: d.description, + policy_family_id: d.policyFamilyId, + policy_family_definition_overrides: d.policyFamilyDefinitionOverrides, + max_clusters_per_user: d.maxClustersPerUser, + libraries: d.libraries, + })); + +export const marshalPythonPyPiLibrarySchema: z.ZodType = z + .object({ + package: z.string().optional(), + repo: z.string().optional(), + }) + .transform(d => ({ + package: d.package, + repo: d.repo, + })); + +export const marshalRCranLibrarySchema: z.ZodType = z + .object({ + package: z.string().optional(), + repo: z.string().optional(), + }) + .transform(d => ({ + package: d.package, + repo: d.repo, + })); diff --git a/packages/clusterpolicies/src/v2/utils.ts b/packages/clusterpolicies/src/v2/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/clusterpolicies/src/v2/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/clusterpolicies/tsconfig.json b/packages/clusterpolicies/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/clusterpolicies/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/connections/package.json b/packages/connections/package.json index dc3d1340..55d41ca3 100644 --- a/packages/connections/package.json +++ b/packages/connections/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/connections/src/v1/client.ts b/packages/connections/src/v1/client.ts index f328aafd..a750f946 100644 --- a/packages/connections/src/v1/client.ts +++ b/packages/connections/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { ConnectionInfo, CreateConnection, @@ -47,25 +42,17 @@ export class Client { /** * Creates a new connection - * + * * Creates a new connection to an external data source. It allows users to specify connection details and * configurations for interaction with the external server. */ - async createConnection( - signal: AbortSignal | undefined, - req: CreateConnection, - options?: Options - ): Promise { + async createConnection(signal: AbortSignal | undefined, req: CreateConnection, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/connections`; const body = marshalRequest(req, marshalCreateConnectionSchema); let resp: ConnectionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalConnectionInfoSchema); }; await execute(signal, call, options); @@ -76,20 +63,12 @@ export class Client { } /** Deletes the connection that matches the supplied name. */ - async deleteConnection( - signal: AbortSignal | undefined, - req: DeleteConnection, - options?: Options - ): Promise { + async deleteConnection(signal: AbortSignal | undefined, req: DeleteConnection, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`; let resp: DeleteConnection_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteConnection_ResponseSchema); }; await execute(signal, call, options); @@ -100,20 +79,12 @@ export class Client { } /** Gets a connection from it's name. */ - async getConnection( - signal: AbortSignal | undefined, - req: GetConnection, - options?: Options - ): Promise { + async getConnection(signal: AbortSignal | undefined, req: GetConnection, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`; let resp: ConnectionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalConnectionInfoSchema); }; await execute(signal, call, options); @@ -125,17 +96,13 @@ export class Client { /** * List all connections. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listConnections( - signal: AbortSignal | undefined, - req: ListConnections, - options?: Options - ): Promise { + async listConnections(signal: AbortSignal | undefined, req: ListConnections, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/connections`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -144,16 +111,15 @@ export class Client { if (req.pageToken !== undefined) { params.append('page_token', req.pageToken); } + if (req.parent !== undefined) { + params.append('parent', req.parent); + } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: ListConnections_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListConnections_ResponseSchema); }; await execute(signal, call, options); @@ -163,11 +129,8 @@ export class Client { return resp; } - async *listConnectionsIter( - signal: AbortSignal | undefined, - req: ListConnections, - options?: Options - ): AsyncGenerator { + + async *listConnectionsIter(signal: AbortSignal | undefined, req: ListConnections, options?: Options): AsyncGenerator { const pageReq: ListConnections = {...req}; for (;;) { const resp = await this.listConnections(signal, pageReq, options); @@ -181,22 +144,15 @@ export class Client { } } + /** Updates the connection that matches the supplied name. */ - async updateConnection( - signal: AbortSignal | undefined, - req: UpdateConnection, - options?: Options - ): Promise { + async updateConnection(signal: AbortSignal | undefined, req: UpdateConnection, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateConnectionSchema); let resp: ConnectionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalConnectionInfoSchema); }; await execute(signal, call, options); diff --git a/packages/connections/src/v1/index.ts b/packages/connections/src/v1/index.ts index aa5b9a60..97b66592 100644 --- a/packages/connections/src/v1/index.ts +++ b/packages/connections/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/connections/src/v1/model.ts b/packages/connections/src/v1/model.ts index 6f34aa32..a0fbebf8 100644 --- a/packages/connections/src/v1/model.ts +++ b/packages/connections/src/v1/model.ts @@ -2,7 +2,7 @@ import {z} from 'zod'; -/** Next Id: 75 */ +/** Next Id: 76 */ export enum ConnectionType { UNKNOWN_CONNECTION_TYPE = 'UNKNOWN_CONNECTION_TYPE', MYSQL = 'MYSQL', @@ -26,6 +26,7 @@ export enum ConnectionType { HTTP = 'HTTP', POWER_BI = 'POWER_BI', BIGLAKE = 'BIGLAKE', + GOOGLE_CLOUD_LAKEHOUSE = 'GOOGLE_CLOUD_LAKEHOUSE', } /** Next Id: 18 */ @@ -147,6 +148,11 @@ export interface ConnectionInfo_SecretsEntry { } export interface CreateConnection { + /** + * Parent schema for schema-level connections, in format "schemas/{catalog}.{schema}". + * Absent for metastore-level (L1) connections. + */ + parent?: string | undefined; /** Name of the connection. */ name?: string | undefined; /** The type of connection. */ @@ -237,6 +243,8 @@ export interface ListConnections { maxResults?: number | undefined; /** Opaque pagination token to go to next page based on previous query. */ pageToken?: string | undefined; + /** Optional. Parent schema filter for listing schema-level connections, in format "schemas/{catalog}.{schema}". */ + parent?: string | undefined; } // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. @@ -329,9 +337,7 @@ export const unmarshalConnectionInfoSchema: z.ZodType = z owner: z.string().optional(), read_only: z.boolean().optional(), comment: z.string().optional(), - environment_settings: z - .lazy(() => unmarshalEnvironmentSettingsSchema) - .optional(), + environment_settings: z.lazy(() => unmarshalEnvironmentSettingsSchema).optional(), full_name: z.string().optional(), url: z.string().optional(), credential_type: z.enum(CredentialType).optional(), @@ -371,51 +377,47 @@ export const unmarshalConnectionInfoSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalConnectionInfo_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalConnectionInfo_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalConnectionInfo_SecretsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalConnectionInfo_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalConnectionInfo_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalConnectionInfo_SecretsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalCreateConnectionSchema: z.ZodType = z .object({ + parent: z.string().optional(), name: z.string().optional(), connection_type: z.enum(ConnectionType).optional(), owner: z.string().optional(), read_only: z.boolean().optional(), comment: z.string().optional(), - environment_settings: z - .lazy(() => unmarshalEnvironmentSettingsSchema) - .optional(), + environment_settings: z.lazy(() => unmarshalEnvironmentSettingsSchema).optional(), full_name: z.string().optional(), url: z.string().optional(), credential_type: z.enum(CredentialType).optional(), @@ -432,6 +434,7 @@ export const unmarshalCreateConnectionSchema: z.ZodType = z properties: z.record(z.string(), z.string()).optional(), }) .transform(d => ({ + parent: d.parent, name: d.name, connectionType: d.connection_type, owner: d.owner, @@ -455,40 +458,37 @@ export const unmarshalCreateConnectionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateConnection_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateConnection_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateConnection_SecretsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCreateConnection_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateConnection_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateConnection_SecretsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalDeleteConnectionSchema: z.ZodType = z .object({ @@ -499,19 +499,19 @@ export const unmarshalDeleteConnectionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteConnection_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteConnection_ResponseSchema: z.ZodType = z + .object({ + }); -export const unmarshalEnvironmentSettingsSchema: z.ZodType = - z - .object({ - java_dependencies: z.array(z.string()).optional(), - environment_version: z.string().optional(), - }) - .transform(d => ({ - javaDependencies: d.java_dependencies, - environmentVersion: d.environment_version, - })); +export const unmarshalEnvironmentSettingsSchema: z.ZodType = z + .object({ + java_dependencies: z.array(z.string()).optional(), + environment_version: z.string().optional(), + }) + .transform(d => ({ + javaDependencies: d.java_dependencies, + environmentVersion: d.environment_version, + })); export const unmarshalGetConnectionSchema: z.ZodType = z .object({ @@ -525,25 +525,24 @@ export const unmarshalListConnectionsSchema: z.ZodType = z .object({ max_results: z.number().optional(), page_token: z.string().optional(), + parent: z.string().optional(), }) .transform(d => ({ maxResults: d.max_results, pageToken: d.page_token, + parent: d.parent, })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListConnections_ResponseSchema: z.ZodType = - z - .object({ - connections: z - .array(z.lazy(() => unmarshalConnectionInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - connections: d.connections, - nextPageToken: d.next_page_token, - })); +export const unmarshalListConnections_ResponseSchema: z.ZodType = z + .object({ + connections: z.array(z.lazy(() => unmarshalConnectionInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + connections: d.connections, + nextPageToken: d.next_page_token, + })); export const unmarshalProvisioningInfoSchema: z.ZodType = z .object({ @@ -562,9 +561,7 @@ export const unmarshalUpdateConnectionSchema: z.ZodType = z owner: z.string().optional(), read_only: z.boolean().optional(), comment: z.string().optional(), - environment_settings: z - .lazy(() => unmarshalEnvironmentSettingsSchema) - .optional(), + environment_settings: z.lazy(() => unmarshalEnvironmentSettingsSchema).optional(), full_name: z.string().optional(), url: z.string().optional(), credential_type: z.enum(CredentialType).optional(), @@ -606,40 +603,37 @@ export const unmarshalUpdateConnectionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateConnection_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateConnection_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateConnection_SecretsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalUpdateConnection_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalUpdateConnection_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalUpdateConnection_SecretsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const marshalConnectionInfoSchema: z.ZodType = z .object({ @@ -648,9 +642,7 @@ export const marshalConnectionInfoSchema: z.ZodType = z owner: z.string().optional(), readOnly: z.boolean().optional(), comment: z.string().optional(), - environmentSettings: z - .lazy(() => marshalEnvironmentSettingsSchema) - .optional(), + environmentSettings: z.lazy(() => marshalEnvironmentSettingsSchema).optional(), fullName: z.string().optional(), url: z.string().optional(), credentialType: z.enum(CredentialType).optional(), @@ -724,14 +716,13 @@ export const marshalConnectionInfo_SecretsEntrySchema: z.ZodType = z export const marshalCreateConnectionSchema: z.ZodType = z .object({ + parent: z.string().optional(), name: z.string().optional(), connectionType: z.enum(ConnectionType).optional(), owner: z.string().optional(), readOnly: z.boolean().optional(), comment: z.string().optional(), - environmentSettings: z - .lazy(() => marshalEnvironmentSettingsSchema) - .optional(), + environmentSettings: z.lazy(() => marshalEnvironmentSettingsSchema).optional(), fullName: z.string().optional(), url: z.string().optional(), credentialType: z.enum(CredentialType).optional(), @@ -748,6 +739,7 @@ export const marshalCreateConnectionSchema: z.ZodType = z properties: z.record(z.string(), z.string()).optional(), }) .transform(d => ({ + parent: d.parent, name: d.name, connection_type: d.connectionType, owner: d.owner, @@ -812,7 +804,9 @@ export const marshalDeleteConnectionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteConnection_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteConnection_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalEnvironmentSettingsSchema: z.ZodType = z .object({ @@ -836,10 +830,12 @@ export const marshalListConnectionsSchema: z.ZodType = z .object({ maxResults: z.number().optional(), pageToken: z.string().optional(), + parent: z.string().optional(), }) .transform(d => ({ max_results: d.maxResults, page_token: d.pageToken, + parent: d.parent, })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. @@ -870,9 +866,7 @@ export const marshalUpdateConnectionSchema: z.ZodType = z owner: z.string().optional(), readOnly: z.boolean().optional(), comment: z.string().optional(), - environmentSettings: z - .lazy(() => marshalEnvironmentSettingsSchema) - .optional(), + environmentSettings: z.lazy(() => marshalEnvironmentSettingsSchema).optional(), fullName: z.string().optional(), url: z.string().optional(), credentialType: z.enum(CredentialType).optional(), diff --git a/packages/connections/src/v1/utils.ts b/packages/connections/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/connections/src/v1/utils.ts +++ b/packages/connections/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/connections/tsconfig.json b/packages/connections/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/connections/tsconfig.json +++ b/packages/connections/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/credentials/package.json b/packages/credentials/package.json index ba024c26..1291fa56 100644 --- a/packages/credentials/package.json +++ b/packages/credentials/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/credentials/src/v1/client.ts b/packages/credentials/src/v1/client.ts index f60ed838..6f4b3c3e 100644 --- a/packages/credentials/src/v1/client.ts +++ b/packages/credentials/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateCredential, CreateStorageCredential, @@ -80,25 +75,17 @@ export class Client { /** * Creates a new credential. The type of credential to be created is determined by the **purpose** field, * which should be either **SERVICE** or **STORAGE**. - * + * * The caller must be a metastore admin or have the metastore privilege **CREATE_STORAGE_CREDENTIAL** for storage * credentials, or **CREATE_SERVICE_CREDENTIAL** for service credentials. */ - async createCredential( - signal: AbortSignal | undefined, - req: CreateCredential, - options?: Options - ): Promise { + async createCredential(signal: AbortSignal | undefined, req: CreateCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/credentials`; const body = marshalRequest(req, marshalCreateCredentialSchema); let resp: StorageCredentialInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema); }; await execute(signal, call, options); @@ -110,24 +97,16 @@ export class Client { /** * Creates a new storage credential. - * + * * The caller must be a metastore admin or have the **CREATE_STORAGE_CREDENTIAL** privilege on the metastore. */ - async createStorageCredential( - signal: AbortSignal | undefined, - req: CreateStorageCredential, - options?: Options - ): Promise { + async createStorageCredential(signal: AbortSignal | undefined, req: CreateStorageCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/storage-credentials`; const body = marshalRequest(req, marshalCreateStorageCredentialSchema); let resp: StorageCredentialInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema); }; await execute(signal, call, options); @@ -138,11 +117,7 @@ export class Client { } /** Deletes a service or storage credential from the metastore. The caller must be an owner of the credential. */ - async deleteCredential( - signal: AbortSignal | undefined, - req: DeleteCredential, - options?: Options - ): Promise { + async deleteCredential(signal: AbortSignal | undefined, req: DeleteCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/credentials/${req.nameArg ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -153,11 +128,7 @@ export class Client { let resp: DeleteCredential_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteCredential_ResponseSchema); }; await execute(signal, call, options); @@ -168,11 +139,7 @@ export class Client { } /** Deletes a storage credential from the metastore. The caller must be an owner of the storage credential. */ - async deleteStorageCredential( - signal: AbortSignal | undefined, - req: DeleteStorageCredential, - options?: Options - ): Promise { + async deleteStorageCredential(signal: AbortSignal | undefined, req: DeleteStorageCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/storage-credentials/${req.nameArg ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -183,15 +150,8 @@ export class Client { let resp: DeleteStorageCredential_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteStorageCredential_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteStorageCredential_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -210,28 +170,14 @@ export class Client { * For requests on existing external tables, the caller must also have the **EXTERNAL_USE_SCHEMA** privilege on the parent schema; * this privilege can only be granted by catalog owners. */ - async generateTemporaryPathCredential( - signal: AbortSignal | undefined, - req: GenerateTemporaryPathCredential, - options?: Options - ): Promise { + async generateTemporaryPathCredential(signal: AbortSignal | undefined, req: GenerateTemporaryPathCredential, options?: Options): Promise { const url = `${this.host}/api/2.0/unity-catalog/temporary-path-credentials`; - const body = marshalRequest( - req, - marshalGenerateTemporaryPathCredentialSchema - ); + const body = marshalRequest(req, marshalGenerateTemporaryPathCredentialSchema); let resp: GenerateTemporaryPathCredential_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenerateTemporaryPathCredential_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenerateTemporaryPathCredential_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -244,24 +190,13 @@ export class Client { * Returns a set of temporary credentials generated using the specified service credential. * The caller must be a metastore admin or have the metastore privilege **ACCESS** on the service credential. */ - async generateTemporaryServiceCredential( - signal: AbortSignal | undefined, - req: GenerateTemporaryServiceCredential, - options?: Options - ): Promise { + async generateTemporaryServiceCredential(signal: AbortSignal | undefined, req: GenerateTemporaryServiceCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/temporary-service-credentials`; - const body = marshalRequest( - req, - marshalGenerateTemporaryServiceCredentialSchema - ); + const body = marshalRequest(req, marshalGenerateTemporaryServiceCredentialSchema); let resp: TemporaryCredentials | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTemporaryCredentialsSchema); }; await execute(signal, call, options); @@ -277,28 +212,14 @@ export class Client { * The caller must have the **EXTERNAL_USE_SCHEMA** privilege on the parent schema and this privilege can only be granted * by catalog owners. */ - async generateTemporaryTableCredential( - signal: AbortSignal | undefined, - req: GenerateTemporaryTableCredential, - options?: Options - ): Promise { + async generateTemporaryTableCredential(signal: AbortSignal | undefined, req: GenerateTemporaryTableCredential, options?: Options): Promise { const url = `${this.host}/api/2.0/unity-catalog/temporary-table-credentials`; - const body = marshalRequest( - req, - marshalGenerateTemporaryTableCredentialSchema - ); + const body = marshalRequest(req, marshalGenerateTemporaryTableCredentialSchema); let resp: GenerateTemporaryTableCredential_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenerateTemporaryTableCredential_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenerateTemporaryTableCredential_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -311,20 +232,12 @@ export class Client { * Gets a service or storage credential from the metastore. * The caller must be a metastore admin, the owner of the credential, or have any permission on the credential. */ - async getCredential( - signal: AbortSignal | undefined, - req: GetCredential, - options?: Options - ): Promise { + async getCredential(signal: AbortSignal | undefined, req: GetCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/credentials/${req.nameArg ?? ''}`; let resp: StorageCredentialInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema); }; await execute(signal, call, options); @@ -338,20 +251,12 @@ export class Client { * Gets a storage credential from the metastore. * The caller must be a metastore admin, the owner of the storage credential, or have some permission on the storage credential. */ - async getStorageCredential( - signal: AbortSignal | undefined, - req: GetStorageCredential, - options?: Options - ): Promise { + async getStorageCredential(signal: AbortSignal | undefined, req: GetStorageCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/storage-credentials/${req.nameArg ?? ''}`; let resp: StorageCredentialInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema); }; await execute(signal, call, options); @@ -363,19 +268,15 @@ export class Client { /** * Gets an array of credentials (as __CredentialInfo__ objects). - * + * * The array is limited to only 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. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listCredentials( - signal: AbortSignal | undefined, - req: ListCredentials, - options?: Options - ): Promise { + async listCredentials(signal: AbortSignal | undefined, req: ListCredentials, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/credentials`; const params = new URLSearchParams(); if (req.includeUnbound !== undefined) { @@ -392,11 +293,7 @@ export class Client { let resp: ListCredentials_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListCredentials_ResponseSchema); }; await execute(signal, call, options); @@ -406,11 +303,8 @@ export class Client { return resp; } - async *listCredentialsIter( - signal: AbortSignal | undefined, - req: ListCredentials, - options?: Options - ): AsyncGenerator { + + async *listCredentialsIter(signal: AbortSignal | undefined, req: ListCredentials, options?: Options): AsyncGenerator { const pageReq: ListCredentials = {...req}; for (;;) { const resp = await this.listCredentials(signal, pageReq, options); @@ -424,22 +318,19 @@ export class Client { } } + /** * Gets an array of storage credentials (as __StorageCredentialInfo__ objects). * The array is limited to only those storage credentials the caller has permission to access. * If the caller is a metastore admin, retrieval of credentials is unrestricted. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listStorageCredentials( - signal: AbortSignal | undefined, - req: ListStorageCredentials, - options?: Options - ): Promise { + async listStorageCredentials(signal: AbortSignal | undefined, req: ListStorageCredentials, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/storage-credentials`; const params = new URLSearchParams(); if (req.includeUnbound !== undefined) { @@ -456,15 +347,8 @@ export class Client { let resp: ListStorageCredentials_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListStorageCredentials_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListStorageCredentials_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -473,11 +357,8 @@ export class Client { return resp; } - async *listStorageCredentialsIter( - signal: AbortSignal | undefined, - req: ListStorageCredentials, - options?: Options - ): AsyncGenerator { + + async *listStorageCredentialsIter(signal: AbortSignal | undefined, req: ListStorageCredentials, options?: Options): AsyncGenerator { const pageReq: ListStorageCredentials = {...req}; for (;;) { const resp = await this.listStorageCredentials(signal, pageReq, options); @@ -491,27 +372,20 @@ export class Client { } } + /** * Updates a service or storage credential on the metastore. - * + * * The caller must be the owner of the credential or a metastore admin or have the `MANAGE` permission. If the caller is * a metastore admin, only the __owner__ field can be changed. */ - async updateCredential( - signal: AbortSignal | undefined, - req: UpdateCredential, - options?: Options - ): Promise { + async updateCredential(signal: AbortSignal | undefined, req: UpdateCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/credentials/${req.nameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateCredentialSchema); let resp: StorageCredentialInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema); }; await execute(signal, call, options); @@ -523,25 +397,17 @@ export class Client { /** * Updates a storage credential on the metastore. - * + * * The caller must be the owner of the storage credential or a metastore admin. * If the caller is a metastore admin, only the **owner** field can be changed. */ - async updateStorageCredential( - signal: AbortSignal | undefined, - req: UpdateStorageCredential, - options?: Options - ): Promise { + async updateStorageCredential(signal: AbortSignal | undefined, req: UpdateStorageCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/storage-credentials/${req.nameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateStorageCredentialSchema); let resp: StorageCredentialInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStorageCredentialInfoSchema); }; await execute(signal, call, options); @@ -553,37 +419,26 @@ export class Client { /** * Validates a credential. - * + * * For service credentials (purpose is **SERVICE**), either the __credential_name__ or the cloud-specific credential * must be provided. - * + * * For storage credentials (purpose is **STORAGE**), at least one of __external_location_name__ and __url__ need to be * provided. If only one of them is provided, it will be used for validation. And if both are provided, the __url__ * will be used for validation, and __external_location_name__ will be ignored when checking overlapping urls. Either * the __credential_name__ or the cloud-specific credential must be provided. - * + * * The caller must be a metastore admin or the credential owner or have the required permission on the metastore and * the credential (e.g., **CREATE_EXTERNAL_LOCATION** when purpose is **STORAGE**). */ - async validateCredential( - signal: AbortSignal | undefined, - req: ValidateCredential, - options?: Options - ): Promise { + async validateCredential(signal: AbortSignal | undefined, req: ValidateCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/validate-credentials`; const body = marshalRequest(req, marshalValidateCredentialSchema); let resp: ValidateCredential_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalValidateCredential_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalValidateCredential_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -597,31 +452,20 @@ export class Client { * At least one of __external_location_name__ and __url__ need to be provided. If only one of them is * provided, it will be used for validation. And if both are provided, the __url__ will be used for * validation, and __external_location_name__ will be ignored when checking overlapping urls. - * + * * Either the __storage_credential_name__ or the cloud-specific credential must be provided. - * + * * The caller must be a metastore admin or the storage credential owner or * have the **CREATE_EXTERNAL_LOCATION** privilege on the metastore and the storage credential. */ - async validateStorageCredential( - signal: AbortSignal | undefined, - req: ValidateStorageCredential, - options?: Options - ): Promise { + async validateStorageCredential(signal: AbortSignal | undefined, req: ValidateStorageCredential, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/validate-storage-credentials`; const body = marshalRequest(req, marshalValidateStorageCredentialSchema); let resp: ValidateStorageCredential_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalValidateStorageCredential_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalValidateStorageCredential_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { diff --git a/packages/credentials/src/v1/index.ts b/packages/credentials/src/v1/index.ts index e8434f05..45fcee48 100644 --- a/packages/credentials/src/v1/index.ts +++ b/packages/credentials/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/credentials/src/v1/model.ts b/packages/credentials/src/v1/model.ts index 6e594459..7d66e85d 100644 --- a/packages/credentials/src/v1/model.ts +++ b/packages/credentials/src/v1/model.ts @@ -470,7 +470,7 @@ export interface GetStorageCredential { * 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. */ export interface ListCredentials { @@ -871,83 +871,68 @@ export const unmarshalAwsIamRoleSchema: z.ZodType = z externalId: d.external_id, })); -export const unmarshalAzureActiveDirectoryTokenSchema: z.ZodType = - z - .object({ - aad_token: z.string().optional(), - }) - .transform(d => ({ - aadToken: d.aad_token, - })); - -export const unmarshalAzureManagedIdentitySchema: z.ZodType = - z - .object({ - access_connector_id: z.string().optional(), - managed_identity_id: z.string().optional(), - credential_id: z.string().optional(), - }) - .transform(d => ({ - accessConnectorId: d.access_connector_id, - managedIdentityId: d.managed_identity_id, - credentialId: d.credential_id, - })); - -export const unmarshalAzureServicePrincipalSchema: z.ZodType = - z - .object({ - directory_id: z.string().optional(), - application_id: z.string().optional(), - client_secret: z.string().optional(), - }) - .transform(d => ({ - directoryId: d.directory_id, - applicationId: d.application_id, - clientSecret: d.client_secret, - })); - -export const unmarshalAzureUserDelegationSasSchema: z.ZodType = - z - .object({ - sas_token: z.string().optional(), - }) - .transform(d => ({ - sasToken: d.sas_token, - })); - -export const unmarshalCloudflareApiTokenSchema: z.ZodType = - z - .object({ - access_key_id: z.string().optional(), - secret_access_key: z.string().optional(), - account_id: z.string().optional(), - }) - .transform(d => ({ - accessKeyId: d.access_key_id, - secretAccessKey: d.secret_access_key, - accountId: d.account_id, - })); +export const unmarshalAzureActiveDirectoryTokenSchema: z.ZodType = z + .object({ + aad_token: z.string().optional(), + }) + .transform(d => ({ + aadToken: d.aad_token, + })); + +export const unmarshalAzureManagedIdentitySchema: z.ZodType = z + .object({ + access_connector_id: z.string().optional(), + managed_identity_id: z.string().optional(), + credential_id: z.string().optional(), + }) + .transform(d => ({ + accessConnectorId: d.access_connector_id, + managedIdentityId: d.managed_identity_id, + credentialId: d.credential_id, + })); + +export const unmarshalAzureServicePrincipalSchema: z.ZodType = z + .object({ + directory_id: z.string().optional(), + application_id: z.string().optional(), + client_secret: z.string().optional(), + }) + .transform(d => ({ + directoryId: d.directory_id, + applicationId: d.application_id, + clientSecret: d.client_secret, + })); + +export const unmarshalAzureUserDelegationSasSchema: z.ZodType = z + .object({ + sas_token: z.string().optional(), + }) + .transform(d => ({ + sasToken: d.sas_token, + })); + +export const unmarshalCloudflareApiTokenSchema: z.ZodType = z + .object({ + access_key_id: z.string().optional(), + secret_access_key: z.string().optional(), + account_id: z.string().optional(), + }) + .transform(d => ({ + accessKeyId: d.access_key_id, + secretAccessKey: d.secret_access_key, + accountId: d.account_id, + })); export const unmarshalCreateCredentialSchema: z.ZodType = z .object({ skip_validation: z.boolean().optional(), name: z.string().optional(), aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - gcp_service_account_key: z - .lazy(() => unmarshalGcpServiceAccountKeySchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + gcp_service_account_key: z.lazy(() => unmarshalGcpServiceAccountKeySchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), read_only: z.boolean().optional(), owner: z.string().optional(), @@ -984,82 +969,61 @@ export const unmarshalCreateCredentialSchema: z.ZodType = z isolationMode: d.isolation_mode, })); -export const unmarshalCreateStorageCredentialSchema: z.ZodType = - z - .object({ - skip_validation: z.boolean().optional(), - name: z.string().optional(), - aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - gcp_service_account_key: z - .lazy(() => unmarshalGcpServiceAccountKeySchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), - comment: z.string().optional(), - read_only: z.boolean().optional(), - owner: z.string().optional(), - id: z.string().optional(), - metastore_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - used_for_managed_storage: z.boolean().optional(), - full_name: z.string().optional(), - isolation_mode: z.enum(IsolationMode).optional(), - }) - .transform(d => ({ - skipValidation: d.skip_validation, - name: d.name, - awsIamRole: d.aws_iam_role, - azureServicePrincipal: d.azure_service_principal, - gcpServiceAccountKey: d.gcp_service_account_key, - azureManagedIdentity: d.azure_managed_identity, - databricksGcpServiceAccount: d.databricks_gcp_service_account, - cloudflareApiToken: d.cloudflare_api_token, - comment: d.comment, - readOnly: d.read_only, - owner: d.owner, - id: d.id, - metastoreId: d.metastore_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - usedForManagedStorage: d.used_for_managed_storage, - fullName: d.full_name, - isolationMode: d.isolation_mode, - })); +export const unmarshalCreateStorageCredentialSchema: z.ZodType = z + .object({ + skip_validation: z.boolean().optional(), + name: z.string().optional(), + aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + gcp_service_account_key: z.lazy(() => unmarshalGcpServiceAccountKeySchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), + comment: z.string().optional(), + read_only: z.boolean().optional(), + owner: z.string().optional(), + id: z.string().optional(), + metastore_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + used_for_managed_storage: z.boolean().optional(), + full_name: z.string().optional(), + isolation_mode: z.enum(IsolationMode).optional(), + }) + .transform(d => ({ + skipValidation: d.skip_validation, + name: d.name, + awsIamRole: d.aws_iam_role, + azureServicePrincipal: d.azure_service_principal, + gcpServiceAccountKey: d.gcp_service_account_key, + azureManagedIdentity: d.azure_managed_identity, + databricksGcpServiceAccount: d.databricks_gcp_service_account, + cloudflareApiToken: d.cloudflare_api_token, + comment: d.comment, + readOnly: d.read_only, + owner: d.owner, + id: d.id, + metastoreId: d.metastore_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + usedForManagedStorage: d.used_for_managed_storage, + fullName: d.full_name, + isolationMode: d.isolation_mode, + })); export const unmarshalCredentialInfoSchema: z.ZodType = z .object({ name: z.string().optional(), aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - gcp_service_account_key: z - .lazy(() => unmarshalGcpServiceAccountKeySchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + gcp_service_account_key: z.lazy(() => unmarshalGcpServiceAccountKeySchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), read_only: z.boolean().optional(), owner: z.string().optional(), @@ -1095,18 +1059,17 @@ export const unmarshalCredentialInfoSchema: z.ZodType = z isolationMode: d.isolation_mode, })); -export const unmarshalDatabricksGcpServiceAccountSchema: z.ZodType = - z - .object({ - email: z.string().optional(), - private_key_id: z.string().optional(), - credential_id: z.string().optional(), - }) - .transform(d => ({ - email: d.email, - privateKeyId: d.private_key_id, - credentialId: d.credential_id, - })); +export const unmarshalDatabricksGcpServiceAccountSchema: z.ZodType = z + .object({ + email: z.string().optional(), + private_key_id: z.string().optional(), + credential_id: z.string().optional(), + }) + .transform(d => ({ + email: d.email, + privateKeyId: d.private_key_id, + credentialId: d.credential_id, + })); export const unmarshalDeleteCredentialSchema: z.ZodType = z .object({ @@ -1119,23 +1082,24 @@ export const unmarshalDeleteCredentialSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteCredential_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeleteStorageCredentialSchema: z.ZodType = - z - .object({ - name_arg: z.string().optional(), - force: z.boolean().optional(), - }) - .transform(d => ({ - nameArg: d.name_arg, - force: d.force, - })); +export const unmarshalDeleteCredential_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteStorageCredentialSchema: z.ZodType = z + .object({ + name_arg: z.string().optional(), + force: z.boolean().optional(), + }) + .transform(d => ({ + nameArg: d.name_arg, + force: d.force, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteStorageCredential_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteStorageCredential_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalGcpOauthTokenSchema: z.ZodType = z .object({ @@ -1145,151 +1109,115 @@ export const unmarshalGcpOauthTokenSchema: z.ZodType = z oauthToken: d.oauth_token, })); -export const unmarshalGcpServiceAccountKeySchema: z.ZodType = - z - .object({ - email: z.string().optional(), - private_key_id: z.string().optional(), - private_key: z.string().optional(), - }) - .transform(d => ({ - email: d.email, - privateKeyId: d.private_key_id, - privateKey: d.private_key, - })); - -export const unmarshalGenerateTemporaryPathCredentialSchema: z.ZodType = - z - .object({ - url: z.string().optional(), - operation: z.enum(PathOperation).optional(), - dry_run: z.boolean().optional(), - }) - .transform(d => ({ - url: d.url, - operation: d.operation, - dryRun: d.dry_run, - })); +export const unmarshalGcpServiceAccountKeySchema: z.ZodType = z + .object({ + email: z.string().optional(), + private_key_id: z.string().optional(), + private_key: z.string().optional(), + }) + .transform(d => ({ + email: d.email, + privateKeyId: d.private_key_id, + privateKey: d.private_key, + })); + +export const unmarshalGenerateTemporaryPathCredentialSchema: z.ZodType = z + .object({ + url: z.string().optional(), + operation: z.enum(PathOperation).optional(), + dry_run: z.boolean().optional(), + }) + .transform(d => ({ + url: d.url, + operation: d.operation, + dryRun: d.dry_run, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGenerateTemporaryPathCredential_ResponseSchema: z.ZodType = - z - .object({ - aws_temp_credentials: z - .lazy(() => unmarshalAwsCredentialsSchema) - .optional(), - azure_user_delegation_sas: z - .lazy(() => unmarshalAzureUserDelegationSasSchema) - .optional(), - gcp_oauth_token: z.lazy(() => unmarshalGcpOauthTokenSchema).optional(), - azure_aad: z - .lazy(() => unmarshalAzureActiveDirectoryTokenSchema) - .optional(), - r2_temp_credentials: z - .lazy(() => unmarshalR2CredentialsSchema) - .optional(), - uc_encrypted_token: z - .lazy(() => unmarshalUcEncryptedTokenSchema) - .optional(), - expiration_time: z.number().optional(), - url: z.string().optional(), - }) - .transform(d => ({ - awsTempCredentials: d.aws_temp_credentials, - azureUserDelegationSas: d.azure_user_delegation_sas, - gcpOauthToken: d.gcp_oauth_token, - azureAad: d.azure_aad, - r2TempCredentials: d.r2_temp_credentials, - ucEncryptedToken: d.uc_encrypted_token, - expirationTime: d.expiration_time, - url: d.url, - })); - -export const unmarshalGenerateTemporaryServiceCredentialSchema: z.ZodType = - z - .object({ - credential_name: z.string().optional(), - azure_options: z - .lazy( - () => unmarshalGenerateTemporaryServiceCredential_AzureOptionsSchema - ) - .optional(), - gcp_options: z - .lazy( - () => unmarshalGenerateTemporaryServiceCredential_GcpOptionsSchema - ) - .optional(), - }) - .transform(d => ({ - credentialName: d.credential_name, - azureOptions: d.azure_options, - gcpOptions: d.gcp_options, - })); +export const unmarshalGenerateTemporaryPathCredential_ResponseSchema: z.ZodType = z + .object({ + aws_temp_credentials: z.lazy(() => unmarshalAwsCredentialsSchema).optional(), + azure_user_delegation_sas: z.lazy(() => unmarshalAzureUserDelegationSasSchema).optional(), + gcp_oauth_token: z.lazy(() => unmarshalGcpOauthTokenSchema).optional(), + azure_aad: z.lazy(() => unmarshalAzureActiveDirectoryTokenSchema).optional(), + r2_temp_credentials: z.lazy(() => unmarshalR2CredentialsSchema).optional(), + uc_encrypted_token: z.lazy(() => unmarshalUcEncryptedTokenSchema).optional(), + expiration_time: z.number().optional(), + url: z.string().optional(), + }) + .transform(d => ({ + awsTempCredentials: d.aws_temp_credentials, + azureUserDelegationSas: d.azure_user_delegation_sas, + gcpOauthToken: d.gcp_oauth_token, + azureAad: d.azure_aad, + r2TempCredentials: d.r2_temp_credentials, + ucEncryptedToken: d.uc_encrypted_token, + expirationTime: d.expiration_time, + url: d.url, + })); + +export const unmarshalGenerateTemporaryServiceCredentialSchema: z.ZodType = z + .object({ + credential_name: z.string().optional(), + azure_options: z.lazy(() => unmarshalGenerateTemporaryServiceCredential_AzureOptionsSchema).optional(), + gcp_options: z.lazy(() => unmarshalGenerateTemporaryServiceCredential_GcpOptionsSchema).optional(), + }) + .transform(d => ({ + credentialName: d.credential_name, + azureOptions: d.azure_options, + gcpOptions: d.gcp_options, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGenerateTemporaryServiceCredential_AzureOptionsSchema: z.ZodType = - z - .object({ - resources: z.array(z.string()).optional(), - }) - .transform(d => ({ - resources: d.resources, - })); +export const unmarshalGenerateTemporaryServiceCredential_AzureOptionsSchema: z.ZodType = z + .object({ + resources: z.array(z.string()).optional(), + }) + .transform(d => ({ + resources: d.resources, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGenerateTemporaryServiceCredential_GcpOptionsSchema: z.ZodType = - z - .object({ - scopes: z.array(z.string()).optional(), - }) - .transform(d => ({ - scopes: d.scopes, - })); - -export const unmarshalGenerateTemporaryTableCredentialSchema: z.ZodType = - z - .object({ - table_id: z.string().optional(), - operation: z.enum(TableOperation).optional(), - }) - .transform(d => ({ - tableId: d.table_id, - operation: d.operation, - })); +export const unmarshalGenerateTemporaryServiceCredential_GcpOptionsSchema: z.ZodType = z + .object({ + scopes: z.array(z.string()).optional(), + }) + .transform(d => ({ + scopes: d.scopes, + })); + +export const unmarshalGenerateTemporaryTableCredentialSchema: z.ZodType = z + .object({ + table_id: z.string().optional(), + operation: z.enum(TableOperation).optional(), + }) + .transform(d => ({ + tableId: d.table_id, + operation: d.operation, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGenerateTemporaryTableCredential_ResponseSchema: z.ZodType = - z - .object({ - aws_temp_credentials: z - .lazy(() => unmarshalAwsCredentialsSchema) - .optional(), - azure_user_delegation_sas: z - .lazy(() => unmarshalAzureUserDelegationSasSchema) - .optional(), - gcp_oauth_token: z.lazy(() => unmarshalGcpOauthTokenSchema).optional(), - azure_aad: z - .lazy(() => unmarshalAzureActiveDirectoryTokenSchema) - .optional(), - r2_temp_credentials: z - .lazy(() => unmarshalR2CredentialsSchema) - .optional(), - uc_encrypted_token: z - .lazy(() => unmarshalUcEncryptedTokenSchema) - .optional(), - expiration_time: z.number().optional(), - url: z.string().optional(), - }) - .transform(d => ({ - awsTempCredentials: d.aws_temp_credentials, - azureUserDelegationSas: d.azure_user_delegation_sas, - gcpOauthToken: d.gcp_oauth_token, - azureAad: d.azure_aad, - r2TempCredentials: d.r2_temp_credentials, - ucEncryptedToken: d.uc_encrypted_token, - expirationTime: d.expiration_time, - url: d.url, - })); +export const unmarshalGenerateTemporaryTableCredential_ResponseSchema: z.ZodType = z + .object({ + aws_temp_credentials: z.lazy(() => unmarshalAwsCredentialsSchema).optional(), + azure_user_delegation_sas: z.lazy(() => unmarshalAzureUserDelegationSasSchema).optional(), + gcp_oauth_token: z.lazy(() => unmarshalGcpOauthTokenSchema).optional(), + azure_aad: z.lazy(() => unmarshalAzureActiveDirectoryTokenSchema).optional(), + r2_temp_credentials: z.lazy(() => unmarshalR2CredentialsSchema).optional(), + uc_encrypted_token: z.lazy(() => unmarshalUcEncryptedTokenSchema).optional(), + expiration_time: z.number().optional(), + url: z.string().optional(), + }) + .transform(d => ({ + awsTempCredentials: d.aws_temp_credentials, + azureUserDelegationSas: d.azure_user_delegation_sas, + gcpOauthToken: d.gcp_oauth_token, + azureAad: d.azure_aad, + r2TempCredentials: d.r2_temp_credentials, + ucEncryptedToken: d.uc_encrypted_token, + expirationTime: d.expiration_time, + url: d.url, + })); export const unmarshalGetCredentialSchema: z.ZodType = z .object({ @@ -1299,14 +1227,13 @@ export const unmarshalGetCredentialSchema: z.ZodType = z nameArg: d.name_arg, })); -export const unmarshalGetStorageCredentialSchema: z.ZodType = - z - .object({ - name_arg: z.string().optional(), - }) - .transform(d => ({ - nameArg: d.name_arg, - })); +export const unmarshalGetStorageCredentialSchema: z.ZodType = z + .object({ + name_arg: z.string().optional(), + }) + .transform(d => ({ + nameArg: d.name_arg, + })); export const unmarshalListCredentialsSchema: z.ZodType = z .object({ @@ -1321,45 +1248,38 @@ export const unmarshalListCredentialsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListCredentials_ResponseSchema: z.ZodType = - z - .object({ - credentials: z - .array(z.lazy(() => unmarshalCredentialInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - credentials: d.credentials, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListStorageCredentialsSchema: z.ZodType = - z - .object({ - include_unbound: z.boolean().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - includeUnbound: d.include_unbound, - maxResults: d.max_results, - pageToken: d.page_token, - })); +export const unmarshalListCredentials_ResponseSchema: z.ZodType = z + .object({ + credentials: z.array(z.lazy(() => unmarshalCredentialInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + credentials: d.credentials, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListStorageCredentialsSchema: z.ZodType = z + .object({ + include_unbound: z.boolean().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + includeUnbound: d.include_unbound, + maxResults: d.max_results, + pageToken: d.page_token, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListStorageCredentials_ResponseSchema: z.ZodType = - z - .object({ - storage_credentials: z - .array(z.lazy(() => unmarshalStorageCredentialInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - storageCredentials: d.storage_credentials, - nextPageToken: d.next_page_token, - })); +export const unmarshalListStorageCredentials_ResponseSchema: z.ZodType = z + .object({ + storage_credentials: z.array(z.lazy(() => unmarshalStorageCredentialInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + storageCredentials: d.storage_credentials, + nextPageToken: d.next_page_token, + })); export const unmarshalR2CredentialsSchema: z.ZodType = z .object({ @@ -1373,93 +1293,71 @@ export const unmarshalR2CredentialsSchema: z.ZodType = z sessionToken: d.session_token, })); -export const unmarshalStorageCredentialInfoSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - gcp_service_account_key: z - .lazy(() => unmarshalGcpServiceAccountKeySchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), - comment: z.string().optional(), - read_only: z.boolean().optional(), - owner: z.string().optional(), - id: z.string().optional(), - metastore_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - used_for_managed_storage: z.boolean().optional(), - full_name: z.string().optional(), - isolation_mode: z.enum(IsolationMode).optional(), - }) - .transform(d => ({ - name: d.name, - awsIamRole: d.aws_iam_role, - azureServicePrincipal: d.azure_service_principal, - gcpServiceAccountKey: d.gcp_service_account_key, - azureManagedIdentity: d.azure_managed_identity, - databricksGcpServiceAccount: d.databricks_gcp_service_account, - cloudflareApiToken: d.cloudflare_api_token, - comment: d.comment, - readOnly: d.read_only, - owner: d.owner, - id: d.id, - metastoreId: d.metastore_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - usedForManagedStorage: d.used_for_managed_storage, - fullName: d.full_name, - isolationMode: d.isolation_mode, - })); - -export const unmarshalTemporaryCredentialsSchema: z.ZodType = - z - .object({ - aws_temp_credentials: z - .lazy(() => unmarshalAwsCredentialsSchema) - .optional(), - azure_user_delegation_sas: z - .lazy(() => unmarshalAzureUserDelegationSasSchema) - .optional(), - gcp_oauth_token: z.lazy(() => unmarshalGcpOauthTokenSchema).optional(), - azure_aad: z - .lazy(() => unmarshalAzureActiveDirectoryTokenSchema) - .optional(), - r2_temp_credentials: z - .lazy(() => unmarshalR2CredentialsSchema) - .optional(), - uc_encrypted_token: z - .lazy(() => unmarshalUcEncryptedTokenSchema) - .optional(), - expiration_time: z.number().optional(), - url: z.string().optional(), - }) - .transform(d => ({ - awsTempCredentials: d.aws_temp_credentials, - azureUserDelegationSas: d.azure_user_delegation_sas, - gcpOauthToken: d.gcp_oauth_token, - azureAad: d.azure_aad, - r2TempCredentials: d.r2_temp_credentials, - ucEncryptedToken: d.uc_encrypted_token, - expirationTime: d.expiration_time, - url: d.url, - })); +export const unmarshalStorageCredentialInfoSchema: z.ZodType = z + .object({ + name: z.string().optional(), + aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + gcp_service_account_key: z.lazy(() => unmarshalGcpServiceAccountKeySchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), + comment: z.string().optional(), + read_only: z.boolean().optional(), + owner: z.string().optional(), + id: z.string().optional(), + metastore_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + used_for_managed_storage: z.boolean().optional(), + full_name: z.string().optional(), + isolation_mode: z.enum(IsolationMode).optional(), + }) + .transform(d => ({ + name: d.name, + awsIamRole: d.aws_iam_role, + azureServicePrincipal: d.azure_service_principal, + gcpServiceAccountKey: d.gcp_service_account_key, + azureManagedIdentity: d.azure_managed_identity, + databricksGcpServiceAccount: d.databricks_gcp_service_account, + cloudflareApiToken: d.cloudflare_api_token, + comment: d.comment, + readOnly: d.read_only, + owner: d.owner, + id: d.id, + metastoreId: d.metastore_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + usedForManagedStorage: d.used_for_managed_storage, + fullName: d.full_name, + isolationMode: d.isolation_mode, + })); + +export const unmarshalTemporaryCredentialsSchema: z.ZodType = z + .object({ + aws_temp_credentials: z.lazy(() => unmarshalAwsCredentialsSchema).optional(), + azure_user_delegation_sas: z.lazy(() => unmarshalAzureUserDelegationSasSchema).optional(), + gcp_oauth_token: z.lazy(() => unmarshalGcpOauthTokenSchema).optional(), + azure_aad: z.lazy(() => unmarshalAzureActiveDirectoryTokenSchema).optional(), + r2_temp_credentials: z.lazy(() => unmarshalR2CredentialsSchema).optional(), + uc_encrypted_token: z.lazy(() => unmarshalUcEncryptedTokenSchema).optional(), + expiration_time: z.number().optional(), + url: z.string().optional(), + }) + .transform(d => ({ + awsTempCredentials: d.aws_temp_credentials, + azureUserDelegationSas: d.azure_user_delegation_sas, + gcpOauthToken: d.gcp_oauth_token, + azureAad: d.azure_aad, + r2TempCredentials: d.r2_temp_credentials, + ucEncryptedToken: d.uc_encrypted_token, + expirationTime: d.expiration_time, + url: d.url, + })); export const unmarshalUcEncryptedTokenSchema: z.ZodType = z .object({ @@ -1477,21 +1375,63 @@ export const unmarshalUpdateCredentialSchema: z.ZodType = z force: z.boolean().optional(), name: z.string().optional(), aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - gcp_service_account_key: z - .lazy(() => unmarshalGcpServiceAccountKeySchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + gcp_service_account_key: z.lazy(() => unmarshalGcpServiceAccountKeySchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), + comment: z.string().optional(), + read_only: z.boolean().optional(), + owner: z.string().optional(), + id: z.string().optional(), + metastore_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + used_for_managed_storage: z.boolean().optional(), + full_name: z.string().optional(), + isolation_mode: z.enum(IsolationMode).optional(), + }) + .transform(d => ({ + nameArg: d.name_arg, + newName: d.new_name, + skipValidation: d.skip_validation, + force: d.force, + name: d.name, + awsIamRole: d.aws_iam_role, + azureServicePrincipal: d.azure_service_principal, + gcpServiceAccountKey: d.gcp_service_account_key, + azureManagedIdentity: d.azure_managed_identity, + databricksGcpServiceAccount: d.databricks_gcp_service_account, + cloudflareApiToken: d.cloudflare_api_token, + comment: d.comment, + readOnly: d.read_only, + owner: d.owner, + id: d.id, + metastoreId: d.metastore_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + usedForManagedStorage: d.used_for_managed_storage, + fullName: d.full_name, + isolationMode: d.isolation_mode, + })); + +export const unmarshalUpdateStorageCredentialSchema: z.ZodType = z + .object({ + name_arg: z.string().optional(), + new_name: z.string().optional(), + skip_validation: z.boolean().optional(), + force: z.boolean().optional(), + name: z.string().optional(), + aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + gcp_service_account_key: z.lazy(() => unmarshalGcpServiceAccountKeySchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), read_only: z.boolean().optional(), owner: z.string().optional(), @@ -1531,184 +1471,95 @@ export const unmarshalUpdateCredentialSchema: z.ZodType = z isolationMode: d.isolation_mode, })); -export const unmarshalUpdateStorageCredentialSchema: z.ZodType = - z - .object({ - name_arg: z.string().optional(), - new_name: z.string().optional(), - skip_validation: z.boolean().optional(), - force: z.boolean().optional(), - name: z.string().optional(), - aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - gcp_service_account_key: z - .lazy(() => unmarshalGcpServiceAccountKeySchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), - comment: z.string().optional(), - read_only: z.boolean().optional(), - owner: z.string().optional(), - id: z.string().optional(), - metastore_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - used_for_managed_storage: z.boolean().optional(), - full_name: z.string().optional(), - isolation_mode: z.enum(IsolationMode).optional(), - }) - .transform(d => ({ - nameArg: d.name_arg, - newName: d.new_name, - skipValidation: d.skip_validation, - force: d.force, - name: d.name, - awsIamRole: d.aws_iam_role, - azureServicePrincipal: d.azure_service_principal, - gcpServiceAccountKey: d.gcp_service_account_key, - azureManagedIdentity: d.azure_managed_identity, - databricksGcpServiceAccount: d.databricks_gcp_service_account, - cloudflareApiToken: d.cloudflare_api_token, - comment: d.comment, - readOnly: d.read_only, - owner: d.owner, - id: d.id, - metastoreId: d.metastore_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - usedForManagedStorage: d.used_for_managed_storage, - fullName: d.full_name, - isolationMode: d.isolation_mode, - })); - -export const unmarshalValidateCredentialSchema: z.ZodType = - z - .object({ - credential_name: z.string().optional(), - aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - external_location_name: z.string().optional(), - url: z.string().optional(), - read_only: z.boolean().optional(), - }) - .transform(d => ({ - credentialName: d.credential_name, - awsIamRole: d.aws_iam_role, - azureManagedIdentity: d.azure_managed_identity, - databricksGcpServiceAccount: d.databricks_gcp_service_account, - externalLocationName: d.external_location_name, - url: d.url, - readOnly: d.read_only, - })); +export const unmarshalValidateCredentialSchema: z.ZodType = z + .object({ + credential_name: z.string().optional(), + aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + external_location_name: z.string().optional(), + url: z.string().optional(), + read_only: z.boolean().optional(), + }) + .transform(d => ({ + credentialName: d.credential_name, + awsIamRole: d.aws_iam_role, + azureManagedIdentity: d.azure_managed_identity, + databricksGcpServiceAccount: d.databricks_gcp_service_account, + externalLocationName: d.external_location_name, + url: d.url, + readOnly: d.read_only, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalValidateCredential_ResponseSchema: z.ZodType = - z - .object({ - results: z - .array(z.lazy(() => unmarshalValidateCredential_ValidationResultSchema)) - .optional(), - isDir: z.boolean().optional(), - }) - .transform(d => ({ - results: d.results, - isDir: d.isDir, - })); +export const unmarshalValidateCredential_ResponseSchema: z.ZodType = z + .object({ + results: z.array(z.lazy(() => unmarshalValidateCredential_ValidationResultSchema)).optional(), + isDir: z.boolean().optional(), + }) + .transform(d => ({ + results: d.results, + isDir: d.isDir, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalValidateCredential_ValidationResultSchema: z.ZodType = - z - .object({ - result: z.enum(ValidateCredential_Result).optional(), - message: z.string().optional(), - }) - .transform(d => ({ - result: d.result, - message: d.message, - })); - -export const unmarshalValidateStorageCredentialSchema: z.ZodType = - z - .object({ - storage_credential_name: z.string().optional(), - aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), - azure_service_principal: z - .lazy(() => unmarshalAzureServicePrincipalSchema) - .optional(), - azure_managed_identity: z - .lazy(() => unmarshalAzureManagedIdentitySchema) - .optional(), - databricks_gcp_service_account: z - .lazy(() => unmarshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflare_api_token: z - .lazy(() => unmarshalCloudflareApiTokenSchema) - .optional(), - external_location_name: z.string().optional(), - url: z.string().optional(), - read_only: z.boolean().optional(), - }) - .transform(d => ({ - storageCredentialName: d.storage_credential_name, - awsIamRole: d.aws_iam_role, - azureServicePrincipal: d.azure_service_principal, - azureManagedIdentity: d.azure_managed_identity, - databricksGcpServiceAccount: d.databricks_gcp_service_account, - cloudflareApiToken: d.cloudflare_api_token, - externalLocationName: d.external_location_name, - url: d.url, - readOnly: d.read_only, - })); +export const unmarshalValidateCredential_ValidationResultSchema: z.ZodType = z + .object({ + result: z.enum(ValidateCredential_Result).optional(), + message: z.string().optional(), + }) + .transform(d => ({ + result: d.result, + message: d.message, + })); + +export const unmarshalValidateStorageCredentialSchema: z.ZodType = z + .object({ + storage_credential_name: z.string().optional(), + aws_iam_role: z.lazy(() => unmarshalAwsIamRoleSchema).optional(), + azure_service_principal: z.lazy(() => unmarshalAzureServicePrincipalSchema).optional(), + azure_managed_identity: z.lazy(() => unmarshalAzureManagedIdentitySchema).optional(), + databricks_gcp_service_account: z.lazy(() => unmarshalDatabricksGcpServiceAccountSchema).optional(), + cloudflare_api_token: z.lazy(() => unmarshalCloudflareApiTokenSchema).optional(), + external_location_name: z.string().optional(), + url: z.string().optional(), + read_only: z.boolean().optional(), + }) + .transform(d => ({ + storageCredentialName: d.storage_credential_name, + awsIamRole: d.aws_iam_role, + azureServicePrincipal: d.azure_service_principal, + azureManagedIdentity: d.azure_managed_identity, + databricksGcpServiceAccount: d.databricks_gcp_service_account, + cloudflareApiToken: d.cloudflare_api_token, + externalLocationName: d.external_location_name, + url: d.url, + readOnly: d.read_only, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalValidateStorageCredential_ResponseSchema: z.ZodType = - z - .object({ - isDir: z.boolean().optional(), - results: z - .array( - z.lazy( - () => unmarshalValidateStorageCredential_ValidationResultSchema - ) - ) - .optional(), - }) - .transform(d => ({ - isDir: d.isDir, - results: d.results, - })); +export const unmarshalValidateStorageCredential_ResponseSchema: z.ZodType = z + .object({ + isDir: z.boolean().optional(), + results: z.array(z.lazy(() => unmarshalValidateStorageCredential_ValidationResultSchema)).optional(), + }) + .transform(d => ({ + isDir: d.isDir, + results: d.results, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalValidateStorageCredential_ValidationResultSchema: z.ZodType = - z - .object({ - operation: z.enum(ValidateStorageCredential_FileOperation).optional(), - result: z.enum(ValidateStorageCredential_Result).optional(), - message: z.string().optional(), - }) - .transform(d => ({ - operation: d.operation, - result: d.result, - message: d.message, - })); +export const unmarshalValidateStorageCredential_ValidationResultSchema: z.ZodType = z + .object({ + operation: z.enum(ValidateStorageCredential_FileOperation).optional(), + result: z.enum(ValidateStorageCredential_Result).optional(), + message: z.string().optional(), + }) + .transform(d => ({ + operation: d.operation, + result: d.result, + message: d.message, + })); export const marshalAwsCredentialsSchema: z.ZodType = z .object({ @@ -1793,21 +1644,11 @@ export const marshalCreateCredentialSchema: z.ZodType = z skipValidation: z.boolean().optional(), name: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - gcpServiceAccountKey: z - .lazy(() => marshalGcpServiceAccountKeySchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + gcpServiceAccountKey: z.lazy(() => marshalGcpServiceAccountKeySchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), readOnly: z.boolean().optional(), owner: z.string().optional(), @@ -1849,21 +1690,11 @@ export const marshalCreateStorageCredentialSchema: z.ZodType = z skipValidation: z.boolean().optional(), name: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - gcpServiceAccountKey: z - .lazy(() => marshalGcpServiceAccountKeySchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + gcpServiceAccountKey: z.lazy(() => marshalGcpServiceAccountKeySchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), readOnly: z.boolean().optional(), owner: z.string().optional(), @@ -1904,21 +1735,11 @@ export const marshalCredentialInfoSchema: z.ZodType = z .object({ name: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - gcpServiceAccountKey: z - .lazy(() => marshalGcpServiceAccountKeySchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + gcpServiceAccountKey: z.lazy(() => marshalGcpServiceAccountKeySchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), readOnly: z.boolean().optional(), owner: z.string().optional(), @@ -1977,7 +1798,9 @@ export const marshalDeleteCredentialSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteCredential_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteCredential_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeleteStorageCredentialSchema: z.ZodType = z .object({ @@ -1990,8 +1813,9 @@ export const marshalDeleteStorageCredentialSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteStorageCredential_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeleteStorageCredential_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalGcpOauthTokenSchema: z.ZodType = z .object({ @@ -2026,40 +1850,33 @@ export const marshalGenerateTemporaryPathCredentialSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalGenerateTemporaryPathCredential_ResponseSchema: z.ZodType = - z - .object({ - awsTempCredentials: z.lazy(() => marshalAwsCredentialsSchema).optional(), - azureUserDelegationSas: z - .lazy(() => marshalAzureUserDelegationSasSchema) - .optional(), - gcpOauthToken: z.lazy(() => marshalGcpOauthTokenSchema).optional(), - azureAad: z.lazy(() => marshalAzureActiveDirectoryTokenSchema).optional(), - r2TempCredentials: z.lazy(() => marshalR2CredentialsSchema).optional(), - ucEncryptedToken: z.lazy(() => marshalUcEncryptedTokenSchema).optional(), - expirationTime: z.number().optional(), - url: z.string().optional(), - }) - .transform(d => ({ - aws_temp_credentials: d.awsTempCredentials, - azure_user_delegation_sas: d.azureUserDelegationSas, - gcp_oauth_token: d.gcpOauthToken, - azure_aad: d.azureAad, - r2_temp_credentials: d.r2TempCredentials, - uc_encrypted_token: d.ucEncryptedToken, - expiration_time: d.expirationTime, - url: d.url, - })); +export const marshalGenerateTemporaryPathCredential_ResponseSchema: z.ZodType = z + .object({ + awsTempCredentials: z.lazy(() => marshalAwsCredentialsSchema).optional(), + azureUserDelegationSas: z.lazy(() => marshalAzureUserDelegationSasSchema).optional(), + gcpOauthToken: z.lazy(() => marshalGcpOauthTokenSchema).optional(), + azureAad: z.lazy(() => marshalAzureActiveDirectoryTokenSchema).optional(), + r2TempCredentials: z.lazy(() => marshalR2CredentialsSchema).optional(), + ucEncryptedToken: z.lazy(() => marshalUcEncryptedTokenSchema).optional(), + expirationTime: z.number().optional(), + url: z.string().optional(), + }) + .transform(d => ({ + aws_temp_credentials: d.awsTempCredentials, + azure_user_delegation_sas: d.azureUserDelegationSas, + gcp_oauth_token: d.gcpOauthToken, + azure_aad: d.azureAad, + r2_temp_credentials: d.r2TempCredentials, + uc_encrypted_token: d.ucEncryptedToken, + expiration_time: d.expirationTime, + url: d.url, + })); export const marshalGenerateTemporaryServiceCredentialSchema: z.ZodType = z .object({ credentialName: z.string().optional(), - azureOptions: z - .lazy(() => marshalGenerateTemporaryServiceCredential_AzureOptionsSchema) - .optional(), - gcpOptions: z - .lazy(() => marshalGenerateTemporaryServiceCredential_GcpOptionsSchema) - .optional(), + azureOptions: z.lazy(() => marshalGenerateTemporaryServiceCredential_AzureOptionsSchema).optional(), + gcpOptions: z.lazy(() => marshalGenerateTemporaryServiceCredential_GcpOptionsSchema).optional(), }) .transform(d => ({ credential_name: d.credentialName, @@ -2068,24 +1885,22 @@ export const marshalGenerateTemporaryServiceCredentialSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalGenerateTemporaryServiceCredential_AzureOptionsSchema: z.ZodType = - z - .object({ - resources: z.array(z.string()).optional(), - }) - .transform(d => ({ - resources: d.resources, - })); +export const marshalGenerateTemporaryServiceCredential_AzureOptionsSchema: z.ZodType = z + .object({ + resources: z.array(z.string()).optional(), + }) + .transform(d => ({ + resources: d.resources, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalGenerateTemporaryServiceCredential_GcpOptionsSchema: z.ZodType = - z - .object({ - scopes: z.array(z.string()).optional(), - }) - .transform(d => ({ - scopes: d.scopes, - })); +export const marshalGenerateTemporaryServiceCredential_GcpOptionsSchema: z.ZodType = z + .object({ + scopes: z.array(z.string()).optional(), + }) + .transform(d => ({ + scopes: d.scopes, + })); export const marshalGenerateTemporaryTableCredentialSchema: z.ZodType = z .object({ @@ -2098,30 +1913,27 @@ export const marshalGenerateTemporaryTableCredentialSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalGenerateTemporaryTableCredential_ResponseSchema: z.ZodType = - z - .object({ - awsTempCredentials: z.lazy(() => marshalAwsCredentialsSchema).optional(), - azureUserDelegationSas: z - .lazy(() => marshalAzureUserDelegationSasSchema) - .optional(), - gcpOauthToken: z.lazy(() => marshalGcpOauthTokenSchema).optional(), - azureAad: z.lazy(() => marshalAzureActiveDirectoryTokenSchema).optional(), - r2TempCredentials: z.lazy(() => marshalR2CredentialsSchema).optional(), - ucEncryptedToken: z.lazy(() => marshalUcEncryptedTokenSchema).optional(), - expirationTime: z.number().optional(), - url: z.string().optional(), - }) - .transform(d => ({ - aws_temp_credentials: d.awsTempCredentials, - azure_user_delegation_sas: d.azureUserDelegationSas, - gcp_oauth_token: d.gcpOauthToken, - azure_aad: d.azureAad, - r2_temp_credentials: d.r2TempCredentials, - uc_encrypted_token: d.ucEncryptedToken, - expiration_time: d.expirationTime, - url: d.url, - })); +export const marshalGenerateTemporaryTableCredential_ResponseSchema: z.ZodType = z + .object({ + awsTempCredentials: z.lazy(() => marshalAwsCredentialsSchema).optional(), + azureUserDelegationSas: z.lazy(() => marshalAzureUserDelegationSasSchema).optional(), + gcpOauthToken: z.lazy(() => marshalGcpOauthTokenSchema).optional(), + azureAad: z.lazy(() => marshalAzureActiveDirectoryTokenSchema).optional(), + r2TempCredentials: z.lazy(() => marshalR2CredentialsSchema).optional(), + ucEncryptedToken: z.lazy(() => marshalUcEncryptedTokenSchema).optional(), + expirationTime: z.number().optional(), + url: z.string().optional(), + }) + .transform(d => ({ + aws_temp_credentials: d.awsTempCredentials, + azure_user_delegation_sas: d.azureUserDelegationSas, + gcp_oauth_token: d.gcpOauthToken, + azure_aad: d.azureAad, + r2_temp_credentials: d.r2TempCredentials, + uc_encrypted_token: d.ucEncryptedToken, + expiration_time: d.expirationTime, + url: d.url, + })); export const marshalGetCredentialSchema: z.ZodType = z .object({ @@ -2177,9 +1989,7 @@ export const marshalListStorageCredentialsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListStorageCredentials_ResponseSchema: z.ZodType = z .object({ - storageCredentials: z - .array(z.lazy(() => marshalStorageCredentialInfoSchema)) - .optional(), + storageCredentials: z.array(z.lazy(() => marshalStorageCredentialInfoSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2203,21 +2013,11 @@ export const marshalStorageCredentialInfoSchema: z.ZodType = z .object({ name: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - gcpServiceAccountKey: z - .lazy(() => marshalGcpServiceAccountKeySchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + gcpServiceAccountKey: z.lazy(() => marshalGcpServiceAccountKeySchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), readOnly: z.boolean().optional(), owner: z.string().optional(), @@ -2256,9 +2056,7 @@ export const marshalStorageCredentialInfoSchema: z.ZodType = z export const marshalTemporaryCredentialsSchema: z.ZodType = z .object({ awsTempCredentials: z.lazy(() => marshalAwsCredentialsSchema).optional(), - azureUserDelegationSas: z - .lazy(() => marshalAzureUserDelegationSasSchema) - .optional(), + azureUserDelegationSas: z.lazy(() => marshalAzureUserDelegationSasSchema).optional(), gcpOauthToken: z.lazy(() => marshalGcpOauthTokenSchema).optional(), azureAad: z.lazy(() => marshalAzureActiveDirectoryTokenSchema).optional(), r2TempCredentials: z.lazy(() => marshalR2CredentialsSchema).optional(), @@ -2293,21 +2091,11 @@ export const marshalUpdateCredentialSchema: z.ZodType = z force: z.boolean().optional(), name: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - gcpServiceAccountKey: z - .lazy(() => marshalGcpServiceAccountKeySchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + gcpServiceAccountKey: z.lazy(() => marshalGcpServiceAccountKeySchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), readOnly: z.boolean().optional(), owner: z.string().optional(), @@ -2355,21 +2143,11 @@ export const marshalUpdateStorageCredentialSchema: z.ZodType = z force: z.boolean().optional(), name: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - gcpServiceAccountKey: z - .lazy(() => marshalGcpServiceAccountKeySchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + gcpServiceAccountKey: z.lazy(() => marshalGcpServiceAccountKeySchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), comment: z.string().optional(), readOnly: z.boolean().optional(), owner: z.string().optional(), @@ -2413,12 +2191,8 @@ export const marshalValidateCredentialSchema: z.ZodType = z .object({ credentialName: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), externalLocationName: z.string().optional(), url: z.string().optional(), readOnly: z.boolean().optional(), @@ -2436,9 +2210,7 @@ export const marshalValidateCredentialSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalValidateCredential_ResponseSchema: z.ZodType = z .object({ - results: z - .array(z.lazy(() => marshalValidateCredential_ValidationResultSchema)) - .optional(), + results: z.array(z.lazy(() => marshalValidateCredential_ValidationResultSchema)).optional(), isDir: z.boolean().optional(), }) .transform(d => ({ @@ -2461,18 +2233,10 @@ export const marshalValidateStorageCredentialSchema: z.ZodType = z .object({ storageCredentialName: z.string().optional(), awsIamRole: z.lazy(() => marshalAwsIamRoleSchema).optional(), - azureServicePrincipal: z - .lazy(() => marshalAzureServicePrincipalSchema) - .optional(), - azureManagedIdentity: z - .lazy(() => marshalAzureManagedIdentitySchema) - .optional(), - databricksGcpServiceAccount: z - .lazy(() => marshalDatabricksGcpServiceAccountSchema) - .optional(), - cloudflareApiToken: z - .lazy(() => marshalCloudflareApiTokenSchema) - .optional(), + azureServicePrincipal: z.lazy(() => marshalAzureServicePrincipalSchema).optional(), + azureManagedIdentity: z.lazy(() => marshalAzureManagedIdentitySchema).optional(), + databricksGcpServiceAccount: z.lazy(() => marshalDatabricksGcpServiceAccountSchema).optional(), + cloudflareApiToken: z.lazy(() => marshalCloudflareApiTokenSchema).optional(), externalLocationName: z.string().optional(), url: z.string().optional(), readOnly: z.boolean().optional(), @@ -2493,11 +2257,7 @@ export const marshalValidateStorageCredentialSchema: z.ZodType = z export const marshalValidateStorageCredential_ResponseSchema: z.ZodType = z .object({ isDir: z.boolean().optional(), - results: z - .array( - z.lazy(() => marshalValidateStorageCredential_ValidationResultSchema) - ) - .optional(), + results: z.array(z.lazy(() => marshalValidateStorageCredential_ValidationResultSchema)).optional(), }) .transform(d => ({ isDir: d.isDir, @@ -2505,15 +2265,14 @@ export const marshalValidateStorageCredential_ResponseSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalValidateStorageCredential_ValidationResultSchema: z.ZodType = - z - .object({ - operation: z.enum(ValidateStorageCredential_FileOperation).optional(), - result: z.enum(ValidateStorageCredential_Result).optional(), - message: z.string().optional(), - }) - .transform(d => ({ - operation: d.operation, - result: d.result, - message: d.message, - })); +export const marshalValidateStorageCredential_ValidationResultSchema: z.ZodType = z + .object({ + operation: z.enum(ValidateStorageCredential_FileOperation).optional(), + result: z.enum(ValidateStorageCredential_Result).optional(), + message: z.string().optional(), + }) + .transform(d => ({ + operation: d.operation, + result: d.result, + message: d.message, + })); diff --git a/packages/credentials/src/v1/utils.ts b/packages/credentials/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/credentials/src/v1/utils.ts +++ b/packages/credentials/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/credentials/tsconfig.json b/packages/credentials/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/credentials/tsconfig.json +++ b/packages/credentials/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/dataclassification/package.json b/packages/dataclassification/package.json index b210978b..09d3f3c0 100644 --- a/packages/dataclassification/package.json +++ b/packages/dataclassification/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/dataclassification/src/v1/client.ts b/packages/dataclassification/src/v1/client.ts index 927d4c78..64068cfe 100644 --- a/packages/dataclassification/src/v1/client.ts +++ b/packages/dataclassification/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CatalogConfig, CreateCatalogConfigRequest, @@ -41,26 +36,18 @@ export class Client { /** * Create Data Classification configuration for a catalog. - * + * * Creates a new config resource, which enables Data Classification * for the specified catalog. * - The config must not already exist for the catalog. */ - async createCatalogConfig( - signal: AbortSignal | undefined, - req: CreateCatalogConfigRequest, - options?: Options - ): Promise { + async createCatalogConfig(signal: AbortSignal | undefined, req: CreateCatalogConfigRequest, options?: Options): Promise { const url = `${this.host}/api/data-classification/v1/${req.parent ?? ''}/config`; const body = marshalRequest(req.catalogConfig, marshalCatalogConfigSchema); let resp: CatalogConfig | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogConfigSchema); }; await execute(signal, call, options); @@ -71,38 +58,22 @@ export class Client { } /** Delete Data Classification configuration for a catalog. */ - async deleteCatalogConfig( - signal: AbortSignal | undefined, - req: DeleteCatalogConfigRequest, - options?: Options - ): Promise { + async deleteCatalogConfig(signal: AbortSignal | undefined, req: DeleteCatalogConfigRequest, options?: Options): Promise { const url = `${this.host}/api/data-classification/v1/${req.name ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Get the Data Classification configuration for a catalog. */ - async getCatalogConfig( - signal: AbortSignal | undefined, - req: GetCatalogConfigRequest, - options?: Options - ): Promise { + async getCatalogConfig(signal: AbortSignal | undefined, req: GetCatalogConfigRequest, options?: Options): Promise { const url = `${this.host}/api/data-classification/v1/${req.name ?? ''}`; let resp: CatalogConfig | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogConfigSchema); }; await execute(signal, call, options); @@ -117,15 +88,11 @@ export class Client { * - The config must already exist for the catalog. * - Updates fields specified in the update_mask. Use update_mask field to perform partial updates of the configuration. */ - async updateCatalogConfig( - signal: AbortSignal | undefined, - req: UpdateCatalogConfigRequest, - options?: Options - ): Promise { + async updateCatalogConfig(signal: AbortSignal | undefined, req: UpdateCatalogConfigRequest, options?: Options): Promise { const url = `${this.host}/api/data-classification/v1/${req.catalogConfig?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -133,11 +100,7 @@ export class Client { let resp: CatalogConfig | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogConfigSchema); }; await execute(signal, call, options); diff --git a/packages/dataclassification/src/v1/index.ts b/packages/dataclassification/src/v1/index.ts index 07ed2e89..9d5b4b68 100644 --- a/packages/dataclassification/src/v1/index.ts +++ b/packages/dataclassification/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {AutoTaggingConfig_AutoTaggingMode} from './model'; +export { + AutoTaggingConfig_AutoTaggingMode, +} from './model'; export type { AutoTaggingConfig, diff --git a/packages/dataclassification/src/v1/model.ts b/packages/dataclassification/src/v1/model.ts index 5b8658e0..3712827f 100644 --- a/packages/dataclassification/src/v1/model.ts +++ b/packages/dataclassification/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** Auto-tagging mode. */ @@ -81,7 +82,7 @@ export interface GetCatalogConfigRequest { /** * 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. */ @@ -92,7 +93,7 @@ export interface UpdateCatalogConfigRequest { */ catalogConfig?: CatalogConfig | undefined; /** Field mask specifying which fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export const unmarshalAutoTaggingConfigSchema: z.ZodType = z @@ -108,15 +109,9 @@ export const unmarshalAutoTaggingConfigSchema: z.ZodType = z export const unmarshalCatalogConfigSchema: z.ZodType = z .object({ name: z.string().optional(), - included_schemas: z - .lazy(() => unmarshalCatalogConfig_SchemaNamesSchema) - .optional(), - auto_tag_configs: z - .array(z.lazy(() => unmarshalAutoTaggingConfigSchema)) - .optional(), - effective_auto_tag_configs: z - .array(z.lazy(() => unmarshalAutoTaggingConfigSchema)) - .optional(), + included_schemas: z.lazy(() => unmarshalCatalogConfig_SchemaNamesSchema).optional(), + auto_tag_configs: z.array(z.lazy(() => unmarshalAutoTaggingConfigSchema)).optional(), + effective_auto_tag_configs: z.array(z.lazy(() => unmarshalAutoTaggingConfigSchema)).optional(), }) .transform(d => ({ name: d.name, @@ -126,54 +121,49 @@ export const unmarshalCatalogConfigSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCatalogConfig_SchemaNamesSchema: z.ZodType = - z - .object({ - names: z.array(z.string()).optional(), - }) - .transform(d => ({ - names: d.names, - })); - -export const unmarshalCreateCatalogConfigRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - catalog_config: z.lazy(() => unmarshalCatalogConfigSchema).optional(), - }) - .transform(d => ({ - parent: d.parent, - catalogConfig: d.catalog_config, - })); - -export const unmarshalDeleteCatalogConfigRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalGetCatalogConfigRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalUpdateCatalogConfigRequestSchema: z.ZodType = - z - .object({ - catalog_config: z.lazy(() => unmarshalCatalogConfigSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - catalogConfig: d.catalog_config, - updateMask: d.update_mask, - })); +export const unmarshalCatalogConfig_SchemaNamesSchema: z.ZodType = z + .object({ + names: z.array(z.string()).optional(), + }) + .transform(d => ({ + names: d.names, + })); + +export const unmarshalCreateCatalogConfigRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + catalog_config: z.lazy(() => unmarshalCatalogConfigSchema).optional(), + }) + .transform(d => ({ + parent: d.parent, + catalogConfig: d.catalog_config, + })); + +export const unmarshalDeleteCatalogConfigRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalGetCatalogConfigRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalUpdateCatalogConfigRequestSchema: z.ZodType = z + .object({ + catalog_config: z.lazy(() => unmarshalCatalogConfigSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + catalogConfig: d.catalog_config, + updateMask: d.update_mask, + })); export const marshalAutoTaggingConfigSchema: z.ZodType = z .object({ @@ -188,15 +178,9 @@ export const marshalAutoTaggingConfigSchema: z.ZodType = z export const marshalCatalogConfigSchema: z.ZodType = z .object({ name: z.string().optional(), - includedSchemas: z - .lazy(() => marshalCatalogConfig_SchemaNamesSchema) - .optional(), - autoTagConfigs: z - .array(z.lazy(() => marshalAutoTaggingConfigSchema)) - .optional(), - effectiveAutoTagConfigs: z - .array(z.lazy(() => marshalAutoTaggingConfigSchema)) - .optional(), + includedSchemas: z.lazy(() => marshalCatalogConfig_SchemaNamesSchema).optional(), + autoTagConfigs: z.array(z.lazy(() => marshalAutoTaggingConfigSchema)).optional(), + effectiveAutoTagConfigs: z.array(z.lazy(() => marshalAutoTaggingConfigSchema)).optional(), }) .transform(d => ({ name: d.name, @@ -243,7 +227,7 @@ export const marshalGetCatalogConfigRequestSchema: z.ZodType = z export const marshalUpdateCatalogConfigRequestSchema: z.ZodType = z .object({ catalogConfig: z.lazy(() => marshalCatalogConfigSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ catalog_config: d.catalogConfig, diff --git a/packages/dataclassification/src/v1/utils.ts b/packages/dataclassification/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/dataclassification/src/v1/utils.ts +++ b/packages/dataclassification/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/dataclassification/tsconfig.json b/packages/dataclassification/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/dataclassification/tsconfig.json +++ b/packages/dataclassification/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/dataquality/package.json b/packages/dataquality/package.json index 9b9527c9..7f83202c 100644 --- a/packages/dataquality/package.json +++ b/packages/dataquality/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/dataquality/src/v1/client.ts b/packages/dataquality/src/v1/client.ts index 9c5f911c..c6f47b1e 100644 --- a/packages/dataquality/src/v1/client.ts +++ b/packages/dataquality/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CancelRefreshRequest, CancelRefreshResponse, @@ -59,27 +54,19 @@ export class Client { /** * Cancels a data quality monitor refresh. Currently only supported for the `table` `object_type`. * The call must be made in the same workspace as where the monitor was created. - * + * * The caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog. * 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **MANAGE** on the table. */ - async cancelRefresh( - signal: AbortSignal | undefined, - req: CancelRefreshRequest, - options?: Options - ): Promise { + async cancelRefresh(signal: AbortSignal | undefined, req: CancelRefreshRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}/refreshes/${String(req.refreshId ?? '')}/cancel`; const body = marshalRequest(req, marshalCancelRefreshRequestSchema); let resp: CancelRefreshResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCancelRefreshResponseSchema); }; await execute(signal, call, options); @@ -91,33 +78,25 @@ export class Client { /** * Create a data quality monitor on a Unity Catalog object. The caller must provide either `anomaly_detection_config` for a schema monitor or `data_profiling_config` for a table monitor. - * + * * For the `table` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **SELECT** on the table * 2. **USE_CATALOG** on the table's parent catalog, **MANAGE** and **USE_SCHEMA** on the table's parent schema, and **SELECT** on the table. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **MANAGE** and **SELECT** on the table. - * + * * Workspace assets, such as the dashboard, will be created in the workspace where this call was made. - * + * * For the `schema` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog. * 2. **USE_CATALOG** on the schema's parent catalog, and **MANAGE** and **USE_SCHEMA** on the schema. */ - async createMonitor( - signal: AbortSignal | undefined, - req: CreateMonitorRequest, - options?: Options - ): Promise { + async createMonitor(signal: AbortSignal | undefined, req: CreateMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors`; const body = marshalRequest(req.monitor, marshalMonitorSchema); let resp: Monitor | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMonitorSchema); }; await execute(signal, call, options); @@ -130,27 +109,19 @@ export class Client { /** * Creates a refresh. Currently only supported for the `table` `object_type`. * The call must be made in the same workspace as where the monitor was created. - * + * * The caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog. * 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **MANAGE** on the table. */ - async createRefresh( - signal: AbortSignal | undefined, - req: CreateRefreshRequest, - options?: Options - ): Promise { + async createRefresh(signal: AbortSignal | undefined, req: CreateRefreshRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.refresh?.objectType ?? ''}/${req.refresh?.objectId ?? ''}/refreshes`; const body = marshalRequest(req.refresh, marshalRefreshSchema); let resp: Refresh | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRefreshSchema); }; await execute(signal, call, options); @@ -162,84 +133,60 @@ export class Client { /** * Delete a data quality monitor on Unity Catalog object. - * + * * For the `table` `object_type`, the caller must have either of the following sets of permissions: * **MANAGE** and **USE_CATALOG** on the table's parent catalog. * **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **MANAGE** on the table. - * + * * Note that the metric tables and dashboard will not be deleted as part of this call; those * assets must be manually cleaned up (if desired). - * + * * For the `schema` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog. * 2. **USE_CATALOG** on the schema's parent catalog, and **MANAGE** and **USE_SCHEMA** on the schema. */ - async deleteMonitor( - signal: AbortSignal | undefined, - req: DeleteMonitorRequest, - options?: Options - ): Promise { + async deleteMonitor(signal: AbortSignal | undefined, req: DeleteMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** (Unimplemented) Delete a refresh */ - async deleteRefresh( - signal: AbortSignal | undefined, - req: DeleteRefreshRequest, - options?: Options - ): Promise { + async deleteRefresh(signal: AbortSignal | undefined, req: DeleteRefreshRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}/refreshes/${String(req.refreshId ?? '')}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** * Read a data quality monitor on a Unity Catalog object. - * + * * For the `table` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog. * 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **SELECT** on the table. - * + * * For the `schema` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog. * 2. **USE_CATALOG** on the schema's parent catalog, and **USE_SCHEMA** on the schema. - * + * * The returned information includes configuration values on the entity and parent entity as well as information on * assets created by the monitor. Some information (e.g. dashboard) may be filtered out * if the caller is in a different workspace than where the monitor was created. */ - async getMonitor( - signal: AbortSignal | undefined, - req: GetMonitorRequest, - options?: Options - ): Promise { + async getMonitor(signal: AbortSignal | undefined, req: GetMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}`; let resp: Monitor | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMonitorSchema); }; await execute(signal, call, options); @@ -251,30 +198,22 @@ export class Client { /** * Get data quality monitor refresh. The call must be made in the same workspace as where the monitor was created. - * + * * For the `table` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog. * 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **SELECT** on the table. - * + * * For the `schema` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog. * 2. **USE_CATALOG** on the schema's parent catalog, and **USE_SCHEMA** on the schema. */ - async getRefresh( - signal: AbortSignal | undefined, - req: GetRefreshRequest, - options?: Options - ): Promise { + async getRefresh(signal: AbortSignal | undefined, req: GetRefreshRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}/refreshes/${String(req.refreshId ?? '')}`; let resp: Refresh | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRefreshSchema); }; await execute(signal, call, options); @@ -285,11 +224,7 @@ export class Client { } /** (Unimplemented) List data quality monitors. */ - async listMonitor( - signal: AbortSignal | undefined, - req: ListMonitorRequest, - options?: Options - ): Promise { + async listMonitor(signal: AbortSignal | undefined, req: ListMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -303,11 +238,7 @@ export class Client { let resp: ListMonitorResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListMonitorResponseSchema); }; await execute(signal, call, options); @@ -317,11 +248,8 @@ export class Client { return resp; } - async *listMonitorIter( - signal: AbortSignal | undefined, - req: ListMonitorRequest, - options?: Options - ): AsyncGenerator { + + async *listMonitorIter(signal: AbortSignal | undefined, req: ListMonitorRequest, options?: Options): AsyncGenerator { const pageReq: ListMonitorRequest = {...req}; for (;;) { const resp = await this.listMonitor(signal, pageReq, options); @@ -335,23 +263,20 @@ export class Client { } } + /** * List data quality monitor refreshes. The call must be made in the same workspace as where the monitor was created. - * + * * For the `table` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog. * 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **SELECT** on the table. - * + * * For the `schema` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog. * 2. **USE_CATALOG** on the schema's parent catalog, and **USE_SCHEMA** on the schema. */ - async listRefresh( - signal: AbortSignal | undefined, - req: ListRefreshRequest, - options?: Options - ): Promise { + async listRefresh(signal: AbortSignal | undefined, req: ListRefreshRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}/refreshes`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -365,11 +290,7 @@ export class Client { let resp: ListRefreshResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListRefreshResponseSchema); }; await execute(signal, call, options); @@ -379,11 +300,8 @@ export class Client { return resp; } - async *listRefreshIter( - signal: AbortSignal | undefined, - req: ListRefreshRequest, - options?: Options - ): AsyncGenerator { + + async *listRefreshIter(signal: AbortSignal | undefined, req: ListRefreshRequest, options?: Options): AsyncGenerator { const pageReq: ListRefreshRequest = {...req}; for (;;) { const resp = await this.listRefresh(signal, pageReq, options); @@ -397,27 +315,24 @@ export class Client { } } + /** * Update a data quality monitor on Unity Catalog object. - * + * * For the `table` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog. * 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema. * 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **MANAGE** on the table. - * + * * For the `schema` `object_type`, the caller must have either of the following sets of permissions: * 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog. * 2. **USE_CATALOG** on the schema's parent catalog, and **MANAGE** and **USE_SCHEMA** on the schema. */ - async updateMonitor( - signal: AbortSignal | undefined, - req: UpdateMonitorRequest, - options?: Options - ): Promise { + async updateMonitor(signal: AbortSignal | undefined, req: UpdateMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -425,11 +340,7 @@ export class Client { let resp: Monitor | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMonitorSchema); }; await execute(signal, call, options); @@ -440,15 +351,11 @@ export class Client { } /** (Unimplemented) Update a refresh */ - async updateRefresh( - signal: AbortSignal | undefined, - req: UpdateRefreshRequest, - options?: Options - ): Promise { + async updateRefresh(signal: AbortSignal | undefined, req: UpdateRefreshRequest, options?: Options): Promise { const url = `${this.host}/api/data-quality/v1/monitors/${req.objectType ?? ''}/${req.objectId ?? ''}/refreshes/${String(req.refreshId ?? '')}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -456,11 +363,7 @@ export class Client { let resp: Refresh | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRefreshSchema); }; await execute(signal, call, options); diff --git a/packages/dataquality/src/v1/index.ts b/packages/dataquality/src/v1/index.ts index af249d28..19326ebe 100644 --- a/packages/dataquality/src/v1/index.ts +++ b/packages/dataquality/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/dataquality/src/v1/model.ts b/packages/dataquality/src/v1/model.ts index aa5d5644..d95af989 100644 --- a/packages/dataquality/src/v1/model.ts +++ b/packages/dataquality/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** The granularity for aggregating data into time windows based on their timestamp. */ @@ -123,11 +124,11 @@ export interface CancelRefreshRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -260,11 +261,11 @@ export interface DeleteMonitorRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -278,11 +279,11 @@ export interface DeleteRefreshRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -298,11 +299,11 @@ export interface GetMonitorRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -316,11 +317,11 @@ export interface GetRefreshRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -366,11 +367,11 @@ export interface ListRefreshRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -392,11 +393,11 @@ export interface Monitor { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -445,11 +446,11 @@ export interface Refresh { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -492,11 +493,11 @@ export interface UpdateMonitorRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -508,7 +509,7 @@ export interface UpdateMonitorRequest { * 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 | undefined; + updateMask?: FieldMask> | undefined; } /** Request to update a refresh. */ @@ -517,11 +518,11 @@ export interface UpdateRefreshRequest { objectType?: string | undefined; /** * 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](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field. - * + * * Find the `table_id` from either: * 1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource. * 2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field. @@ -532,7 +533,7 @@ export interface UpdateRefreshRequest { /** The refresh to update. */ refresh?: Refresh | undefined; /** The field mask to specify which fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface ValidityCheckConfiguration { @@ -543,64 +544,57 @@ export interface ValidityCheckConfiguration { uniquenessValidityCheck?: UniquenessValidityCheck | undefined; } -export const unmarshalAnomalyDetectionConfigSchema: z.ZodType = - z - .object({ - anomaly_detection_workflow_id: z.number().optional(), - publish_health_indicator: z.boolean().optional(), - job_type: z.enum(AnomalyDetectionJobType).optional(), - excluded_table_full_names: z.array(z.string()).optional(), - validity_check_configurations: z - .array(z.lazy(() => unmarshalValidityCheckConfigurationSchema)) - .optional(), - }) - .transform(d => ({ - anomalyDetectionWorkflowId: d.anomaly_detection_workflow_id, - publishHealthIndicator: d.publish_health_indicator, - jobType: d.job_type, - excludedTableFullNames: d.excluded_table_full_names, - validityCheckConfigurations: d.validity_check_configurations, - })); - -export const unmarshalCancelRefreshRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - refresh_id: z.number().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - refreshId: d.refresh_id, - })); - -export const unmarshalCancelRefreshResponseSchema: z.ZodType = - z - .object({ - refresh: z.lazy(() => unmarshalRefreshSchema).optional(), - }) - .transform(d => ({ - refresh: d.refresh, - })); - -export const unmarshalCreateMonitorRequestSchema: z.ZodType = - z - .object({ - monitor: z.lazy(() => unmarshalMonitorSchema).optional(), - }) - .transform(d => ({ - monitor: d.monitor, - })); - -export const unmarshalCreateRefreshRequestSchema: z.ZodType = - z - .object({ - refresh: z.lazy(() => unmarshalRefreshSchema).optional(), - }) - .transform(d => ({ - refresh: d.refresh, - })); +export const unmarshalAnomalyDetectionConfigSchema: z.ZodType = z + .object({ + anomaly_detection_workflow_id: z.number().optional(), + publish_health_indicator: z.boolean().optional(), + job_type: z.enum(AnomalyDetectionJobType).optional(), + excluded_table_full_names: z.array(z.string()).optional(), + validity_check_configurations: z.array(z.lazy(() => unmarshalValidityCheckConfigurationSchema)).optional(), + }) + .transform(d => ({ + anomalyDetectionWorkflowId: d.anomaly_detection_workflow_id, + publishHealthIndicator: d.publish_health_indicator, + jobType: d.job_type, + excludedTableFullNames: d.excluded_table_full_names, + validityCheckConfigurations: d.validity_check_configurations, + })); + +export const unmarshalCancelRefreshRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + refresh_id: z.number().optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + refreshId: d.refresh_id, + })); + +export const unmarshalCancelRefreshResponseSchema: z.ZodType = z + .object({ + refresh: z.lazy(() => unmarshalRefreshSchema).optional(), + }) + .transform(d => ({ + refresh: d.refresh, + })); + +export const unmarshalCreateMonitorRequestSchema: z.ZodType = z + .object({ + monitor: z.lazy(() => unmarshalMonitorSchema).optional(), + }) + .transform(d => ({ + monitor: d.monitor, + })); + +export const unmarshalCreateRefreshRequestSchema: z.ZodType = z + .object({ + refresh: z.lazy(() => unmarshalRefreshSchema).optional(), + }) + .transform(d => ({ + refresh: d.refresh, + })); export const unmarshalCronScheduleSchema: z.ZodType = z .object({ @@ -614,97 +608,89 @@ export const unmarshalCronScheduleSchema: z.ZodType = z pauseStatus: d.pause_status, })); -export const unmarshalDataProfilingConfigSchema: z.ZodType = - z - .object({ - output_schema_id: z.string().optional(), - assets_dir: z.string().optional(), - inference_log: z.lazy(() => unmarshalInferenceLogConfigSchema).optional(), - time_series: z.lazy(() => unmarshalTimeSeriesConfigSchema).optional(), - snapshot: z.lazy(() => unmarshalSnapshotConfigSchema).optional(), - slicing_exprs: z.array(z.string()).optional(), - custom_metrics: z - .array(z.lazy(() => unmarshalDataProfilingCustomMetricSchema)) - .optional(), - baseline_table_name: z.string().optional(), - schedule: z.lazy(() => unmarshalCronScheduleSchema).optional(), - notification_settings: z - .lazy(() => unmarshalNotificationSettingsSchema) - .optional(), - skip_builtin_dashboard: z.boolean().optional(), - warehouse_id: z.string().optional(), - monitored_table_name: z.string().optional(), - status: z.enum(DataProfilingStatus).optional(), - latest_monitor_failure_message: z.string().optional(), - profile_metrics_table_name: z.string().optional(), - drift_metrics_table_name: z.string().optional(), - dashboard_id: z.string().optional(), - monitor_version: z.number().optional(), - effective_warehouse_id: z.string().optional(), - }) - .transform(d => ({ - outputSchemaId: d.output_schema_id, - assetsDir: d.assets_dir, - inferenceLog: d.inference_log, - timeSeries: d.time_series, - snapshot: d.snapshot, - slicingExprs: d.slicing_exprs, - customMetrics: d.custom_metrics, - baselineTableName: d.baseline_table_name, - schedule: d.schedule, - notificationSettings: d.notification_settings, - skipBuiltinDashboard: d.skip_builtin_dashboard, - warehouseId: d.warehouse_id, - monitoredTableName: d.monitored_table_name, - status: d.status, - latestMonitorFailureMessage: d.latest_monitor_failure_message, - profileMetricsTableName: d.profile_metrics_table_name, - driftMetricsTableName: d.drift_metrics_table_name, - dashboardId: d.dashboard_id, - monitorVersion: d.monitor_version, - effectiveWarehouseId: d.effective_warehouse_id, - })); - -export const unmarshalDataProfilingCustomMetricSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - definition: z.string().optional(), - input_columns: z.array(z.string()).optional(), - output_data_type: z.string().optional(), - type: z.enum(DataProfilingCustomMetricType).optional(), - }) - .transform(d => ({ - name: d.name, - definition: d.definition, - inputColumns: d.input_columns, - outputDataType: d.output_data_type, - type: d.type, - })); - -export const unmarshalDeleteMonitorRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - })); - -export const unmarshalDeleteRefreshRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - refresh_id: z.number().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - refreshId: d.refresh_id, - })); +export const unmarshalDataProfilingConfigSchema: z.ZodType = z + .object({ + output_schema_id: z.string().optional(), + assets_dir: z.string().optional(), + inference_log: z.lazy(() => unmarshalInferenceLogConfigSchema).optional(), + time_series: z.lazy(() => unmarshalTimeSeriesConfigSchema).optional(), + snapshot: z.lazy(() => unmarshalSnapshotConfigSchema).optional(), + slicing_exprs: z.array(z.string()).optional(), + custom_metrics: z.array(z.lazy(() => unmarshalDataProfilingCustomMetricSchema)).optional(), + baseline_table_name: z.string().optional(), + schedule: z.lazy(() => unmarshalCronScheduleSchema).optional(), + notification_settings: z.lazy(() => unmarshalNotificationSettingsSchema).optional(), + skip_builtin_dashboard: z.boolean().optional(), + warehouse_id: z.string().optional(), + monitored_table_name: z.string().optional(), + status: z.enum(DataProfilingStatus).optional(), + latest_monitor_failure_message: z.string().optional(), + profile_metrics_table_name: z.string().optional(), + drift_metrics_table_name: z.string().optional(), + dashboard_id: z.string().optional(), + monitor_version: z.number().optional(), + effective_warehouse_id: z.string().optional(), + }) + .transform(d => ({ + outputSchemaId: d.output_schema_id, + assetsDir: d.assets_dir, + inferenceLog: d.inference_log, + timeSeries: d.time_series, + snapshot: d.snapshot, + slicingExprs: d.slicing_exprs, + customMetrics: d.custom_metrics, + baselineTableName: d.baseline_table_name, + schedule: d.schedule, + notificationSettings: d.notification_settings, + skipBuiltinDashboard: d.skip_builtin_dashboard, + warehouseId: d.warehouse_id, + monitoredTableName: d.monitored_table_name, + status: d.status, + latestMonitorFailureMessage: d.latest_monitor_failure_message, + profileMetricsTableName: d.profile_metrics_table_name, + driftMetricsTableName: d.drift_metrics_table_name, + dashboardId: d.dashboard_id, + monitorVersion: d.monitor_version, + effectiveWarehouseId: d.effective_warehouse_id, + })); + +export const unmarshalDataProfilingCustomMetricSchema: z.ZodType = z + .object({ + name: z.string().optional(), + definition: z.string().optional(), + input_columns: z.array(z.string()).optional(), + output_data_type: z.string().optional(), + type: z.enum(DataProfilingCustomMetricType).optional(), + }) + .transform(d => ({ + name: d.name, + definition: d.definition, + inputColumns: d.input_columns, + outputDataType: d.output_data_type, + type: d.type, + })); + +export const unmarshalDeleteMonitorRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + })); + +export const unmarshalDeleteRefreshRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + refresh_id: z.number().optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + refreshId: d.refresh_id, + })); export const unmarshalGetMonitorRequestSchema: z.ZodType = z .object({ @@ -728,85 +714,76 @@ export const unmarshalGetRefreshRequestSchema: z.ZodType = z refreshId: d.refresh_id, })); -export const unmarshalInferenceLogConfigSchema: z.ZodType = - z - .object({ - problem_type: z.enum(InferenceProblemType).optional(), - timestamp_column: z.string().optional(), - granularities: z.array(z.enum(AggregationGranularity)).optional(), - prediction_column: z.string().optional(), - label_column: z.string().optional(), - model_id_column: z.string().optional(), - prediction_probability_column: z.string().optional(), - }) - .transform(d => ({ - problemType: d.problem_type, - timestampColumn: d.timestamp_column, - granularities: d.granularities, - predictionColumn: d.prediction_column, - labelColumn: d.label_column, - modelIdColumn: d.model_id_column, - predictionProbabilityColumn: d.prediction_probability_column, - })); - -export const unmarshalListMonitorRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListMonitorResponseSchema: z.ZodType = - z - .object({ - monitors: z.array(z.lazy(() => unmarshalMonitorSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - monitors: d.monitors, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListRefreshRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListRefreshResponseSchema: z.ZodType = - z - .object({ - refreshes: z.array(z.lazy(() => unmarshalRefreshSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - refreshes: d.refreshes, - nextPageToken: d.next_page_token, - })); +export const unmarshalInferenceLogConfigSchema: z.ZodType = z + .object({ + problem_type: z.enum(InferenceProblemType).optional(), + timestamp_column: z.string().optional(), + granularities: z.array(z.enum(AggregationGranularity)).optional(), + prediction_column: z.string().optional(), + label_column: z.string().optional(), + model_id_column: z.string().optional(), + prediction_probability_column: z.string().optional(), + }) + .transform(d => ({ + problemType: d.problem_type, + timestampColumn: d.timestamp_column, + granularities: d.granularities, + predictionColumn: d.prediction_column, + labelColumn: d.label_column, + modelIdColumn: d.model_id_column, + predictionProbabilityColumn: d.prediction_probability_column, + })); + +export const unmarshalListMonitorRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListMonitorResponseSchema: z.ZodType = z + .object({ + monitors: z.array(z.lazy(() => unmarshalMonitorSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + monitors: d.monitors, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListRefreshRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListRefreshResponseSchema: z.ZodType = z + .object({ + refreshes: z.array(z.lazy(() => unmarshalRefreshSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + refreshes: d.refreshes, + nextPageToken: d.next_page_token, + })); export const unmarshalMonitorSchema: z.ZodType = z .object({ object_type: z.string().optional(), object_id: z.string().optional(), - anomaly_detection_config: z - .lazy(() => unmarshalAnomalyDetectionConfigSchema) - .optional(), - data_profiling_config: z - .lazy(() => unmarshalDataProfilingConfigSchema) - .optional(), + anomaly_detection_config: z.lazy(() => unmarshalAnomalyDetectionConfigSchema).optional(), + data_profiling_config: z.lazy(() => unmarshalDataProfilingConfigSchema).optional(), }) .transform(d => ({ objectType: d.object_type, @@ -815,49 +792,43 @@ export const unmarshalMonitorSchema: z.ZodType = z dataProfilingConfig: d.data_profiling_config, })); -export const unmarshalNotificationDestinationSchema: z.ZodType = - z - .object({ - email_addresses: z.array(z.string()).optional(), - }) - .transform(d => ({ - emailAddresses: d.email_addresses, - })); - -export const unmarshalNotificationSettingsSchema: z.ZodType = - z - .object({ - on_failure: z - .lazy(() => unmarshalNotificationDestinationSchema) - .optional(), - }) - .transform(d => ({ - onFailure: d.on_failure, - })); - -export const unmarshalPercentNullValidityCheckSchema: z.ZodType = - z - .object({ - column_names: z.array(z.string()).optional(), - upper_bound: z.number().optional(), - }) - .transform(d => ({ - columnNames: d.column_names, - upperBound: d.upper_bound, - })); - -export const unmarshalRangeValidityCheckSchema: z.ZodType = - z - .object({ - column_names: z.array(z.string()).optional(), - lower_bound: z.number().optional(), - upper_bound: z.number().optional(), - }) - .transform(d => ({ - columnNames: d.column_names, - lowerBound: d.lower_bound, - upperBound: d.upper_bound, - })); +export const unmarshalNotificationDestinationSchema: z.ZodType = z + .object({ + email_addresses: z.array(z.string()).optional(), + }) + .transform(d => ({ + emailAddresses: d.email_addresses, + })); + +export const unmarshalNotificationSettingsSchema: z.ZodType = z + .object({ + on_failure: z.lazy(() => unmarshalNotificationDestinationSchema).optional(), + }) + .transform(d => ({ + onFailure: d.on_failure, + })); + +export const unmarshalPercentNullValidityCheckSchema: z.ZodType = z + .object({ + column_names: z.array(z.string()).optional(), + upper_bound: z.number().optional(), + }) + .transform(d => ({ + columnNames: d.column_names, + upperBound: d.upper_bound, + })); + +export const unmarshalRangeValidityCheckSchema: z.ZodType = z + .object({ + column_names: z.array(z.string()).optional(), + lower_bound: z.number().optional(), + upper_bound: z.number().optional(), + }) + .transform(d => ({ + columnNames: d.column_names, + lowerBound: d.lower_bound, + upperBound: d.upper_bound, + })); export const unmarshalRefreshSchema: z.ZodType = z .object({ @@ -881,8 +852,9 @@ export const unmarshalRefreshSchema: z.ZodType = z trigger: d.trigger, })); -export const unmarshalSnapshotConfigSchema: z.ZodType = - z.object({}); +export const unmarshalSnapshotConfigSchema: z.ZodType = z + .object({ + }); export const unmarshalTimeSeriesConfigSchema: z.ZodType = z .object({ @@ -894,67 +866,57 @@ export const unmarshalTimeSeriesConfigSchema: z.ZodType = z granularities: d.granularities, })); -export const unmarshalUniquenessValidityCheckSchema: z.ZodType = - z - .object({ - column_names: z.array(z.string()).optional(), - }) - .transform(d => ({ - columnNames: d.column_names, - })); - -export const unmarshalUpdateMonitorRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - monitor: z.lazy(() => unmarshalMonitorSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - monitor: d.monitor, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateRefreshRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - refresh_id: z.number().optional(), - refresh: z.lazy(() => unmarshalRefreshSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - refreshId: d.refresh_id, - refresh: d.refresh, - updateMask: d.update_mask, - })); - -export const unmarshalValidityCheckConfigurationSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - percent_null_validity_check: z - .lazy(() => unmarshalPercentNullValidityCheckSchema) - .optional(), - range_validity_check: z - .lazy(() => unmarshalRangeValidityCheckSchema) - .optional(), - uniqueness_validity_check: z - .lazy(() => unmarshalUniquenessValidityCheckSchema) - .optional(), - }) - .transform(d => ({ - name: d.name, - percentNullValidityCheck: d.percent_null_validity_check, - rangeValidityCheck: d.range_validity_check, - uniquenessValidityCheck: d.uniqueness_validity_check, - })); +export const unmarshalUniquenessValidityCheckSchema: z.ZodType = z + .object({ + column_names: z.array(z.string()).optional(), + }) + .transform(d => ({ + columnNames: d.column_names, + })); + +export const unmarshalUpdateMonitorRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + monitor: z.lazy(() => unmarshalMonitorSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + monitor: d.monitor, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateRefreshRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + refresh_id: z.number().optional(), + refresh: z.lazy(() => unmarshalRefreshSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + refreshId: d.refresh_id, + refresh: d.refresh, + updateMask: d.update_mask, + })); + +export const unmarshalValidityCheckConfigurationSchema: z.ZodType = z + .object({ + name: z.string().optional(), + percent_null_validity_check: z.lazy(() => unmarshalPercentNullValidityCheckSchema).optional(), + range_validity_check: z.lazy(() => unmarshalRangeValidityCheckSchema).optional(), + uniqueness_validity_check: z.lazy(() => unmarshalUniquenessValidityCheckSchema).optional(), + }) + .transform(d => ({ + name: d.name, + percentNullValidityCheck: d.percent_null_validity_check, + rangeValidityCheck: d.range_validity_check, + uniquenessValidityCheck: d.uniqueness_validity_check, + })); export const marshalAnomalyDetectionConfigSchema: z.ZodType = z .object({ @@ -962,9 +924,7 @@ export const marshalAnomalyDetectionConfigSchema: z.ZodType = z publishHealthIndicator: z.boolean().optional(), jobType: z.enum(AnomalyDetectionJobType).optional(), excludedTableFullNames: z.array(z.string()).optional(), - validityCheckConfigurations: z - .array(z.lazy(() => marshalValidityCheckConfigurationSchema)) - .optional(), + validityCheckConfigurations: z.array(z.lazy(() => marshalValidityCheckConfigurationSchema)).optional(), }) .transform(d => ({ anomaly_detection_workflow_id: d.anomalyDetectionWorkflowId, @@ -1030,14 +990,10 @@ export const marshalDataProfilingConfigSchema: z.ZodType = z timeSeries: z.lazy(() => marshalTimeSeriesConfigSchema).optional(), snapshot: z.lazy(() => marshalSnapshotConfigSchema).optional(), slicingExprs: z.array(z.string()).optional(), - customMetrics: z - .array(z.lazy(() => marshalDataProfilingCustomMetricSchema)) - .optional(), + customMetrics: z.array(z.lazy(() => marshalDataProfilingCustomMetricSchema)).optional(), baselineTableName: z.string().optional(), schedule: z.lazy(() => marshalCronScheduleSchema).optional(), - notificationSettings: z - .lazy(() => marshalNotificationSettingsSchema) - .optional(), + notificationSettings: z.lazy(() => marshalNotificationSettingsSchema).optional(), skipBuiltinDashboard: z.boolean().optional(), warehouseId: z.string().optional(), monitoredTableName: z.string().optional(), @@ -1200,12 +1156,8 @@ export const marshalMonitorSchema: z.ZodType = z .object({ objectType: z.string().optional(), objectId: z.string().optional(), - anomalyDetectionConfig: z - .lazy(() => marshalAnomalyDetectionConfigSchema) - .optional(), - dataProfilingConfig: z - .lazy(() => marshalDataProfilingConfigSchema) - .optional(), + anomalyDetectionConfig: z.lazy(() => marshalAnomalyDetectionConfigSchema).optional(), + dataProfilingConfig: z.lazy(() => marshalDataProfilingConfigSchema).optional(), }) .transform(d => ({ object_type: d.objectType, @@ -1274,7 +1226,9 @@ export const marshalRefreshSchema: z.ZodType = z trigger: d.trigger, })); -export const marshalSnapshotConfigSchema: z.ZodType = z.object({}); +export const marshalSnapshotConfigSchema: z.ZodType = z + .object({ + }); export const marshalTimeSeriesConfigSchema: z.ZodType = z .object({ @@ -1299,7 +1253,7 @@ export const marshalUpdateMonitorRequestSchema: z.ZodType = z objectType: z.string().optional(), objectId: z.string().optional(), monitor: z.lazy(() => marshalMonitorSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ object_type: d.objectType, @@ -1314,7 +1268,7 @@ export const marshalUpdateRefreshRequestSchema: z.ZodType = z objectId: z.string().optional(), refreshId: z.number().optional(), refresh: z.lazy(() => marshalRefreshSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ object_type: d.objectType, @@ -1327,15 +1281,9 @@ export const marshalUpdateRefreshRequestSchema: z.ZodType = z export const marshalValidityCheckConfigurationSchema: z.ZodType = z .object({ name: z.string().optional(), - percentNullValidityCheck: z - .lazy(() => marshalPercentNullValidityCheckSchema) - .optional(), - rangeValidityCheck: z - .lazy(() => marshalRangeValidityCheckSchema) - .optional(), - uniquenessValidityCheck: z - .lazy(() => marshalUniquenessValidityCheckSchema) - .optional(), + percentNullValidityCheck: z.lazy(() => marshalPercentNullValidityCheckSchema).optional(), + rangeValidityCheck: z.lazy(() => marshalRangeValidityCheckSchema).optional(), + uniquenessValidityCheck: z.lazy(() => marshalUniquenessValidityCheckSchema).optional(), }) .transform(d => ({ name: d.name, diff --git a/packages/dataquality/src/v1/utils.ts b/packages/dataquality/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/dataquality/src/v1/utils.ts +++ b/packages/dataquality/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/dataquality/tsconfig.json b/packages/dataquality/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/dataquality/tsconfig.json +++ b/packages/dataquality/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/entitytagassignments/package.json b/packages/entitytagassignments/package.json index 096eeffd..413ad78a 100644 --- a/packages/entitytagassignments/package.json +++ b/packages/entitytagassignments/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/entitytagassignments/src/v1/client.ts b/packages/entitytagassignments/src/v1/client.ts index 9f1138ea..17ee291b 100644 --- a/packages/entitytagassignments/src/v1/client.ts +++ b/packages/entitytagassignments/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateEntityTagAssignmentRequest, DeleteEntityTagAssignmentRequest, @@ -44,32 +39,21 @@ export class Client { /** * Creates a tag assignment for an Unity Catalog entity. - * + * * To add tags to Unity Catalog entities, you must own the entity or have the following privileges: * - **APPLY TAG** on the entity * - **USE SCHEMA** on the entity's parent schema * - **USE CATALOG** on the entity's parent catalog - * + * * To add a governed tag to Unity Catalog entities, you must also have the **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy permissions](https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions). */ - async createEntityTagAssignment( - signal: AbortSignal | undefined, - req: CreateEntityTagAssignmentRequest, - options?: Options - ): Promise { + async createEntityTagAssignment(signal: AbortSignal | undefined, req: CreateEntityTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments`; - const body = marshalRequest( - req.tagAssignment, - marshalEntityTagAssignmentSchema - ); + const body = marshalRequest(req.tagAssignment, marshalEntityTagAssignmentSchema); let resp: EntityTagAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEntityTagAssignmentSchema); }; await execute(signal, call, options); @@ -81,37 +65,25 @@ export class Client { /** * Deletes a tag assignment for an Unity Catalog entity by its key. - * + * * To delete tags from Unity Catalog entities, you must own the entity or have the following privileges: * - **APPLY TAG** on the entity * - **USE_SCHEMA** on the entity's parent schema * - **USE_CATALOG** on the entity's parent catalog - * + * * To delete a governed tag from Unity Catalog entities, you must also have the **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy permissions](https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions). */ - async deleteEntityTagAssignment( - signal: AbortSignal | undefined, - req: DeleteEntityTagAssignmentRequest, - options?: Options - ): Promise { + async deleteEntityTagAssignment(signal: AbortSignal | undefined, req: DeleteEntityTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.entityType ?? ''}/${req.entityName ?? ''}/tags/${req.tagKey ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Gets a tag assignment for an Unity Catalog entity by tag key. */ - async getEntityTagAssignment( - signal: AbortSignal | undefined, - req: GetEntityTagAssignmentRequest, - options?: Options - ): Promise { + async getEntityTagAssignment(signal: AbortSignal | undefined, req: GetEntityTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.entityType ?? ''}/${req.entityName ?? ''}/tags/${req.tagKey ?? ''}`; const params = new URLSearchParams(); if (req.includeInherited !== undefined) { @@ -122,11 +94,7 @@ export class Client { let resp: EntityTagAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEntityTagAssignmentSchema); }; await execute(signal, call, options); @@ -138,15 +106,11 @@ export class Client { /** * List tag assignments for an Unity Catalog entity - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listEntityTagAssignments( - signal: AbortSignal | undefined, - req: ListEntityTagAssignmentsRequest, - options?: Options - ): Promise { + async listEntityTagAssignments(signal: AbortSignal | undefined, req: ListEntityTagAssignmentsRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.entityType ?? ''}/${req.entityName ?? ''}/tags`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -163,15 +127,8 @@ export class Client { let resp: ListEntityTagAssignmentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListEntityTagAssignmentsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListEntityTagAssignmentsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -180,18 +137,11 @@ export class Client { return resp; } - async *listEntityTagAssignmentsIter( - signal: AbortSignal | undefined, - req: ListEntityTagAssignmentsRequest, - options?: Options - ): AsyncGenerator { + + async *listEntityTagAssignmentsIter(signal: AbortSignal | undefined, req: ListEntityTagAssignmentsRequest, options?: Options): AsyncGenerator { const pageReq: ListEntityTagAssignmentsRequest = {...req}; for (;;) { - const resp = await this.listEntityTagAssignments( - signal, - pageReq, - options - ); + const resp = await this.listEntityTagAssignments(signal, pageReq, options); for (const item of resp.tagAssignments ?? []) { yield item; } @@ -202,40 +152,30 @@ export class Client { } } + /** * Updates an existing tag assignment for an Unity Catalog entity. - * + * * To update tags to Unity Catalog entities, you must own the entity or have the following privileges: * - **APPLY TAG** on the entity * - **USE SCHEMA** on the entity's parent schema * - **USE CATALOG** on the entity's parent catalog - * + * * To update a governed tag to Unity Catalog entities, you must also have the **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy permissions](https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions). */ - async updateEntityTagAssignment( - signal: AbortSignal | undefined, - req: UpdateEntityTagAssignmentRequest, - options?: Options - ): Promise { + async updateEntityTagAssignment(signal: AbortSignal | undefined, req: UpdateEntityTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.tagAssignment?.entityType ?? ''}/${req.tagAssignment?.entityName ?? ''}/tags/${req.tagAssignment?.tagKey ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.tagAssignment, - marshalEntityTagAssignmentSchema - ); + const body = marshalRequest(req.tagAssignment, marshalEntityTagAssignmentSchema); let resp: EntityTagAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEntityTagAssignmentSchema); }; await execute(signal, call, options); diff --git a/packages/entitytagassignments/src/v1/index.ts b/packages/entitytagassignments/src/v1/index.ts index 5c776a23..47b893bb 100644 --- a/packages/entitytagassignments/src/v1/index.ts +++ b/packages/entitytagassignments/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {TagAssignmentSourceType} from './model'; +export { + TagAssignmentSourceType, +} from './model'; export type { CreateEntityTagAssignmentRequest, diff --git a/packages/entitytagassignments/src/v1/model.ts b/packages/entitytagassignments/src/v1/model.ts index b6f5ebe3..90ac8c99 100644 --- a/packages/entitytagassignments/src/v1/model.ts +++ b/packages/entitytagassignments/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** Enum representing the source type of a tag assignment */ @@ -82,116 +84,100 @@ export interface ListEntityTagAssignmentsResponse { /** Request to update an entity tag assignment */ export interface UpdateEntityTagAssignmentRequest { tagAssignment?: EntityTagAssignment | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } -export const unmarshalCreateEntityTagAssignmentRequestSchema: z.ZodType = - z - .object({ - tag_assignment: z - .lazy(() => unmarshalEntityTagAssignmentSchema) - .optional(), - }) - .transform(d => ({ - tagAssignment: d.tag_assignment, - })); +export const unmarshalCreateEntityTagAssignmentRequestSchema: z.ZodType = z + .object({ + tag_assignment: z.lazy(() => unmarshalEntityTagAssignmentSchema).optional(), + }) + .transform(d => ({ + tagAssignment: d.tag_assignment, + })); -export const unmarshalDeleteEntityTagAssignmentRequestSchema: z.ZodType = - z - .object({ - entity_name: z.string().optional(), - tag_key: z.string().optional(), - entity_type: z.string().optional(), - }) - .transform(d => ({ - entityName: d.entity_name, - tagKey: d.tag_key, - entityType: d.entity_type, - })); +export const unmarshalDeleteEntityTagAssignmentRequestSchema: z.ZodType = z + .object({ + entity_name: z.string().optional(), + tag_key: z.string().optional(), + entity_type: z.string().optional(), + }) + .transform(d => ({ + entityName: d.entity_name, + tagKey: d.tag_key, + entityType: d.entity_type, + })); -export const unmarshalEntityTagAssignmentSchema: z.ZodType = - z - .object({ - entity_name: z.string().optional(), - tag_key: z.string().optional(), - tag_value: z.string().optional(), - entity_type: z.string().optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - updated_by: z.string().optional(), - source_type: z.enum(TagAssignmentSourceType).optional(), - inherited: z.boolean().optional(), - }) - .transform(d => ({ - entityName: d.entity_name, - tagKey: d.tag_key, - tagValue: d.tag_value, - entityType: d.entity_type, - updateTime: d.update_time, - updatedBy: d.updated_by, - sourceType: d.source_type, - inherited: d.inherited, - })); +export const unmarshalEntityTagAssignmentSchema: z.ZodType = z + .object({ + entity_name: z.string().optional(), + tag_key: z.string().optional(), + tag_value: z.string().optional(), + entity_type: z.string().optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + updated_by: z.string().optional(), + source_type: z.enum(TagAssignmentSourceType).optional(), + inherited: z.boolean().optional(), + }) + .transform(d => ({ + entityName: d.entity_name, + tagKey: d.tag_key, + tagValue: d.tag_value, + entityType: d.entity_type, + updateTime: d.update_time, + updatedBy: d.updated_by, + sourceType: d.source_type, + inherited: d.inherited, + })); -export const unmarshalGetEntityTagAssignmentRequestSchema: z.ZodType = - z - .object({ - entity_name: z.string().optional(), - tag_key: z.string().optional(), - entity_type: z.string().optional(), - include_inherited: z.boolean().optional(), - }) - .transform(d => ({ - entityName: d.entity_name, - tagKey: d.tag_key, - entityType: d.entity_type, - includeInherited: d.include_inherited, - })); +export const unmarshalGetEntityTagAssignmentRequestSchema: z.ZodType = z + .object({ + entity_name: z.string().optional(), + tag_key: z.string().optional(), + entity_type: z.string().optional(), + include_inherited: z.boolean().optional(), + }) + .transform(d => ({ + entityName: d.entity_name, + tagKey: d.tag_key, + entityType: d.entity_type, + includeInherited: d.include_inherited, + })); -export const unmarshalListEntityTagAssignmentsRequestSchema: z.ZodType = - z - .object({ - entity_name: z.string().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - entity_type: z.string().optional(), - include_inherited: z.boolean().optional(), - }) - .transform(d => ({ - entityName: d.entity_name, - maxResults: d.max_results, - pageToken: d.page_token, - entityType: d.entity_type, - includeInherited: d.include_inherited, - })); +export const unmarshalListEntityTagAssignmentsRequestSchema: z.ZodType = z + .object({ + entity_name: z.string().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + entity_type: z.string().optional(), + include_inherited: z.boolean().optional(), + }) + .transform(d => ({ + entityName: d.entity_name, + maxResults: d.max_results, + pageToken: d.page_token, + entityType: d.entity_type, + includeInherited: d.include_inherited, + })); -export const unmarshalListEntityTagAssignmentsResponseSchema: z.ZodType = - z - .object({ - tag_assignments: z - .array(z.lazy(() => unmarshalEntityTagAssignmentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - tagAssignments: d.tag_assignments, - nextPageToken: d.next_page_token, - })); +export const unmarshalListEntityTagAssignmentsResponseSchema: z.ZodType = z + .object({ + tag_assignments: z.array(z.lazy(() => unmarshalEntityTagAssignmentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + tagAssignments: d.tag_assignments, + nextPageToken: d.next_page_token, + })); -export const unmarshalUpdateEntityTagAssignmentRequestSchema: z.ZodType = - z - .object({ - tag_assignment: z - .lazy(() => unmarshalEntityTagAssignmentSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - tagAssignment: d.tag_assignment, - updateMask: d.update_mask, - })); +export const unmarshalUpdateEntityTagAssignmentRequestSchema: z.ZodType = z + .object({ + tag_assignment: z.lazy(() => unmarshalEntityTagAssignmentSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + tagAssignment: d.tag_assignment, + updateMask: d.update_mask, + })); export const marshalCreateEntityTagAssignmentRequestSchema: z.ZodType = z .object({ @@ -219,10 +205,7 @@ export const marshalEntityTagAssignmentSchema: z.ZodType = z tagKey: z.string().optional(), tagValue: z.string().optional(), entityType: z.string().optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), updatedBy: z.string().optional(), sourceType: z.enum(TagAssignmentSourceType).optional(), inherited: z.boolean().optional(), @@ -270,9 +253,7 @@ export const marshalListEntityTagAssignmentsRequestSchema: z.ZodType = z export const marshalListEntityTagAssignmentsResponseSchema: z.ZodType = z .object({ - tagAssignments: z - .array(z.lazy(() => marshalEntityTagAssignmentSchema)) - .optional(), + tagAssignments: z.array(z.lazy(() => marshalEntityTagAssignmentSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -283,7 +264,7 @@ export const marshalListEntityTagAssignmentsResponseSchema: z.ZodType = z export const marshalUpdateEntityTagAssignmentRequestSchema: z.ZodType = z .object({ tagAssignment: z.lazy(() => marshalEntityTagAssignmentSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ tag_assignment: d.tagAssignment, diff --git a/packages/entitytagassignments/src/v1/utils.ts b/packages/entitytagassignments/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/entitytagassignments/src/v1/utils.ts +++ b/packages/entitytagassignments/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/entitytagassignments/tsconfig.json b/packages/entitytagassignments/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/entitytagassignments/tsconfig.json +++ b/packages/entitytagassignments/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/environments/package.json b/packages/environments/package.json index e9a5c99c..855ffbf3 100644 --- a/packages/environments/package.json +++ b/packages/environments/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/environments/src/v1/client.ts b/packages/environments/src/v1/client.ts index c38238c6..85b46d73 100644 --- a/packages/environments/src/v1/client.ts +++ b/packages/environments/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import {z} from 'zod'; import type { CreateWorkspaceBaseEnvironmentRequest, @@ -61,36 +56,22 @@ export class Client { * to optimize dependency resolution and is only marked as done when the materialized environment has been * successfully generated or has failed. */ - async createWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: CreateWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async createWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: CreateWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/workspace-base-environments`; const params = new URLSearchParams(); if (req.workspaceBaseEnvironmentId !== undefined) { - params.append( - 'workspace_base_environment_id', - req.workspaceBaseEnvironmentId - ); + params.append('workspace_base_environment_id', req.workspaceBaseEnvironmentId); } if (req.requestId !== undefined) { params.append('request_id', req.requestId); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.workspaceBaseEnvironment, - marshalWorkspaceBaseEnvironmentSchema - ); + const body = marshalRequest(req.workspaceBaseEnvironment, marshalWorkspaceBaseEnvironmentSchema); let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -100,33 +81,25 @@ export class Client { return resp; } - async createWorkspaceBaseEnvironmentOperation( - signal: AbortSignal | undefined, - req: CreateWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { - const op = await this.createWorkspaceBaseEnvironment(signal, req, options); - return new CreateWorkspaceBaseEnvironmentOperation(this, op); - } +async createWorkspaceBaseEnvironmentOperation( + signal: AbortSignal | undefined, + req: CreateWorkspaceBaseEnvironmentRequest, + options?: Options +): Promise { + const op = await this.createWorkspaceBaseEnvironment(signal, req, options); + return new CreateWorkspaceBaseEnvironmentOperation(this, op); +} /** * Deletes a WorkspaceBaseEnvironment. * Deleting a base environment may impact linked notebooks and jobs. * This operation is irreversible and should be performed only when you are certain the environment is no longer needed. */ - async deleteWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: DeleteWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async deleteWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: DeleteWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.name ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } @@ -135,24 +108,13 @@ export class Client { * Gets the default WorkspaceBaseEnvironment configuration for the workspace. * Returns the current default base environment settings for both CPU and GPU compute. */ - async getDefaultWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: GetDefaultWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async getDefaultWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: GetDefaultWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.name ?? ''}`; let resp: DefaultWorkspaceBaseEnvironment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDefaultWorkspaceBaseEnvironmentSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDefaultWorkspaceBaseEnvironmentSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -165,20 +127,12 @@ export class Client { * Gets the status of a long-running operation. * Clients can use this method to poll the operation result. */ - async getOperation( - signal: AbortSignal | undefined, - req: GetOperationRequest, - options?: Options - ): Promise { + async getOperation(signal: AbortSignal | undefined, req: GetOperationRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.name ?? ''}`; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -189,20 +143,12 @@ export class Client { } /** Retrieves a WorkspaceBaseEnvironment by its name. */ - async getWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: GetWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async getWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: GetWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.name ?? ''}`; let resp: WorkspaceBaseEnvironment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceBaseEnvironmentSchema); }; await execute(signal, call, options); @@ -213,11 +159,7 @@ export class Client { } /** Lists all WorkspaceBaseEnvironments in the workspace. */ - async listWorkspaceBaseEnvironments( - signal: AbortSignal | undefined, - req: ListWorkspaceBaseEnvironmentsRequest, - options?: Options - ): Promise { + async listWorkspaceBaseEnvironments(signal: AbortSignal | undefined, req: ListWorkspaceBaseEnvironmentsRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/workspace-base-environments`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -231,15 +173,8 @@ export class Client { let resp: ListWorkspaceBaseEnvironmentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWorkspaceBaseEnvironmentsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspaceBaseEnvironmentsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -248,18 +183,11 @@ export class Client { return resp; } - async *listWorkspaceBaseEnvironmentsIter( - signal: AbortSignal | undefined, - req: ListWorkspaceBaseEnvironmentsRequest, - options?: Options - ): AsyncGenerator { + + async *listWorkspaceBaseEnvironmentsIter(signal: AbortSignal | undefined, req: ListWorkspaceBaseEnvironmentsRequest, options?: Options): AsyncGenerator { const pageReq: ListWorkspaceBaseEnvironmentsRequest = {...req}; for (;;) { - const resp = await this.listWorkspaceBaseEnvironments( - signal, - pageReq, - options - ); + const resp = await this.listWorkspaceBaseEnvironments(signal, pageReq, options); for (const item of resp.workspaceBaseEnvironments ?? []) { yield item; } @@ -270,30 +198,20 @@ export class Client { } } + /** * Refreshes the materialized environment for a WorkspaceBaseEnvironment. * This is a long-running operation. The operation will asynchronously regenerate the materialized environment * and is only marked as done when the materialized environment has been successfully generated or has failed. * The existing materialized environment remains available until it expires. */ - async refreshWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: RefreshWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async refreshWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: RefreshWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.name ?? ''}/refresh`; - const body = marshalRequest( - req, - marshalRefreshWorkspaceBaseEnvironmentRequestSchema - ); + const body = marshalRequest(req, marshalRefreshWorkspaceBaseEnvironmentRequestSchema); let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -303,47 +221,33 @@ export class Client { return resp; } - async refreshWorkspaceBaseEnvironmentOperation( - signal: AbortSignal | undefined, - req: RefreshWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { - const op = await this.refreshWorkspaceBaseEnvironment(signal, req, options); - return new RefreshWorkspaceBaseEnvironmentOperation(this, op); - } +async refreshWorkspaceBaseEnvironmentOperation( + signal: AbortSignal | undefined, + req: RefreshWorkspaceBaseEnvironmentRequest, + options?: Options +): Promise { + const op = await this.refreshWorkspaceBaseEnvironment(signal, req, options); + return new RefreshWorkspaceBaseEnvironmentOperation(this, op); +} /** * Updates the default WorkspaceBaseEnvironment configuration for the workspace. * Sets the specified base environments as the workspace defaults for CPU and/or GPU compute. */ - async updateDefaultWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: UpdateDefaultWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async updateDefaultWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: UpdateDefaultWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.defaultWorkspaceBaseEnvironment?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.defaultWorkspaceBaseEnvironment, - marshalDefaultWorkspaceBaseEnvironmentSchema - ); + const body = marshalRequest(req.defaultWorkspaceBaseEnvironment, marshalDefaultWorkspaceBaseEnvironmentSchema); let resp: DefaultWorkspaceBaseEnvironment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDefaultWorkspaceBaseEnvironmentSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDefaultWorkspaceBaseEnvironmentSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -358,24 +262,13 @@ export class Client { * and is only marked as done when the materialized environment has been successfully generated or has failed. * The existing materialized environment remains available until it expires. */ - async updateWorkspaceBaseEnvironment( - signal: AbortSignal | undefined, - req: UpdateWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { + async updateWorkspaceBaseEnvironment(signal: AbortSignal | undefined, req: UpdateWorkspaceBaseEnvironmentRequest, options?: Options): Promise { const url = `${this.host}/api/environments/v1/${req.name ?? ''}`; - const body = marshalRequest( - req.workspaceBaseEnvironment, - marshalWorkspaceBaseEnvironmentSchema - ); + const body = marshalRequest(req.workspaceBaseEnvironment, marshalWorkspaceBaseEnvironmentSchema); let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -385,14 +278,14 @@ export class Client { return resp; } - async updateWorkspaceBaseEnvironmentOperation( - signal: AbortSignal | undefined, - req: UpdateWorkspaceBaseEnvironmentRequest, - options?: Options - ): Promise { - const op = await this.updateWorkspaceBaseEnvironment(signal, req, options); - return new UpdateWorkspaceBaseEnvironmentOperation(this, op); - } +async updateWorkspaceBaseEnvironmentOperation( + signal: AbortSignal | undefined, + req: UpdateWorkspaceBaseEnvironmentRequest, + options?: Options +): Promise { + const op = await this.updateWorkspaceBaseEnvironment(signal, req, options); + return new UpdateWorkspaceBaseEnvironmentOperation(this, op); +} } export class CreateWorkspaceBaseEnvironmentOperation { @@ -412,9 +305,7 @@ export class CreateWorkspaceBaseEnvironmentOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -464,9 +355,7 @@ export class CreateWorkspaceBaseEnvironmentOperation { throw new Error('operation completed without a response'); } - result = z - .lazy(() => unmarshalWorkspaceBaseEnvironmentSchema) - .parse(op.response); + result = z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).parse(op.response); }; const retryOptions: Options = { @@ -514,9 +403,7 @@ export class RefreshWorkspaceBaseEnvironmentOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -566,9 +453,7 @@ export class RefreshWorkspaceBaseEnvironmentOperation { throw new Error('operation completed without a response'); } - result = z - .lazy(() => unmarshalWorkspaceBaseEnvironmentSchema) - .parse(op.response); + result = z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).parse(op.response); }; const retryOptions: Options = { @@ -616,9 +501,7 @@ export class UpdateWorkspaceBaseEnvironmentOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -668,9 +551,7 @@ export class UpdateWorkspaceBaseEnvironmentOperation { throw new Error('operation completed without a response'); } - result = z - .lazy(() => unmarshalWorkspaceBaseEnvironmentSchema) - .parse(op.response); + result = z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).parse(op.response); }; const retryOptions: Options = { diff --git a/packages/environments/src/v1/index.ts b/packages/environments/src/v1/index.ts index 01bc550a..9c079e44 100644 --- a/packages/environments/src/v1/index.ts +++ b/packages/environments/src/v1/index.ts @@ -1,11 +1,7 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. -export { - Client, - CreateWorkspaceBaseEnvironmentOperation, - RefreshWorkspaceBaseEnvironmentOperation, - UpdateWorkspaceBaseEnvironmentOperation, -} from './client'; + +export {Client, CreateWorkspaceBaseEnvironmentOperation, RefreshWorkspaceBaseEnvironmentOperation, UpdateWorkspaceBaseEnvironmentOperation} from './client'; export { BaseEnvironmentType, diff --git a/packages/environments/src/v1/model.ts b/packages/environments/src/v1/model.ts index 097dfe7e..641b43e9 100644 --- a/packages/environments/src/v1/model.ts +++ b/packages/environments/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** If changed, also update estore/namespaces/defaultbaseenvironments/latest.proto */ @@ -15,10 +17,10 @@ export enum ErrorCode { /** * Unknown error. This error generally should not be returned explicitly, but will be used * as a fallback if the error enum is missing from the message for some reason. - * + * * It's assigned tag 0 to follow the best practice from * https://developers.google.com/protocol-buffers/docs/style#enums - * + * * TODO(PLAT-55898): Add custom option to declare HTTP and gRPC mappings. * Maps to: * - google.rpc.Code: UNKNOWN = 2; @@ -29,10 +31,10 @@ export enum ErrorCode { * Internal error. This means that some invariants expected by the underlying system have been * broken. This error code is reserved for serious errors, which generally cannot be resolved * by the user. - * + * * Prefer this over all kinds of detailed error messages (e.g IO_ERROR), unless there's some * automation that relies on the custom error code. - * + * * Maps to: * - google.rpc.Code: INTERNAL = 13; * - HTTP code: 500 Internal Server Error @@ -42,12 +44,12 @@ export enum ErrorCode { * The service is currently unavailable. This is most likely a transient condition, which can be * corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent * operations. - * + * * Prefer this over SERVICE_UNDER_MAINTENANCE, WORKSPACE_TEMPORARILY_UNAVAILABLE. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on how to pick this vs RESOURCE_EXHAUSTED. - * + * * Maps to: * - google.rpc.Code: UNAVAILABLE = 14; * - HTTP code: 503 Service Unavailable @@ -62,9 +64,9 @@ export enum ErrorCode { /** * The request is invalid. Prefer more specific error code whenever possible. * Also see similar recommendation for the google.rpc.Code.FAILED_PRECONDITION. - * + * * Prefer this error code over MALFORMED_REQUEST, INVALID_STATE, UNPARSEABLE_HTTP_ERROR. - * + * * Maps to: * - google.rpc.Code: FAILED_PRECONDITION = 9; * - HTTP code: 400 Bad Request @@ -84,7 +86,7 @@ export enum ErrorCode { * the deadline to expire. When possible - implementations should make sure further processing of * the request is aborted, e.g. by throwing an exception instead of making the RPC request, * making the database query, etc. - * + * * Maps to: * - google.rpc.Code: DEADLINE_EXCEEDED = 4; * - HTTP code: 504 Gateway Timeout @@ -93,7 +95,7 @@ export enum ErrorCode { /** * The operation was canceled by the caller. An example - client closed the connection without * waiting for a response. - * + * * Maps to: * - google.rpc.Code: CANCELLED = 1; * - HTTP code: 499 Client Closed Request @@ -103,10 +105,10 @@ export enum ErrorCode { * The operation is rejected because of either rate limiting or resource quota, * such as the client has sent too many requests recently or the client has allocated too many * resources. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on how to pick this vs TEMPORARILY_UNAVAILABLE. - * + * * Maps to: * - google.rpc.Code: RESOURCE_EXHAUSTED = 8; * - HTTP code: 429 Too Many Requests @@ -115,7 +117,7 @@ export enum ErrorCode { /** * The operation was aborted, typically due to a concurrency issue such as a sequencer * check failure, transaction abort, or transaction conflict. - * + * * Maps to: * - google.rpc.Code: ABORTED = 10; * - HTTP code: 409 Conflict @@ -124,7 +126,7 @@ export enum ErrorCode { /** * Operation was performed on a resource that does not exist, * e.g. file or directory was not found. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -133,9 +135,9 @@ export enum ErrorCode { /** * Operation was rejected due a conflict with an existing resource, e.g. attempted to create * file or directory that already exists. - * + * * Prefer this over RESOURCE_CONFLICT. - * + * * Maps to: * - google.rpc.Code: ALREADY_EXISTS = 6; * - HTTP code: 409 Conflict @@ -143,11 +145,11 @@ export enum ErrorCode { ALREADY_EXISTS = 'ALREADY_EXISTS', /** * The request does not have valid authentication (AuthN) credentials for the operation. - * + * * Prefer this over CUSTOMER_UNAUTHORIZED, unless you need to keep consistent behavior with legacy * code. * For authorization (AuthZ) errors use PERMISSION_DENIED. - * + * * Maps to: * - google.rpc.Code: UNAUTHENTICATED = 16; * - HTTP code: 401 Unauthorized @@ -162,7 +164,7 @@ export enum ErrorCode { * not know whether it is because the domain name is completely wrong (non-transient situation) or * the domain name is valid but the DNS server does not have an entry for this domain name yet (transient * situation). Hence, `UNAVAILABLE` is suitable for this case. - * + * * Maps to: * - google.rpc.Code: UNAVAILABLE = 14; * - HTTP code: 503 Service Unavailable @@ -170,7 +172,7 @@ export enum ErrorCode { UNAVAILABLE = 'UNAVAILABLE', /** * Supplied value for a parameter was invalid (e.g., giving a number for a string parameter). - * + * * Maps to: * - google.rpc.Code: INVALID_ARGUMENT = 3; * - HTTP code: 400 Bad Request @@ -179,7 +181,7 @@ export enum ErrorCode { /** * Indicates that the given API endpoint does not exist. Legacy, when possible - NOT_IMPLEMENTED * should be used instead to indicate that API doesn't exist. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -201,7 +203,7 @@ export enum ErrorCode { * use CUSTOMER_UNAUTHORIZED instead for those errors. * This error code does not imply the request is valid or the requested entity exists or * satisfies other pre-conditions. - * + * * Maps to: * - google.rpc.Code: PERMISSION_DENIED = 7; * - HTTP code: 403 Forbidden @@ -211,9 +213,9 @@ export enum ErrorCode { * NOTE: Deprecated due to inconsistent mapping in legacy code, see * https://docs.google.com/document/d/17TZIKX_Y39cJMBr333lc-d5dTvvBLSu3DPUyGU5eMJg/edit?disco=AAAAzVGt6FA. * Prefer using NOT_FOUND or PERMISSION_DENIED. - * + * * If a given user/entity is trying to use a feature which has been disabled. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -221,20 +223,20 @@ export enum ErrorCode { FEATURE_DISABLED = 'FEATURE_DISABLED', /** * The request does not have valid authentication (AuthN) credentials for the operation. - * + * * For authentication (AuthN) errors prefer using UNAUTHENTICATED, unless you need to keep * consistent behavior with legacy code. * For authorization (AuthZ) errors use PERMISSION_DENIED. - * + * * Important: name is confusing, this error code is for authentication (AuthN) errors, not * authorization (AuthZ) errors. It maps to 401 Unauthorized and suffers from the same confusing * naming. See https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 - "[...] status code * indicates that the request has not been applied because it lacks valid authentication * credentials for the target resource. [...] If the request included authentication credentials, * then the 401 response indicates that authorization has been refused for those credentials." - * + * * Also, see https://stackoverflow.com/a/6937030/16352922, it covers it pretty well. - * + * * Maps to: * - google.rpc.Code: UNAUTHENTICATED = 16; * - HTTP code: 401 Unauthorized @@ -243,12 +245,12 @@ export enum ErrorCode { /** * The operation is rejected because of request rate limit, for example rate limiting applied to * users, workspaces, IP addresses, etc. - * + * * Prefer a more generic RESOURCE_EXHAUSTED for the new use cases. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on the rate limiting vs throttling. - * + * * Maps to: * - google.rpc.Code: RESOURCE_EXHAUSTED = 8; * - HTTP code: 429 Too Many Requests @@ -265,7 +267,7 @@ export enum ErrorCode { UNPARSEABLE_HTTP_ERROR = 'UNPARSEABLE_HTTP_ERROR', /** * The operation is not implemented or is not supported/enabled in this service. - * + * * Maps to: * - google.rpc.Code: UNIMPLEMENTED = 12; * - HTTP code: 501 Not Implemented @@ -273,14 +275,14 @@ export enum ErrorCode { NOT_IMPLEMENTED = 'NOT_IMPLEMENTED', /** * Unrecoverable data loss or corruption. - * + * * One of the major use cases is to indicate that server failed to validate the integrity of * the request. This error can occur when the checksum specified in the `X-Databricks-Checksum` * request header (or trailer) doesn't match the actual request content checksum. - * + * * Note, in case of the severe corruption that results in a malformed request, the server may * send a generic `400 Bad Request` response rather than sending this error code. - * + * * Maps to: * - google.rpc.Code: DATA_LOSS = 15; * - HTTP code: 500 Internal Server Error @@ -298,7 +300,7 @@ export enum ErrorCode { * NOTE: Deprecated, prefer using ALREADY_EXISTS. * Unlike ALREADY_EXISTS - this maps to HTTP code 400 Bad Request due to legacy reasons, * remapping will be a backwards incompatible change. - * + * * Operation was performed on a resource that already exists. */ RESOURCE_ALREADY_EXISTS = 'RESOURCE_ALREADY_EXISTS', @@ -306,7 +308,7 @@ export enum ErrorCode { * NOTE: Deprecated, prefer using NOT_FOUND - see the note for the RESOURCE_ALREADY_EXISTS, * because this pair of codes is related and RESOURCE_ALREADY_EXISTS has bad mapping to the HTTP * codes we added new error codes NOT_FOUND and ALREADY_EXISTS, and recommend to use them instead. - * + * * Operation was performed on a resource that does not exist. */ RESOURCE_DOES_NOT_EXIST = 'RESOURCE_DOES_NOT_EXIST', @@ -687,11 +689,11 @@ export interface UpdateDefaultWorkspaceBaseEnvironmentRequest { * 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 | undefined; + updateMask?: FieldMask> | undefined; } /** Request message for UpdateWorkspaceBaseEnvironment. */ @@ -749,117 +751,102 @@ export interface WorkspaceBaseEnvironmentCache {} // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface WorkspaceBaseEnvironmentOperationMetadata {} -export const unmarshalCreateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - workspace_base_environment: z - .lazy(() => unmarshalWorkspaceBaseEnvironmentSchema) - .optional(), - workspace_base_environment_id: z.string().optional(), - request_id: z.string().optional(), - }) - .transform(d => ({ - workspaceBaseEnvironment: d.workspace_base_environment, - workspaceBaseEnvironmentId: d.workspace_base_environment_id, - requestId: d.request_id, - })); +export const unmarshalCreateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + workspace_base_environment: z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).optional(), + workspace_base_environment_id: z.string().optional(), + request_id: z.string().optional(), + }) + .transform(d => ({ + workspaceBaseEnvironment: d.workspace_base_environment, + workspaceBaseEnvironmentId: d.workspace_base_environment_id, + requestId: d.request_id, + })); -export const unmarshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = - z - .object({ - error_code: z.enum(ErrorCode).optional(), - message: z.string().optional(), - stack_trace: z.string().optional(), - details: z.array(z.record(z.string(), z.unknown())).optional(), - }) - .transform(d => ({ - errorCode: d.error_code, - message: d.message, - stackTrace: d.stack_trace, - details: d.details, - })); +export const unmarshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = z + .object({ + error_code: z.enum(ErrorCode).optional(), + message: z.string().optional(), + stack_trace: z.string().optional(), + details: z.array(z.record(z.string(), z.unknown())).optional(), + }) + .transform(d => ({ + errorCode: d.error_code, + message: d.message, + stackTrace: d.stack_trace, + details: d.details, + })); -export const unmarshalDefaultWorkspaceBaseEnvironmentSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - cpu_workspace_base_environment: z.string().optional(), - gpu_workspace_base_environment: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - cpuWorkspaceBaseEnvironment: d.cpu_workspace_base_environment, - gpuWorkspaceBaseEnvironment: d.gpu_workspace_base_environment, - })); +export const unmarshalDefaultWorkspaceBaseEnvironmentSchema: z.ZodType = z + .object({ + name: z.string().optional(), + cpu_workspace_base_environment: z.string().optional(), + gpu_workspace_base_environment: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + cpuWorkspaceBaseEnvironment: d.cpu_workspace_base_environment, + gpuWorkspaceBaseEnvironment: d.gpu_workspace_base_environment, + })); -export const unmarshalDeleteWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalDeleteWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); -export const unmarshalGetDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalGetDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); -export const unmarshalGetOperationRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalGetOperationRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); -export const unmarshalGetWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalGetWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); -export const unmarshalListWorkspaceBaseEnvironmentsRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); +export const unmarshalListWorkspaceBaseEnvironmentsRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + })); -export const unmarshalListWorkspaceBaseEnvironmentsResponseSchema: z.ZodType = - z - .object({ - workspace_base_environments: z - .array(z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - workspaceBaseEnvironments: d.workspace_base_environments, - nextPageToken: d.next_page_token, - })); +export const unmarshalListWorkspaceBaseEnvironmentsResponseSchema: z.ZodType = z + .object({ + workspace_base_environments: z.array(z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + workspaceBaseEnvironments: d.workspace_base_environments, + nextPageToken: d.next_page_token, + })); export const unmarshalOperationSchema: z.ZodType = z .object({ name: z.string().optional(), metadata: z.record(z.string(), z.unknown()).optional(), done: z.boolean().optional(), - error: z - .lazy(() => unmarshalDatabricksServiceExceptionWithDetailsProtoSchema) - .optional(), + error: z.lazy(() => unmarshalDatabricksServiceExceptionWithDetailsProtoSchema).optional(), response: z.record(z.string(), z.unknown()).optional(), }) .transform(d => ({ @@ -870,91 +857,75 @@ export const unmarshalOperationSchema: z.ZodType = z response: d.response, })); -export const unmarshalRefreshWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalRefreshWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); -export const unmarshalUpdateDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - default_workspace_base_environment: z - .lazy(() => unmarshalDefaultWorkspaceBaseEnvironmentSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - defaultWorkspaceBaseEnvironment: d.default_workspace_base_environment, - updateMask: d.update_mask, - })); +export const unmarshalUpdateDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + default_workspace_base_environment: z.lazy(() => unmarshalDefaultWorkspaceBaseEnvironmentSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + defaultWorkspaceBaseEnvironment: d.default_workspace_base_environment, + updateMask: d.update_mask, + })); -export const unmarshalUpdateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - workspace_base_environment: z - .lazy(() => unmarshalWorkspaceBaseEnvironmentSchema) - .optional(), - }) - .transform(d => ({ - name: d.name, - workspaceBaseEnvironment: d.workspace_base_environment, - })); +export const unmarshalUpdateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + workspace_base_environment: z.lazy(() => unmarshalWorkspaceBaseEnvironmentSchema).optional(), + }) + .transform(d => ({ + name: d.name, + workspaceBaseEnvironment: d.workspace_base_environment, + })); -export const unmarshalWorkspaceBaseEnvironmentSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - display_name: z.string().optional(), - filepath: z.string().optional(), - creator_user_id: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - last_updated_user_id: z.string().optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - status: z.enum(WorkspaceBaseEnvironmentCache_Status).optional(), - message: z.string().optional(), - is_default: z.boolean().optional(), - base_environment_type: z.enum(BaseEnvironmentType).optional(), - base_environment_provider: z - .enum(WorkspaceBaseEnvironmentProvider) - .optional(), - }) - .transform(d => ({ - name: d.name, - displayName: d.display_name, - filepath: d.filepath, - creatorUserId: d.creator_user_id, - createTime: d.create_time, - lastUpdatedUserId: d.last_updated_user_id, - updateTime: d.update_time, - status: d.status, - message: d.message, - isDefault: d.is_default, - baseEnvironmentType: d.base_environment_type, - baseEnvironmentProvider: d.base_environment_provider, - })); +export const unmarshalWorkspaceBaseEnvironmentSchema: z.ZodType = z + .object({ + name: z.string().optional(), + display_name: z.string().optional(), + filepath: z.string().optional(), + creator_user_id: z.string().optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + last_updated_user_id: z.string().optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + status: z.enum(WorkspaceBaseEnvironmentCache_Status).optional(), + message: z.string().optional(), + is_default: z.boolean().optional(), + base_environment_type: z.enum(BaseEnvironmentType).optional(), + base_environment_provider: z.enum(WorkspaceBaseEnvironmentProvider).optional(), + }) + .transform(d => ({ + name: d.name, + displayName: d.display_name, + filepath: d.filepath, + creatorUserId: d.creator_user_id, + createTime: d.create_time, + lastUpdatedUserId: d.last_updated_user_id, + updateTime: d.update_time, + status: d.status, + message: d.message, + isDefault: d.is_default, + baseEnvironmentType: d.base_environment_type, + baseEnvironmentProvider: d.base_environment_provider, + })); -export const unmarshalWorkspaceBaseEnvironmentCacheSchema: z.ZodType = - z.object({}); +export const unmarshalWorkspaceBaseEnvironmentCacheSchema: z.ZodType = z + .object({ + }); -export const unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema: z.ZodType = - z.object({}); +export const unmarshalWorkspaceBaseEnvironmentOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalCreateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z .object({ - workspaceBaseEnvironment: z - .lazy(() => marshalWorkspaceBaseEnvironmentSchema) - .optional(), + workspaceBaseEnvironment: z.lazy(() => marshalWorkspaceBaseEnvironmentSchema).optional(), workspaceBaseEnvironmentId: z.string().optional(), requestId: z.string().optional(), }) @@ -964,20 +935,19 @@ export const marshalCreateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z request_id: d.requestId, })); -export const marshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = - z - .object({ - errorCode: z.enum(ErrorCode).optional(), - message: z.string().optional(), - stackTrace: z.string().optional(), - details: z.array(z.record(z.string(), z.unknown())).optional(), - }) - .transform(d => ({ - error_code: d.errorCode, - message: d.message, - stack_trace: d.stackTrace, - details: d.details, - })); +export const marshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = z + .object({ + errorCode: z.enum(ErrorCode).optional(), + message: z.string().optional(), + stackTrace: z.string().optional(), + details: z.array(z.record(z.string(), z.unknown())).optional(), + }) + .transform(d => ({ + error_code: d.errorCode, + message: d.message, + stack_trace: d.stackTrace, + details: d.details, + })); export const marshalDefaultWorkspaceBaseEnvironmentSchema: z.ZodType = z .object({ @@ -999,14 +969,13 @@ export const marshalDeleteWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z name: d.name, })); -export const marshalGetDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const marshalGetDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const marshalGetOperationRequestSchema: z.ZodType = z .object({ @@ -1036,9 +1005,7 @@ export const marshalListWorkspaceBaseEnvironmentsRequestSchema: z.ZodType = z export const marshalListWorkspaceBaseEnvironmentsResponseSchema: z.ZodType = z .object({ - workspaceBaseEnvironments: z - .array(z.lazy(() => marshalWorkspaceBaseEnvironmentSchema)) - .optional(), + workspaceBaseEnvironments: z.array(z.lazy(() => marshalWorkspaceBaseEnvironmentSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -1051,9 +1018,7 @@ export const marshalOperationSchema: z.ZodType = z name: z.string().optional(), metadata: z.record(z.string(), z.unknown()).optional(), done: z.boolean().optional(), - error: z - .lazy(() => marshalDatabricksServiceExceptionWithDetailsProtoSchema) - .optional(), + error: z.lazy(() => marshalDatabricksServiceExceptionWithDetailsProtoSchema).optional(), response: z.record(z.string(), z.unknown()).optional(), }) .transform(d => ({ @@ -1072,25 +1037,20 @@ export const marshalRefreshWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z name: d.name, })); -export const marshalUpdateDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = - z - .object({ - defaultWorkspaceBaseEnvironment: z - .lazy(() => marshalDefaultWorkspaceBaseEnvironmentSchema) - .optional(), - updateMask: z.string().optional(), - }) - .transform(d => ({ - default_workspace_base_environment: d.defaultWorkspaceBaseEnvironment, - update_mask: d.updateMask, - })); +export const marshalUpdateDefaultWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z + .object({ + defaultWorkspaceBaseEnvironment: z.lazy(() => marshalDefaultWorkspaceBaseEnvironmentSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), + }) + .transform(d => ({ + default_workspace_base_environment: d.defaultWorkspaceBaseEnvironment, + update_mask: d.updateMask, + })); export const marshalUpdateWorkspaceBaseEnvironmentRequestSchema: z.ZodType = z .object({ name: z.string().optional(), - workspaceBaseEnvironment: z - .lazy(() => marshalWorkspaceBaseEnvironmentSchema) - .optional(), + workspaceBaseEnvironment: z.lazy(() => marshalWorkspaceBaseEnvironmentSchema).optional(), }) .transform(d => ({ name: d.name, @@ -1103,22 +1063,14 @@ export const marshalWorkspaceBaseEnvironmentSchema: z.ZodType = z displayName: z.string().optional(), filepath: z.string().optional(), creatorUserId: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), lastUpdatedUserId: z.string().optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), status: z.enum(WorkspaceBaseEnvironmentCache_Status).optional(), message: z.string().optional(), isDefault: z.boolean().optional(), baseEnvironmentType: z.enum(BaseEnvironmentType).optional(), - baseEnvironmentProvider: z - .enum(WorkspaceBaseEnvironmentProvider) - .optional(), + baseEnvironmentProvider: z.enum(WorkspaceBaseEnvironmentProvider).optional(), }) .transform(d => ({ name: d.name, @@ -1135,9 +1087,10 @@ export const marshalWorkspaceBaseEnvironmentSchema: z.ZodType = z base_environment_provider: d.baseEnvironmentProvider, })); -export const marshalWorkspaceBaseEnvironmentCacheSchema: z.ZodType = z.object( - {} -); +export const marshalWorkspaceBaseEnvironmentCacheSchema: z.ZodType = z + .object({ + }); -export const marshalWorkspaceBaseEnvironmentOperationMetadataSchema: z.ZodType = - z.object({}); +export const marshalWorkspaceBaseEnvironmentOperationMetadataSchema: z.ZodType = z + .object({ + }); diff --git a/packages/environments/src/v1/utils.ts b/packages/environments/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/environments/src/v1/utils.ts +++ b/packages/environments/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/environments/tsconfig.json b/packages/environments/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/environments/tsconfig.json +++ b/packages/environments/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/externallocations/package.json b/packages/externallocations/package.json index 3ec09799..3e762953 100644 --- a/packages/externallocations/package.json +++ b/packages/externallocations/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/externallocations/src/v1/client.ts b/packages/externallocations/src/v1/client.ts index c82a0f2d..6f8e7af0 100644 --- a/packages/externallocations/src/v1/client.ts +++ b/packages/externallocations/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateExternalLocation, DeleteExternalLocation, @@ -49,21 +44,13 @@ export class Client { * Creates a new external location entry in the metastore. * The caller must be a metastore admin or have the **CREATE_EXTERNAL_LOCATION** privilege on both the metastore and the associated storage credential. */ - async createExternalLocation( - signal: AbortSignal | undefined, - req: CreateExternalLocation, - options?: Options - ): Promise { + async createExternalLocation(signal: AbortSignal | undefined, req: CreateExternalLocation, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/external-locations`; const body = marshalRequest(req, marshalCreateExternalLocationSchema); let resp: ExternalLocationInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalExternalLocationInfoSchema); }; await execute(signal, call, options); @@ -74,11 +61,7 @@ export class Client { } /** Deletes the specified external location from the metastore. The caller must be the owner of the external location. */ - async deleteExternalLocation( - signal: AbortSignal | undefined, - req: DeleteExternalLocation, - options?: Options - ): Promise { + async deleteExternalLocation(signal: AbortSignal | undefined, req: DeleteExternalLocation, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/external-locations/${req.nameArg ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -89,15 +72,8 @@ export class Client { let resp: DeleteExternalLocation_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteExternalLocation_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteExternalLocation_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -110,11 +86,7 @@ export class Client { * Gets an external location from the metastore. * The caller must be either a metastore admin, the owner of the external location, or a user that has some privilege on the external location. */ - async getExternalLocation( - signal: AbortSignal | undefined, - req: GetExternalLocation, - options?: Options - ): Promise { + async getExternalLocation(signal: AbortSignal | undefined, req: GetExternalLocation, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/external-locations/${req.nameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -125,11 +97,7 @@ export class Client { let resp: ExternalLocationInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalExternalLocationInfoSchema); }; await execute(signal, call, options); @@ -143,17 +111,13 @@ export class Client { * Gets an array of external locations (__ExternalLocationInfo__ objects) from the metastore. * The caller must be a metastore admin, the owner of the external location, or a user that has some privilege on the external location. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listExternalLocations( - signal: AbortSignal | undefined, - req: ListExternalLocations, - options?: Options - ): Promise { + async listExternalLocations(signal: AbortSignal | undefined, req: ListExternalLocations, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/external-locations`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -173,15 +137,8 @@ export class Client { let resp: ListExternalLocations_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListExternalLocations_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListExternalLocations_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -190,11 +147,8 @@ export class Client { return resp; } - async *listExternalLocationsIter( - signal: AbortSignal | undefined, - req: ListExternalLocations, - options?: Options - ): AsyncGenerator { + + async *listExternalLocationsIter(signal: AbortSignal | undefined, req: ListExternalLocations, options?: Options): AsyncGenerator { const pageReq: ListExternalLocations = {...req}; for (;;) { const resp = await this.listExternalLocations(signal, pageReq, options); @@ -208,25 +162,18 @@ export class Client { } } + /** * Updates an external location in the metastore. The caller must be the owner of the external location, or be a metastore admin. * In the second case, the admin can only update the name of the external location. */ - async updateExternalLocation( - signal: AbortSignal | undefined, - req: UpdateExternalLocation, - options?: Options - ): Promise { + async updateExternalLocation(signal: AbortSignal | undefined, req: UpdateExternalLocation, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/external-locations/${req.nameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateExternalLocationSchema); let resp: ExternalLocationInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalExternalLocationInfoSchema); }; await execute(signal, call, options); diff --git a/packages/externallocations/src/v1/index.ts b/packages/externallocations/src/v1/index.ts index 962aefee..fcd2ec39 100644 --- a/packages/externallocations/src/v1/index.ts +++ b/packages/externallocations/src/v1/index.ts @@ -1,8 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {IsolationMode, SseEncryptionAlgorithm} from './model'; +export { + IsolationMode, + SseEncryptionAlgorithm, +} from './model'; export type { AwsSqsQueue, diff --git a/packages/externallocations/src/v1/model.ts b/packages/externallocations/src/v1/model.ts index c7f6f7c8..71b351b8 100644 --- a/packages/externallocations/src/v1/model.ts +++ b/packages/externallocations/src/v1/model.ts @@ -312,134 +312,122 @@ export const unmarshalAzureQueueStorageSchema: z.ZodType = z managedResourceId: d.managed_resource_id, })); -export const unmarshalCreateExternalLocationSchema: z.ZodType = - z - .object({ - skip_validation: z.boolean().optional(), - name: z.string().optional(), - url: z.string().optional(), - credential_name: z.string().optional(), - read_only: z.boolean().optional(), - comment: z.string().optional(), - enable_file_events: z.boolean().optional(), - file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), - owner: z.string().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), - metastore_id: z.string().optional(), - credential_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - browse_only: z.boolean().optional(), - isolation_mode: z.enum(IsolationMode).optional(), - fallback: z.boolean().optional(), - effective_enable_file_events: z.boolean().optional(), - effective_file_event_queue: z - .lazy(() => unmarshalFileEventQueueSchema) - .optional(), - }) - .transform(d => ({ - skipValidation: d.skip_validation, - name: d.name, - url: d.url, - credentialName: d.credential_name, - readOnly: d.read_only, - comment: d.comment, - enableFileEvents: d.enable_file_events, - fileEventQueue: d.file_event_queue, - owner: d.owner, - encryptionDetails: d.encryption_details, - metastoreId: d.metastore_id, - credentialId: d.credential_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - browseOnly: d.browse_only, - isolationMode: d.isolation_mode, - fallback: d.fallback, - effectiveEnableFileEvents: d.effective_enable_file_events, - effectiveFileEventQueue: d.effective_file_event_queue, - })); - -export const unmarshalDeleteExternalLocationSchema: z.ZodType = - z - .object({ - name_arg: z.string().optional(), - force: z.boolean().optional(), - }) - .transform(d => ({ - nameArg: d.name_arg, - force: d.force, - })); +export const unmarshalCreateExternalLocationSchema: z.ZodType = z + .object({ + skip_validation: z.boolean().optional(), + name: z.string().optional(), + url: z.string().optional(), + credential_name: z.string().optional(), + read_only: z.boolean().optional(), + comment: z.string().optional(), + enable_file_events: z.boolean().optional(), + file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), + owner: z.string().optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), + metastore_id: z.string().optional(), + credential_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + browse_only: z.boolean().optional(), + isolation_mode: z.enum(IsolationMode).optional(), + fallback: z.boolean().optional(), + effective_enable_file_events: z.boolean().optional(), + effective_file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), + }) + .transform(d => ({ + skipValidation: d.skip_validation, + name: d.name, + url: d.url, + credentialName: d.credential_name, + readOnly: d.read_only, + comment: d.comment, + enableFileEvents: d.enable_file_events, + fileEventQueue: d.file_event_queue, + owner: d.owner, + encryptionDetails: d.encryption_details, + metastoreId: d.metastore_id, + credentialId: d.credential_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + browseOnly: d.browse_only, + isolationMode: d.isolation_mode, + fallback: d.fallback, + effectiveEnableFileEvents: d.effective_enable_file_events, + effectiveFileEventQueue: d.effective_file_event_queue, + })); + +export const unmarshalDeleteExternalLocationSchema: z.ZodType = z + .object({ + name_arg: z.string().optional(), + force: z.boolean().optional(), + }) + .transform(d => ({ + nameArg: d.name_arg, + force: d.force, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteExternalLocation_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteExternalLocation_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalEncryptionDetailsSchema: z.ZodType = z .object({ - sse_encryption_details: z - .lazy(() => unmarshalSseEncryptionDetailsSchema) - .optional(), + sse_encryption_details: z.lazy(() => unmarshalSseEncryptionDetailsSchema).optional(), }) .transform(d => ({ sseEncryptionDetails: d.sse_encryption_details, })); -export const unmarshalExternalLocationInfoSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - url: z.string().optional(), - credential_name: z.string().optional(), - read_only: z.boolean().optional(), - comment: z.string().optional(), - enable_file_events: z.boolean().optional(), - file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), - owner: z.string().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), - metastore_id: z.string().optional(), - credential_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - browse_only: z.boolean().optional(), - isolation_mode: z.enum(IsolationMode).optional(), - fallback: z.boolean().optional(), - effective_enable_file_events: z.boolean().optional(), - effective_file_event_queue: z - .lazy(() => unmarshalFileEventQueueSchema) - .optional(), - }) - .transform(d => ({ - name: d.name, - url: d.url, - credentialName: d.credential_name, - readOnly: d.read_only, - comment: d.comment, - enableFileEvents: d.enable_file_events, - fileEventQueue: d.file_event_queue, - owner: d.owner, - encryptionDetails: d.encryption_details, - metastoreId: d.metastore_id, - credentialId: d.credential_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - browseOnly: d.browse_only, - isolationMode: d.isolation_mode, - fallback: d.fallback, - effectiveEnableFileEvents: d.effective_enable_file_events, - effectiveFileEventQueue: d.effective_file_event_queue, - })); +export const unmarshalExternalLocationInfoSchema: z.ZodType = z + .object({ + name: z.string().optional(), + url: z.string().optional(), + credential_name: z.string().optional(), + read_only: z.boolean().optional(), + comment: z.string().optional(), + enable_file_events: z.boolean().optional(), + file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), + owner: z.string().optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), + metastore_id: z.string().optional(), + credential_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + browse_only: z.boolean().optional(), + isolation_mode: z.enum(IsolationMode).optional(), + fallback: z.boolean().optional(), + effective_enable_file_events: z.boolean().optional(), + effective_file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), + }) + .transform(d => ({ + name: d.name, + url: d.url, + credentialName: d.credential_name, + readOnly: d.read_only, + comment: d.comment, + enableFileEvents: d.enable_file_events, + fileEventQueue: d.file_event_queue, + owner: d.owner, + encryptionDetails: d.encryption_details, + metastoreId: d.metastore_id, + credentialId: d.credential_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + browseOnly: d.browse_only, + isolationMode: d.isolation_mode, + fallback: d.fallback, + effectiveEnableFileEvents: d.effective_enable_file_events, + effectiveFileEventQueue: d.effective_file_event_queue, + })); export const unmarshalFileEventQueueSchema: z.ZodType = z .object({ @@ -469,115 +457,104 @@ export const unmarshalGcpPubsubSchema: z.ZodType = z managedResourceId: d.managed_resource_id, })); -export const unmarshalGetExternalLocationSchema: z.ZodType = - z - .object({ - name_arg: z.string().optional(), - include_browse: z.boolean().optional(), - }) - .transform(d => ({ - nameArg: d.name_arg, - includeBrowse: d.include_browse, - })); - -export const unmarshalListExternalLocationsSchema: z.ZodType = - z - .object({ - include_browse: z.boolean().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - include_unbound: z.boolean().optional(), - }) - .transform(d => ({ - includeBrowse: d.include_browse, - maxResults: d.max_results, - pageToken: d.page_token, - includeUnbound: d.include_unbound, - })); +export const unmarshalGetExternalLocationSchema: z.ZodType = z + .object({ + name_arg: z.string().optional(), + include_browse: z.boolean().optional(), + }) + .transform(d => ({ + nameArg: d.name_arg, + includeBrowse: d.include_browse, + })); + +export const unmarshalListExternalLocationsSchema: z.ZodType = z + .object({ + include_browse: z.boolean().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + include_unbound: z.boolean().optional(), + }) + .transform(d => ({ + includeBrowse: d.include_browse, + maxResults: d.max_results, + pageToken: d.page_token, + includeUnbound: d.include_unbound, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListExternalLocations_ResponseSchema: z.ZodType = - z - .object({ - external_locations: z - .array(z.lazy(() => unmarshalExternalLocationInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - externalLocations: d.external_locations, - nextPageToken: d.next_page_token, - })); - -export const unmarshalSseEncryptionDetailsSchema: z.ZodType = - z - .object({ - algorithm: z.enum(SseEncryptionAlgorithm).optional(), - aws_kms_key_arn: z.string().optional(), - }) - .transform(d => ({ - algorithm: d.algorithm, - awsKmsKeyArn: d.aws_kms_key_arn, - })); - -export const unmarshalUpdateExternalLocationSchema: z.ZodType = - z - .object({ - name_arg: z.string().optional(), - new_name: z.string().optional(), - force: z.boolean().optional(), - skip_validation: z.boolean().optional(), - name: z.string().optional(), - url: z.string().optional(), - credential_name: z.string().optional(), - read_only: z.boolean().optional(), - comment: z.string().optional(), - enable_file_events: z.boolean().optional(), - file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), - owner: z.string().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), - metastore_id: z.string().optional(), - credential_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - browse_only: z.boolean().optional(), - isolation_mode: z.enum(IsolationMode).optional(), - fallback: z.boolean().optional(), - effective_enable_file_events: z.boolean().optional(), - effective_file_event_queue: z - .lazy(() => unmarshalFileEventQueueSchema) - .optional(), - }) - .transform(d => ({ - nameArg: d.name_arg, - newName: d.new_name, - force: d.force, - skipValidation: d.skip_validation, - name: d.name, - url: d.url, - credentialName: d.credential_name, - readOnly: d.read_only, - comment: d.comment, - enableFileEvents: d.enable_file_events, - fileEventQueue: d.file_event_queue, - owner: d.owner, - encryptionDetails: d.encryption_details, - metastoreId: d.metastore_id, - credentialId: d.credential_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - browseOnly: d.browse_only, - isolationMode: d.isolation_mode, - fallback: d.fallback, - effectiveEnableFileEvents: d.effective_enable_file_events, - effectiveFileEventQueue: d.effective_file_event_queue, - })); +export const unmarshalListExternalLocations_ResponseSchema: z.ZodType = z + .object({ + external_locations: z.array(z.lazy(() => unmarshalExternalLocationInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + externalLocations: d.external_locations, + nextPageToken: d.next_page_token, + })); + +export const unmarshalSseEncryptionDetailsSchema: z.ZodType = z + .object({ + algorithm: z.enum(SseEncryptionAlgorithm).optional(), + aws_kms_key_arn: z.string().optional(), + }) + .transform(d => ({ + algorithm: d.algorithm, + awsKmsKeyArn: d.aws_kms_key_arn, + })); + +export const unmarshalUpdateExternalLocationSchema: z.ZodType = z + .object({ + name_arg: z.string().optional(), + new_name: z.string().optional(), + force: z.boolean().optional(), + skip_validation: z.boolean().optional(), + name: z.string().optional(), + url: z.string().optional(), + credential_name: z.string().optional(), + read_only: z.boolean().optional(), + comment: z.string().optional(), + enable_file_events: z.boolean().optional(), + file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), + owner: z.string().optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), + metastore_id: z.string().optional(), + credential_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + browse_only: z.boolean().optional(), + isolation_mode: z.enum(IsolationMode).optional(), + fallback: z.boolean().optional(), + effective_enable_file_events: z.boolean().optional(), + effective_file_event_queue: z.lazy(() => unmarshalFileEventQueueSchema).optional(), + }) + .transform(d => ({ + nameArg: d.name_arg, + newName: d.new_name, + force: d.force, + skipValidation: d.skip_validation, + name: d.name, + url: d.url, + credentialName: d.credential_name, + readOnly: d.read_only, + comment: d.comment, + enableFileEvents: d.enable_file_events, + fileEventQueue: d.file_event_queue, + owner: d.owner, + encryptionDetails: d.encryption_details, + metastoreId: d.metastore_id, + credentialId: d.credential_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + browseOnly: d.browse_only, + isolationMode: d.isolation_mode, + fallback: d.fallback, + effectiveEnableFileEvents: d.effective_enable_file_events, + effectiveFileEventQueue: d.effective_file_event_queue, + })); export const marshalAwsSqsQueueSchema: z.ZodType = z .object({ @@ -625,9 +602,7 @@ export const marshalCreateExternalLocationSchema: z.ZodType = z isolationMode: z.enum(IsolationMode).optional(), fallback: z.boolean().optional(), effectiveEnableFileEvents: z.boolean().optional(), - effectiveFileEventQueue: z - .lazy(() => marshalFileEventQueueSchema) - .optional(), + effectiveFileEventQueue: z.lazy(() => marshalFileEventQueueSchema).optional(), }) .transform(d => ({ skip_validation: d.skipValidation, @@ -664,15 +639,13 @@ export const marshalDeleteExternalLocationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteExternalLocation_ResponseSchema: z.ZodType = z.object( - {} -); +export const marshalDeleteExternalLocation_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalEncryptionDetailsSchema: z.ZodType = z .object({ - sseEncryptionDetails: z - .lazy(() => marshalSseEncryptionDetailsSchema) - .optional(), + sseEncryptionDetails: z.lazy(() => marshalSseEncryptionDetailsSchema).optional(), }) .transform(d => ({ sse_encryption_details: d.sseEncryptionDetails, @@ -699,9 +672,7 @@ export const marshalExternalLocationInfoSchema: z.ZodType = z isolationMode: z.enum(IsolationMode).optional(), fallback: z.boolean().optional(), effectiveEnableFileEvents: z.boolean().optional(), - effectiveFileEventQueue: z - .lazy(() => marshalFileEventQueueSchema) - .optional(), + effectiveFileEventQueue: z.lazy(() => marshalFileEventQueueSchema).optional(), }) .transform(d => ({ name: d.name, @@ -781,9 +752,7 @@ export const marshalListExternalLocationsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListExternalLocations_ResponseSchema: z.ZodType = z .object({ - externalLocations: z - .array(z.lazy(() => marshalExternalLocationInfoSchema)) - .optional(), + externalLocations: z.array(z.lazy(() => marshalExternalLocationInfoSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -826,9 +795,7 @@ export const marshalUpdateExternalLocationSchema: z.ZodType = z isolationMode: z.enum(IsolationMode).optional(), fallback: z.boolean().optional(), effectiveEnableFileEvents: z.boolean().optional(), - effectiveFileEventQueue: z - .lazy(() => marshalFileEventQueueSchema) - .optional(), + effectiveFileEventQueue: z.lazy(() => marshalFileEventQueueSchema).optional(), }) .transform(d => ({ name_arg: d.nameArg, diff --git a/packages/externallocations/src/v1/utils.ts b/packages/externallocations/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/externallocations/src/v1/utils.ts +++ b/packages/externallocations/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/externallocations/tsconfig.json b/packages/externallocations/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/externallocations/tsconfig.json +++ b/packages/externallocations/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/features/package.json b/packages/features/package.json index 4bef636f..6caf5c7c 100644 --- a/packages/features/package.json +++ b/packages/features/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/features/src/v1/client.ts b/packages/features/src/v1/client.ts index d3e38730..85b9442d 100644 --- a/packages/features/src/v1/client.ts +++ b/packages/features/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { BatchCreateMaterializedFeaturesRequest, BatchCreateMaterializedFeaturesResponse, @@ -67,28 +62,14 @@ export class Client { } /** Batch create materialized features. */ - async batchCreateMaterializedFeatures( - signal: AbortSignal | undefined, - req: BatchCreateMaterializedFeaturesRequest, - options?: Options - ): Promise { + async batchCreateMaterializedFeatures(signal: AbortSignal | undefined, req: BatchCreateMaterializedFeaturesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/materialized-features:batchCreate`; - const body = marshalRequest( - req, - marshalBatchCreateMaterializedFeaturesRequestSchema - ); + const body = marshalRequest(req, marshalBatchCreateMaterializedFeaturesRequestSchema); let resp: BatchCreateMaterializedFeaturesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalBatchCreateMaterializedFeaturesResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalBatchCreateMaterializedFeaturesResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -98,21 +79,13 @@ export class Client { } /** Create a Feature. */ - async createFeature( - signal: AbortSignal | undefined, - req: CreateFeatureRequest, - options?: Options - ): Promise { + async createFeature(signal: AbortSignal | undefined, req: CreateFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features`; const body = marshalRequest(req.feature, marshalFeatureSchema); let resp: Feature | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureSchema); }; await execute(signal, call, options); @@ -127,21 +100,13 @@ export class Client { * During PrPr, Kafka configs can be read and used when creating features under the entire metastore. * Only the creator of the Kafka config can delete it. */ - async createKafkaConfig( - signal: AbortSignal | undefined, - req: CreateKafkaConfigRequest, - options?: Options - ): Promise { + async createKafkaConfig(signal: AbortSignal | undefined, req: CreateKafkaConfigRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs`; const body = marshalRequest(req.kafkaConfig, marshalKafkaConfigSchema); let resp: KafkaConfig | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalKafkaConfigSchema); }; await execute(signal, call, options); @@ -152,24 +117,13 @@ export class Client { } /** Create a materialized feature. */ - async createMaterializedFeature( - signal: AbortSignal | undefined, - req: CreateMaterializedFeatureRequest, - options?: Options - ): Promise { + async createMaterializedFeature(signal: AbortSignal | undefined, req: CreateMaterializedFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/materialized-features`; - const body = marshalRequest( - req.materializedFeature, - marshalMaterializedFeatureSchema - ); + const body = marshalRequest(req.materializedFeature, marshalMaterializedFeatureSchema); let resp: MaterializedFeature | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMaterializedFeatureSchema); }; await execute(signal, call, options); @@ -180,19 +134,11 @@ export class Client { } /** Delete a Feature. */ - async deleteFeature( - signal: AbortSignal | undefined, - req: DeleteFeatureRequest, - options?: Options - ): Promise { + async deleteFeature(signal: AbortSignal | undefined, req: DeleteFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/${req.fullName ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } @@ -202,56 +148,32 @@ export class Client { * During PrPr, Kafka configs can be read and used when creating features under the entire metastore. * Only the creator of the Kafka config can delete it. */ - async deleteKafkaConfig( - signal: AbortSignal | undefined, - req: DeleteKafkaConfigRequest, - options?: Options - ): Promise { + async deleteKafkaConfig(signal: AbortSignal | undefined, req: DeleteKafkaConfigRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs/${req.name ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Delete a materialized feature. */ - async deleteMaterializedFeature( - signal: AbortSignal | undefined, - req: DeleteMaterializedFeatureRequest, - options?: Options - ): Promise { + async deleteMaterializedFeature(signal: AbortSignal | undefined, req: DeleteMaterializedFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/materialized-features/${req.materializedFeatureId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Get a Feature. */ - async getFeature( - signal: AbortSignal | undefined, - req: GetFeatureRequest, - options?: Options - ): Promise { + async getFeature(signal: AbortSignal | undefined, req: GetFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/${req.fullName ?? ''}`; let resp: Feature | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureSchema); }; await execute(signal, call, options); @@ -266,20 +188,12 @@ export class Client { * During PrPr, Kafka configs can be read and used when creating features under the entire metastore. * Only the creator of the Kafka config can delete it. */ - async getKafkaConfig( - signal: AbortSignal | undefined, - req: GetKafkaConfigRequest, - options?: Options - ): Promise { + async getKafkaConfig(signal: AbortSignal | undefined, req: GetKafkaConfigRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs/${req.name ?? ''}`; let resp: KafkaConfig | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalKafkaConfigSchema); }; await execute(signal, call, options); @@ -290,20 +204,12 @@ export class Client { } /** Get a materialized feature. */ - async getMaterializedFeature( - signal: AbortSignal | undefined, - req: GetMaterializedFeatureRequest, - options?: Options - ): Promise { + async getMaterializedFeature(signal: AbortSignal | undefined, req: GetMaterializedFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/materialized-features/${req.materializedFeatureId ?? ''}`; let resp: MaterializedFeature | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMaterializedFeatureSchema); }; await execute(signal, call, options); @@ -314,11 +220,7 @@ export class Client { } /** List Features. */ - async listFeatures( - signal: AbortSignal | undefined, - req: ListFeaturesRequest, - options?: Options - ): Promise { + async listFeatures(signal: AbortSignal | undefined, req: ListFeaturesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -332,11 +234,7 @@ export class Client { let resp: ListFeaturesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListFeaturesResponseSchema); }; await execute(signal, call, options); @@ -346,11 +244,8 @@ export class Client { return resp; } - async *listFeaturesIter( - signal: AbortSignal | undefined, - req: ListFeaturesRequest, - options?: Options - ): AsyncGenerator { + + async *listFeaturesIter(signal: AbortSignal | undefined, req: ListFeaturesRequest, options?: Options): AsyncGenerator { const pageReq: ListFeaturesRequest = {...req}; for (;;) { const resp = await this.listFeatures(signal, pageReq, options); @@ -364,16 +259,13 @@ export class Client { } } + /** * List Kafka configs. * During PrPr, Kafka configs can be read and used when creating features under the entire metastore. * Only the creator of the Kafka config can delete it. */ - async listKafkaConfigs( - signal: AbortSignal | undefined, - req: ListKafkaConfigsRequest, - options?: Options - ): Promise { + async listKafkaConfigs(signal: AbortSignal | undefined, req: ListKafkaConfigsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -387,11 +279,7 @@ export class Client { let resp: ListKafkaConfigsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListKafkaConfigsResponseSchema); }; await execute(signal, call, options); @@ -401,11 +289,8 @@ export class Client { return resp; } - async *listKafkaConfigsIter( - signal: AbortSignal | undefined, - req: ListKafkaConfigsRequest, - options?: Options - ): AsyncGenerator { + + async *listKafkaConfigsIter(signal: AbortSignal | undefined, req: ListKafkaConfigsRequest, options?: Options): AsyncGenerator { const pageReq: ListKafkaConfigsRequest = {...req}; for (;;) { const resp = await this.listKafkaConfigs(signal, pageReq, options); @@ -419,12 +304,9 @@ export class Client { } } + /** List materialized features. */ - async listMaterializedFeatures( - signal: AbortSignal | undefined, - req: ListMaterializedFeaturesRequest, - options?: Options - ): Promise { + async listMaterializedFeatures(signal: AbortSignal | undefined, req: ListMaterializedFeaturesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/materialized-features`; const params = new URLSearchParams(); if (req.featureName !== undefined) { @@ -441,15 +323,8 @@ export class Client { let resp: ListMaterializedFeaturesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListMaterializedFeaturesResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListMaterializedFeaturesResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -458,18 +333,11 @@ export class Client { return resp; } - async *listMaterializedFeaturesIter( - signal: AbortSignal | undefined, - req: ListMaterializedFeaturesRequest, - options?: Options - ): AsyncGenerator { + + async *listMaterializedFeaturesIter(signal: AbortSignal | undefined, req: ListMaterializedFeaturesRequest, options?: Options): AsyncGenerator { const pageReq: ListMaterializedFeaturesRequest = {...req}; for (;;) { - const resp = await this.listMaterializedFeatures( - signal, - pageReq, - options - ); + const resp = await this.listMaterializedFeatures(signal, pageReq, options); for (const item of resp.materializedFeatures ?? []) { yield item; } @@ -480,16 +348,13 @@ export class Client { } } + /** Update a Feature. */ - async updateFeature( - signal: AbortSignal | undefined, - req: UpdateFeatureRequest, - options?: Options - ): Promise { + async updateFeature(signal: AbortSignal | undefined, req: UpdateFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/${req.feature?.fullName ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -497,11 +362,7 @@ export class Client { let resp: Feature | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureSchema); }; await execute(signal, call, options); @@ -516,15 +377,11 @@ export class Client { * During PrPr, Kafka configs can be read and used when creating features under the entire metastore. * Only the creator of the Kafka config can delete it. */ - async updateKafkaConfig( - signal: AbortSignal | undefined, - req: UpdateKafkaConfigRequest, - options?: Options - ): Promise { + async updateKafkaConfig(signal: AbortSignal | undefined, req: UpdateKafkaConfigRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/features/kafka-configs/${req.kafkaConfig?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -532,11 +389,7 @@ export class Client { let resp: KafkaConfig | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalKafkaConfigSchema); }; await execute(signal, call, options); @@ -547,30 +400,19 @@ export class Client { } /** Update a materialized feature (pause/resume). */ - async updateMaterializedFeature( - signal: AbortSignal | undefined, - req: UpdateMaterializedFeatureRequest, - options?: Options - ): Promise { + async updateMaterializedFeature(signal: AbortSignal | undefined, req: UpdateMaterializedFeatureRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-engineering/materialized-features/${req.materializedFeature?.materializedFeatureId ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.materializedFeature, - marshalMaterializedFeatureSchema - ); + const body = marshalRequest(req.materializedFeature, marshalMaterializedFeatureSchema); let resp: MaterializedFeature | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMaterializedFeatureSchema); }; await execute(signal, call, options); diff --git a/packages/features/src/v1/index.ts b/packages/features/src/v1/index.ts index b9022c7e..84a093ee 100644 --- a/packages/features/src/v1/index.ts +++ b/packages/features/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/features/src/v1/model.ts b/packages/features/src/v1/model.ts index 45cee41b..a5df3335 100644 --- a/packages/features/src/v1/model.ts +++ b/packages/features/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** @@ -612,14 +614,14 @@ export interface UpdateFeatureRequest { /** Feature to update. */ feature?: Feature | undefined; /** The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface UpdateKafkaConfigRequest { /** The Kafka config to update. */ kafkaConfig?: KafkaConfig | undefined; /** The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface UpdateMaterializedFeatureRequest { @@ -629,7 +631,7 @@ export interface UpdateMaterializedFeatureRequest { * Provide the materialization feature fields which should be updated. * Currently, only the pipeline_state field can be updated. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** Computes the population variance. */ @@ -644,68 +646,61 @@ export interface VarSampFunction { input?: string | undefined; } -export const unmarshalAggregationFunctionSchema: z.ZodType = - z - .object({ - avg: z.lazy(() => unmarshalAvgFunctionSchema).optional(), - count_function: z.lazy(() => unmarshalCountFunctionSchema).optional(), - sum: z.lazy(() => unmarshalSumFunctionSchema).optional(), - min: z.lazy(() => unmarshalMinFunctionSchema).optional(), - max: z.lazy(() => unmarshalMaxFunctionSchema).optional(), - first: z.lazy(() => unmarshalFirstFunctionSchema).optional(), - last: z.lazy(() => unmarshalLastFunctionSchema).optional(), - approx_count_distinct: z - .lazy(() => unmarshalApproxCountDistinctFunctionSchema) - .optional(), - approx_percentile: z - .lazy(() => unmarshalApproxPercentileFunctionSchema) - .optional(), - stddev_pop: z.lazy(() => unmarshalStddevPopFunctionSchema).optional(), - stddev_samp: z.lazy(() => unmarshalStddevSampFunctionSchema).optional(), - var_pop: z.lazy(() => unmarshalVarPopFunctionSchema).optional(), - var_samp: z.lazy(() => unmarshalVarSampFunctionSchema).optional(), - time_window: z.lazy(() => unmarshalTimeWindowSchema).optional(), - }) - .transform(d => ({ - avg: d.avg, - countFunction: d.count_function, - sum: d.sum, - min: d.min, - max: d.max, - first: d.first, - last: d.last, - approxCountDistinct: d.approx_count_distinct, - approxPercentile: d.approx_percentile, - stddevPop: d.stddev_pop, - stddevSamp: d.stddev_samp, - varPop: d.var_pop, - varSamp: d.var_samp, - timeWindow: d.time_window, - })); - -export const unmarshalApproxCountDistinctFunctionSchema: z.ZodType = - z - .object({ - input: z.string().optional(), - relative_sd: z.number().optional(), - }) - .transform(d => ({ - input: d.input, - relativeSd: d.relative_sd, - })); - -export const unmarshalApproxPercentileFunctionSchema: z.ZodType = - z - .object({ - input: z.string().optional(), - percentile: z.number().optional(), - accuracy: z.number().optional(), - }) - .transform(d => ({ - input: d.input, - percentile: d.percentile, - accuracy: d.accuracy, - })); +export const unmarshalAggregationFunctionSchema: z.ZodType = z + .object({ + avg: z.lazy(() => unmarshalAvgFunctionSchema).optional(), + count_function: z.lazy(() => unmarshalCountFunctionSchema).optional(), + sum: z.lazy(() => unmarshalSumFunctionSchema).optional(), + min: z.lazy(() => unmarshalMinFunctionSchema).optional(), + max: z.lazy(() => unmarshalMaxFunctionSchema).optional(), + first: z.lazy(() => unmarshalFirstFunctionSchema).optional(), + last: z.lazy(() => unmarshalLastFunctionSchema).optional(), + approx_count_distinct: z.lazy(() => unmarshalApproxCountDistinctFunctionSchema).optional(), + approx_percentile: z.lazy(() => unmarshalApproxPercentileFunctionSchema).optional(), + stddev_pop: z.lazy(() => unmarshalStddevPopFunctionSchema).optional(), + stddev_samp: z.lazy(() => unmarshalStddevSampFunctionSchema).optional(), + var_pop: z.lazy(() => unmarshalVarPopFunctionSchema).optional(), + var_samp: z.lazy(() => unmarshalVarSampFunctionSchema).optional(), + time_window: z.lazy(() => unmarshalTimeWindowSchema).optional(), + }) + .transform(d => ({ + avg: d.avg, + countFunction: d.count_function, + sum: d.sum, + min: d.min, + max: d.max, + first: d.first, + last: d.last, + approxCountDistinct: d.approx_count_distinct, + approxPercentile: d.approx_percentile, + stddevPop: d.stddev_pop, + stddevSamp: d.stddev_samp, + varPop: d.var_pop, + varSamp: d.var_samp, + timeWindow: d.time_window, + })); + +export const unmarshalApproxCountDistinctFunctionSchema: z.ZodType = z + .object({ + input: z.string().optional(), + relative_sd: z.number().optional(), + }) + .transform(d => ({ + input: d.input, + relativeSd: d.relative_sd, + })); + +export const unmarshalApproxPercentileFunctionSchema: z.ZodType = z + .object({ + input: z.string().optional(), + percentile: z.number().optional(), + accuracy: z.number().optional(), + }) + .transform(d => ({ + input: d.input, + percentile: d.percentile, + accuracy: d.accuracy, + })); export const unmarshalAuthConfigSchema: z.ZodType = z .object({ @@ -725,35 +720,27 @@ export const unmarshalAvgFunctionSchema: z.ZodType = z export const unmarshalBackfillSourceSchema: z.ZodType = z .object({ - delta_table_source: z - .lazy(() => unmarshalDeltaTableSourceSchema) - .optional(), + delta_table_source: z.lazy(() => unmarshalDeltaTableSourceSchema).optional(), }) .transform(d => ({ deltaTableSource: d.delta_table_source, })); -export const unmarshalBatchCreateMaterializedFeaturesRequestSchema: z.ZodType = - z - .object({ - requests: z - .array(z.lazy(() => unmarshalCreateMaterializedFeatureRequestSchema)) - .optional(), - }) - .transform(d => ({ - requests: d.requests, - })); - -export const unmarshalBatchCreateMaterializedFeaturesResponseSchema: z.ZodType = - z - .object({ - materialized_features: z - .array(z.lazy(() => unmarshalMaterializedFeatureSchema)) - .optional(), - }) - .transform(d => ({ - materializedFeatures: d.materialized_features, - })); +export const unmarshalBatchCreateMaterializedFeaturesRequestSchema: z.ZodType = z + .object({ + requests: z.array(z.lazy(() => unmarshalCreateMaterializedFeatureRequestSchema)).optional(), + }) + .transform(d => ({ + requests: d.requests, + })); + +export const unmarshalBatchCreateMaterializedFeaturesResponseSchema: z.ZodType = z + .object({ + materialized_features: z.array(z.lazy(() => unmarshalMaterializedFeatureSchema)).optional(), + }) + .transform(d => ({ + materializedFeatures: d.materialized_features, + })); export const unmarshalColumnIdentifierSchema: z.ZodType = z .object({ @@ -773,14 +760,8 @@ export const unmarshalColumnSelectionSchema: z.ZodType = z export const unmarshalContinuousWindowSchema: z.ZodType = z .object({ - window_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - offset: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), + window_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + offset: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), }) .transform(d => ({ windowDuration: d.window_duration, @@ -795,40 +776,33 @@ export const unmarshalCountFunctionSchema: z.ZodType = z input: d.input, })); -export const unmarshalCreateFeatureRequestSchema: z.ZodType = - z - .object({ - feature: z.lazy(() => unmarshalFeatureSchema).optional(), - }) - .transform(d => ({ - feature: d.feature, - })); - -export const unmarshalCreateKafkaConfigRequestSchema: z.ZodType = - z - .object({ - kafka_config: z.lazy(() => unmarshalKafkaConfigSchema).optional(), - }) - .transform(d => ({ - kafkaConfig: d.kafka_config, - })); - -export const unmarshalCreateMaterializedFeatureRequestSchema: z.ZodType = - z - .object({ - materialized_feature: z - .lazy(() => unmarshalMaterializedFeatureSchema) - .optional(), - }) - .transform(d => ({ - materializedFeature: d.materialized_feature, - })); +export const unmarshalCreateFeatureRequestSchema: z.ZodType = z + .object({ + feature: z.lazy(() => unmarshalFeatureSchema).optional(), + }) + .transform(d => ({ + feature: d.feature, + })); + +export const unmarshalCreateKafkaConfigRequestSchema: z.ZodType = z + .object({ + kafka_config: z.lazy(() => unmarshalKafkaConfigSchema).optional(), + }) + .transform(d => ({ + kafkaConfig: d.kafka_config, + })); + +export const unmarshalCreateMaterializedFeatureRequestSchema: z.ZodType = z + .object({ + materialized_feature: z.lazy(() => unmarshalMaterializedFeatureSchema).optional(), + }) + .transform(d => ({ + materializedFeature: d.materialized_feature, + })); export const unmarshalDataSourceSchema: z.ZodType = z .object({ - delta_table_source: z - .lazy(() => unmarshalDeltaTableSourceSchema) - .optional(), + delta_table_source: z.lazy(() => unmarshalDeltaTableSourceSchema).optional(), kafka_source: z.lazy(() => unmarshalKafkaSourceSchema).optional(), request_source: z.lazy(() => unmarshalRequestSourceSchema).optional(), }) @@ -838,32 +812,29 @@ export const unmarshalDataSourceSchema: z.ZodType = z requestSource: d.request_source, })); -export const unmarshalDeleteFeatureRequestSchema: z.ZodType = - z - .object({ - full_name: z.string().optional(), - }) - .transform(d => ({ - fullName: d.full_name, - })); - -export const unmarshalDeleteKafkaConfigRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeleteMaterializedFeatureRequestSchema: z.ZodType = - z - .object({ - materialized_feature_id: z.string().optional(), - }) - .transform(d => ({ - materializedFeatureId: d.materialized_feature_id, - })); +export const unmarshalDeleteFeatureRequestSchema: z.ZodType = z + .object({ + full_name: z.string().optional(), + }) + .transform(d => ({ + fullName: d.full_name, + })); + +export const unmarshalDeleteKafkaConfigRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeleteMaterializedFeatureRequestSchema: z.ZodType = z + .object({ + materialized_feature_id: z.string().optional(), + }) + .transform(d => ({ + materializedFeatureId: d.materialized_feature_id, + })); export const unmarshalDeltaTableSourceSchema: z.ZodType = z .object({ @@ -946,12 +917,8 @@ export const unmarshalFlatSchemaSchema: z.ZodType = z export const unmarshalFunctionSchema: z.ZodType = z .object({ function_type: z.enum(Function_FunctionType).optional(), - extra_parameters: z - .array(z.lazy(() => unmarshalFunction_ExtraParameterSchema)) - .optional(), - aggregation_function: z - .lazy(() => unmarshalAggregationFunctionSchema) - .optional(), + extra_parameters: z.array(z.lazy(() => unmarshalFunction_ExtraParameterSchema)).optional(), + aggregation_function: z.lazy(() => unmarshalAggregationFunctionSchema).optional(), column_selection: z.lazy(() => unmarshalColumnSelectionSchema).optional(), }) .transform(d => ({ @@ -962,16 +929,15 @@ export const unmarshalFunctionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalFunction_ExtraParameterSchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalFunction_ExtraParameterSchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalGetFeatureRequestSchema: z.ZodType = z .object({ @@ -981,23 +947,21 @@ export const unmarshalGetFeatureRequestSchema: z.ZodType = z fullName: d.full_name, })); -export const unmarshalGetKafkaConfigRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalGetMaterializedFeatureRequestSchema: z.ZodType = - z - .object({ - materialized_feature_id: z.string().optional(), - }) - .transform(d => ({ - materializedFeatureId: d.materialized_feature_id, - })); +export const unmarshalGetKafkaConfigRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalGetMaterializedFeatureRequestSchema: z.ZodType = z + .object({ + materialized_feature_id: z.string().optional(), + }) + .transform(d => ({ + materializedFeatureId: d.materialized_feature_id, + })); export const unmarshalJobContextSchema: z.ZodType = z .object({ @@ -1032,26 +996,21 @@ export const unmarshalKafkaConfigSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalKafkaConfig_ExtraOptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalKafkaConfig_ExtraOptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalKafkaSourceSchema: z.ZodType = z .object({ name: z.string().optional(), - entity_column_identifiers: z - .array(z.lazy(() => unmarshalColumnIdentifierSchema)) - .optional(), - timeseries_column_identifier: z - .lazy(() => unmarshalColumnIdentifierSchema) - .optional(), + entity_column_identifiers: z.array(z.lazy(() => unmarshalColumnIdentifierSchema)).optional(), + timeseries_column_identifier: z.lazy(() => unmarshalColumnIdentifierSchema).optional(), filter_condition: z.string().optional(), }) .transform(d => ({ @@ -1079,111 +1038,91 @@ export const unmarshalLineageContextSchema: z.ZodType = z jobContext: d.job_context, })); -export const unmarshalListFeaturesRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListFeaturesResponseSchema: z.ZodType = - z - .object({ - features: z.array(z.lazy(() => unmarshalFeatureSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - features: d.features, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListKafkaConfigsRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListKafkaConfigsResponseSchema: z.ZodType = - z - .object({ - kafka_configs: z - .array(z.lazy(() => unmarshalKafkaConfigSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - kafkaConfigs: d.kafka_configs, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListMaterializedFeaturesRequestSchema: z.ZodType = - z - .object({ - feature_name: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - featureName: d.feature_name, - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListMaterializedFeaturesResponseSchema: z.ZodType = - z - .object({ - materialized_features: z - .array(z.lazy(() => unmarshalMaterializedFeatureSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - materializedFeatures: d.materialized_features, - nextPageToken: d.next_page_token, - })); - -export const unmarshalMaterializedFeatureSchema: z.ZodType = - z - .object({ - materialized_feature_id: z.string().optional(), - feature_name: z.string().optional(), - offline_store_config: z - .lazy(() => unmarshalOfflineStoreConfigSchema) - .optional(), - online_store_config: z - .lazy(() => unmarshalOnlineStoreConfigSchema) - .optional(), - table_name: z.string().optional(), - pipeline_schedule_state: z - .enum(MaterializedFeature_PipelineScheduleState) - .optional(), - last_materialization_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - cron_schedule: z.string().optional(), - is_online: z.boolean().optional(), - }) - .transform(d => ({ - materializedFeatureId: d.materialized_feature_id, - featureName: d.feature_name, - offlineStoreConfig: d.offline_store_config, - onlineStoreConfig: d.online_store_config, - tableName: d.table_name, - pipelineScheduleState: d.pipeline_schedule_state, - lastMaterializationTime: d.last_materialization_time, - cronSchedule: d.cron_schedule, - isOnline: d.is_online, - })); +export const unmarshalListFeaturesRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListFeaturesResponseSchema: z.ZodType = z + .object({ + features: z.array(z.lazy(() => unmarshalFeatureSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + features: d.features, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListKafkaConfigsRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListKafkaConfigsResponseSchema: z.ZodType = z + .object({ + kafka_configs: z.array(z.lazy(() => unmarshalKafkaConfigSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + kafkaConfigs: d.kafka_configs, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListMaterializedFeaturesRequestSchema: z.ZodType = z + .object({ + feature_name: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + featureName: d.feature_name, + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListMaterializedFeaturesResponseSchema: z.ZodType = z + .object({ + materialized_features: z.array(z.lazy(() => unmarshalMaterializedFeatureSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + materializedFeatures: d.materialized_features, + nextPageToken: d.next_page_token, + })); + +export const unmarshalMaterializedFeatureSchema: z.ZodType = z + .object({ + materialized_feature_id: z.string().optional(), + feature_name: z.string().optional(), + offline_store_config: z.lazy(() => unmarshalOfflineStoreConfigSchema).optional(), + online_store_config: z.lazy(() => unmarshalOnlineStoreConfigSchema).optional(), + table_name: z.string().optional(), + pipeline_schedule_state: z.enum(MaterializedFeature_PipelineScheduleState).optional(), + last_materialization_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + cron_schedule: z.string().optional(), + is_online: z.boolean().optional(), + }) + .transform(d => ({ + materializedFeatureId: d.materialized_feature_id, + featureName: d.feature_name, + offlineStoreConfig: d.offline_store_config, + onlineStoreConfig: d.online_store_config, + tableName: d.table_name, + pipelineScheduleState: d.pipeline_schedule_state, + lastMaterializationTime: d.last_materialization_time, + cronSchedule: d.cron_schedule, + isOnline: d.is_online, + })); export const unmarshalMaxFunctionSchema: z.ZodType = z .object({ @@ -1201,18 +1140,17 @@ export const unmarshalMinFunctionSchema: z.ZodType = z input: d.input, })); -export const unmarshalOfflineStoreConfigSchema: z.ZodType = - z - .object({ - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - table_name_prefix: z.string().optional(), - }) - .transform(d => ({ - catalogName: d.catalog_name, - schemaName: d.schema_name, - tableNamePrefix: d.table_name_prefix, - })); +export const unmarshalOfflineStoreConfigSchema: z.ZodType = z + .object({ + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + table_name_prefix: z.string().optional(), + }) + .transform(d => ({ + catalogName: d.catalog_name, + schemaName: d.schema_name, + tableNamePrefix: d.table_name_prefix, + })); export const unmarshalOnlineStoreConfigSchema: z.ZodType = z .object({ @@ -1246,14 +1184,8 @@ export const unmarshalSchemaConfigSchema: z.ZodType = z export const unmarshalSlidingWindowSchema: z.ZodType = z .object({ - window_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - slide_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), + window_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + slide_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), }) .transform(d => ({ windowDuration: d.window_duration, @@ -1268,14 +1200,13 @@ export const unmarshalStddevPopFunctionSchema: z.ZodType = z input: d.input, })); -export const unmarshalStddevSampFunctionSchema: z.ZodType = - z - .object({ - input: z.string().optional(), - }) - .transform(d => ({ - input: d.input, - })); +export const unmarshalStddevSampFunctionSchema: z.ZodType = z + .object({ + input: z.string().optional(), + }) + .transform(d => ({ + input: d.input, + })); export const unmarshalSubscriptionModeSchema: z.ZodType = z .object({ @@ -1319,49 +1250,41 @@ export const unmarshalTimeseriesColumnSchema: z.ZodType = z export const unmarshalTumblingWindowSchema: z.ZodType = z .object({ - window_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), + window_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), }) .transform(d => ({ windowDuration: d.window_duration, })); -export const unmarshalUpdateFeatureRequestSchema: z.ZodType = - z - .object({ - feature: z.lazy(() => unmarshalFeatureSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - feature: d.feature, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateKafkaConfigRequestSchema: z.ZodType = - z - .object({ - kafka_config: z.lazy(() => unmarshalKafkaConfigSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - kafkaConfig: d.kafka_config, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateMaterializedFeatureRequestSchema: z.ZodType = - z - .object({ - materialized_feature: z - .lazy(() => unmarshalMaterializedFeatureSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - materializedFeature: d.materialized_feature, - updateMask: d.update_mask, - })); +export const unmarshalUpdateFeatureRequestSchema: z.ZodType = z + .object({ + feature: z.lazy(() => unmarshalFeatureSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + feature: d.feature, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateKafkaConfigRequestSchema: z.ZodType = z + .object({ + kafka_config: z.lazy(() => unmarshalKafkaConfigSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + kafkaConfig: d.kafka_config, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateMaterializedFeatureRequestSchema: z.ZodType = z + .object({ + materialized_feature: z.lazy(() => unmarshalMaterializedFeatureSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + materializedFeature: d.materialized_feature, + updateMask: d.update_mask, + })); export const unmarshalVarPopFunctionSchema: z.ZodType = z .object({ @@ -1388,12 +1311,8 @@ export const marshalAggregationFunctionSchema: z.ZodType = z max: z.lazy(() => marshalMaxFunctionSchema).optional(), first: z.lazy(() => marshalFirstFunctionSchema).optional(), last: z.lazy(() => marshalLastFunctionSchema).optional(), - approxCountDistinct: z - .lazy(() => marshalApproxCountDistinctFunctionSchema) - .optional(), - approxPercentile: z - .lazy(() => marshalApproxPercentileFunctionSchema) - .optional(), + approxCountDistinct: z.lazy(() => marshalApproxCountDistinctFunctionSchema).optional(), + approxPercentile: z.lazy(() => marshalApproxPercentileFunctionSchema).optional(), stddevPop: z.lazy(() => marshalStddevPopFunctionSchema).optional(), stddevSamp: z.lazy(() => marshalStddevSampFunctionSchema).optional(), varPop: z.lazy(() => marshalVarPopFunctionSchema).optional(), @@ -1465,9 +1384,7 @@ export const marshalBackfillSourceSchema: z.ZodType = z export const marshalBatchCreateMaterializedFeaturesRequestSchema: z.ZodType = z .object({ - requests: z - .array(z.lazy(() => marshalCreateMaterializedFeatureRequestSchema)) - .optional(), + requests: z.array(z.lazy(() => marshalCreateMaterializedFeatureRequestSchema)).optional(), }) .transform(d => ({ requests: d.requests, @@ -1475,9 +1392,7 @@ export const marshalBatchCreateMaterializedFeaturesRequestSchema: z.ZodType = z export const marshalBatchCreateMaterializedFeaturesResponseSchema: z.ZodType = z .object({ - materializedFeatures: z - .array(z.lazy(() => marshalMaterializedFeatureSchema)) - .optional(), + materializedFeatures: z.array(z.lazy(() => marshalMaterializedFeatureSchema)).optional(), }) .transform(d => ({ materialized_features: d.materializedFeatures, @@ -1501,14 +1416,8 @@ export const marshalColumnSelectionSchema: z.ZodType = z export const marshalContinuousWindowSchema: z.ZodType = z .object({ - windowDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), - offset: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + windowDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), + offset: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), }) .transform(d => ({ window_duration: d.windowDuration, @@ -1541,9 +1450,7 @@ export const marshalCreateKafkaConfigRequestSchema: z.ZodType = z export const marshalCreateMaterializedFeatureRequestSchema: z.ZodType = z .object({ - materializedFeature: z - .lazy(() => marshalMaterializedFeatureSchema) - .optional(), + materializedFeature: z.lazy(() => marshalMaterializedFeatureSchema).optional(), }) .transform(d => ({ materialized_feature: d.materializedFeature, @@ -1666,12 +1573,8 @@ export const marshalFlatSchemaSchema: z.ZodType = z export const marshalFunctionSchema: z.ZodType = z .object({ functionType: z.enum(Function_FunctionType).optional(), - extraParameters: z - .array(z.lazy(() => marshalFunction_ExtraParameterSchema)) - .optional(), - aggregationFunction: z - .lazy(() => marshalAggregationFunctionSchema) - .optional(), + extraParameters: z.array(z.lazy(() => marshalFunction_ExtraParameterSchema)).optional(), + aggregationFunction: z.lazy(() => marshalAggregationFunctionSchema).optional(), columnSelection: z.lazy(() => marshalColumnSelectionSchema).optional(), }) .transform(d => ({ @@ -1762,12 +1665,8 @@ export const marshalKafkaConfig_ExtraOptionsEntrySchema: z.ZodType = z export const marshalKafkaSourceSchema: z.ZodType = z .object({ name: z.string().optional(), - entityColumnIdentifiers: z - .array(z.lazy(() => marshalColumnIdentifierSchema)) - .optional(), - timeseriesColumnIdentifier: z - .lazy(() => marshalColumnIdentifierSchema) - .optional(), + entityColumnIdentifiers: z.array(z.lazy(() => marshalColumnIdentifierSchema)).optional(), + timeseriesColumnIdentifier: z.lazy(() => marshalColumnIdentifierSchema).optional(), filterCondition: z.string().optional(), }) .transform(d => ({ @@ -1849,9 +1748,7 @@ export const marshalListMaterializedFeaturesRequestSchema: z.ZodType = z export const marshalListMaterializedFeaturesResponseSchema: z.ZodType = z .object({ - materializedFeatures: z - .array(z.lazy(() => marshalMaterializedFeatureSchema)) - .optional(), + materializedFeatures: z.array(z.lazy(() => marshalMaterializedFeatureSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -1863,18 +1760,11 @@ export const marshalMaterializedFeatureSchema: z.ZodType = z .object({ materializedFeatureId: z.string().optional(), featureName: z.string().optional(), - offlineStoreConfig: z - .lazy(() => marshalOfflineStoreConfigSchema) - .optional(), + offlineStoreConfig: z.lazy(() => marshalOfflineStoreConfigSchema).optional(), onlineStoreConfig: z.lazy(() => marshalOnlineStoreConfigSchema).optional(), tableName: z.string().optional(), - pipelineScheduleState: z - .enum(MaterializedFeature_PipelineScheduleState) - .optional(), - lastMaterializationTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + pipelineScheduleState: z.enum(MaterializedFeature_PipelineScheduleState).optional(), + lastMaterializationTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), cronSchedule: z.string().optional(), isOnline: z.boolean().optional(), }) @@ -1950,14 +1840,8 @@ export const marshalSchemaConfigSchema: z.ZodType = z export const marshalSlidingWindowSchema: z.ZodType = z .object({ - windowDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), - slideDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + windowDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), + slideDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), }) .transform(d => ({ window_duration: d.windowDuration, @@ -2022,10 +1906,7 @@ export const marshalTimeseriesColumnSchema: z.ZodType = z export const marshalTumblingWindowSchema: z.ZodType = z .object({ - windowDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + windowDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), }) .transform(d => ({ window_duration: d.windowDuration, @@ -2034,7 +1915,7 @@ export const marshalTumblingWindowSchema: z.ZodType = z export const marshalUpdateFeatureRequestSchema: z.ZodType = z .object({ feature: z.lazy(() => marshalFeatureSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ feature: d.feature, @@ -2044,7 +1925,7 @@ export const marshalUpdateFeatureRequestSchema: z.ZodType = z export const marshalUpdateKafkaConfigRequestSchema: z.ZodType = z .object({ kafkaConfig: z.lazy(() => marshalKafkaConfigSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ kafka_config: d.kafkaConfig, @@ -2053,10 +1934,8 @@ export const marshalUpdateKafkaConfigRequestSchema: z.ZodType = z export const marshalUpdateMaterializedFeatureRequestSchema: z.ZodType = z .object({ - materializedFeature: z - .lazy(() => marshalMaterializedFeatureSchema) - .optional(), - updateMask: z.string().optional(), + materializedFeature: z.lazy(() => marshalMaterializedFeatureSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ materialized_feature: d.materializedFeature, diff --git a/packages/features/src/v1/utils.ts b/packages/features/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/features/src/v1/utils.ts +++ b/packages/features/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/features/tsconfig.json b/packages/features/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/features/tsconfig.json +++ b/packages/features/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/featurestore/package.json b/packages/featurestore/package.json index f89b5d4d..4e5c792a 100644 --- a/packages/featurestore/package.json +++ b/packages/featurestore/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/featurestore/src/v1/client.ts b/packages/featurestore/src/v1/client.ts index c85746bd..e9dd5490 100644 --- a/packages/featurestore/src/v1/client.ts +++ b/packages/featurestore/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateOnlineStoreRequest, DeleteOnlineStoreRequest, @@ -48,21 +43,13 @@ export class Client { } /** Create an Online Feature Store. */ - async createOnlineStore( - signal: AbortSignal | undefined, - req: CreateOnlineStoreRequest, - options?: Options - ): Promise { + async createOnlineStore(signal: AbortSignal | undefined, req: CreateOnlineStoreRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/online-stores`; const body = marshalRequest(req.onlineStore, marshalOnlineStoreSchema); let resp: OnlineStore | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOnlineStoreSchema); }; await execute(signal, call, options); @@ -73,56 +60,32 @@ export class Client { } /** Delete an Online Feature Store. */ - async deleteOnlineStore( - signal: AbortSignal | undefined, - req: DeleteOnlineStoreRequest, - options?: Options - ): Promise { + async deleteOnlineStore(signal: AbortSignal | undefined, req: DeleteOnlineStoreRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/online-stores/${req.name ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Delete online table. */ - async deleteOnlineTable( - signal: AbortSignal | undefined, - req: DeleteOnlineTableRequest, - options?: Options - ): Promise { + async deleteOnlineTable(signal: AbortSignal | undefined, req: DeleteOnlineTableRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/online-tables/${req.onlineTableName ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Get an Online Feature Store. */ - async getOnlineStore( - signal: AbortSignal | undefined, - req: GetOnlineStoreRequest, - options?: Options - ): Promise { + async getOnlineStore(signal: AbortSignal | undefined, req: GetOnlineStoreRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/online-stores/${req.name ?? ''}`; let resp: OnlineStore | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOnlineStoreSchema); }; await execute(signal, call, options); @@ -133,11 +96,7 @@ export class Client { } /** List Online Feature Stores. */ - async listOnlineStores( - signal: AbortSignal | undefined, - req: ListOnlineStoresRequest, - options?: Options - ): Promise { + async listOnlineStores(signal: AbortSignal | undefined, req: ListOnlineStoresRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/online-stores`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -151,11 +110,7 @@ export class Client { let resp: ListOnlineStoresResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListOnlineStoresResponseSchema); }; await execute(signal, call, options); @@ -165,11 +120,8 @@ export class Client { return resp; } - async *listOnlineStoresIter( - signal: AbortSignal | undefined, - req: ListOnlineStoresRequest, - options?: Options - ): AsyncGenerator { + + async *listOnlineStoresIter(signal: AbortSignal | undefined, req: ListOnlineStoresRequest, options?: Options): AsyncGenerator { const pageReq: ListOnlineStoresRequest = {...req}; for (;;) { const resp = await this.listOnlineStores(signal, pageReq, options); @@ -183,22 +135,15 @@ export class Client { } } + /** Publish features. */ - async publishTable( - signal: AbortSignal | undefined, - req: PublishTableRequest, - options?: Options - ): Promise { + async publishTable(signal: AbortSignal | undefined, req: PublishTableRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/tables/${req.sourceTableName ?? ''}/publish`; const body = marshalRequest(req, marshalPublishTableRequestSchema); let resp: PublishTableResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPublishTableResponseSchema); }; await execute(signal, call, options); @@ -209,15 +154,11 @@ export class Client { } /** Update an Online Feature Store. */ - async updateOnlineStore( - signal: AbortSignal | undefined, - req: UpdateOnlineStoreRequest, - options?: Options - ): Promise { + async updateOnlineStore(signal: AbortSignal | undefined, req: UpdateOnlineStoreRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/online-stores/${req.onlineStore?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -225,11 +166,7 @@ export class Client { let resp: OnlineStore | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOnlineStoreSchema); }; await execute(signal, call, options); diff --git a/packages/featurestore/src/v1/index.ts b/packages/featurestore/src/v1/index.ts index f643a9de..79daafad 100644 --- a/packages/featurestore/src/v1/index.ts +++ b/packages/featurestore/src/v1/index.ts @@ -1,8 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {OnlineStore_State, PublishSpec_PublishMode} from './model'; +export { + OnlineStore_State, + PublishSpec_PublishMode, +} from './model'; export type { CreateOnlineStoreRequest, diff --git a/packages/featurestore/src/v1/model.ts b/packages/featurestore/src/v1/model.ts index 9b31f7ce..028322ba 100644 --- a/packages/featurestore/src/v1/model.ts +++ b/packages/featurestore/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested enum name. @@ -121,77 +123,66 @@ export interface UpdateOnlineStoreRequest { /** Online store to update. */ onlineStore?: OnlineStore | undefined; /** The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } -export const unmarshalCreateOnlineStoreRequestSchema: z.ZodType = - z - .object({ - online_store: z.lazy(() => unmarshalOnlineStoreSchema).optional(), - }) - .transform(d => ({ - onlineStore: d.online_store, - })); - -export const unmarshalDeleteOnlineStoreRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeleteOnlineTableRequestSchema: z.ZodType = - z - .object({ - online_table_name: z.string().optional(), - }) - .transform(d => ({ - onlineTableName: d.online_table_name, - })); - -export const unmarshalGetOnlineStoreRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalListOnlineStoresRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListOnlineStoresResponseSchema: z.ZodType = - z - .object({ - online_stores: z - .array(z.lazy(() => unmarshalOnlineStoreSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - onlineStores: d.online_stores, - nextPageToken: d.next_page_token, - })); +export const unmarshalCreateOnlineStoreRequestSchema: z.ZodType = z + .object({ + online_store: z.lazy(() => unmarshalOnlineStoreSchema).optional(), + }) + .transform(d => ({ + onlineStore: d.online_store, + })); + +export const unmarshalDeleteOnlineStoreRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeleteOnlineTableRequestSchema: z.ZodType = z + .object({ + online_table_name: z.string().optional(), + }) + .transform(d => ({ + onlineTableName: d.online_table_name, + })); + +export const unmarshalGetOnlineStoreRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalListOnlineStoresRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListOnlineStoresResponseSchema: z.ZodType = z + .object({ + online_stores: z.array(z.lazy(() => unmarshalOnlineStoreSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + onlineStores: d.online_stores, + nextPageToken: d.next_page_token, + })); export const unmarshalOnlineStoreSchema: z.ZodType = z .object({ name: z.string().optional(), creator: z.string().optional(), - creation_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + creation_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), state: z.enum(OnlineStore_State).optional(), capacity: z.string().optional(), read_replica_count: z.number().optional(), @@ -219,38 +210,35 @@ export const unmarshalPublishSpecSchema: z.ZodType = z publishMode: d.publish_mode, })); -export const unmarshalPublishTableRequestSchema: z.ZodType = - z - .object({ - source_table_name: z.string().optional(), - publish_spec: z.lazy(() => unmarshalPublishSpecSchema).optional(), - }) - .transform(d => ({ - sourceTableName: d.source_table_name, - publishSpec: d.publish_spec, - })); - -export const unmarshalPublishTableResponseSchema: z.ZodType = - z - .object({ - online_table_name: z.string().optional(), - pipeline_id: z.string().optional(), - }) - .transform(d => ({ - onlineTableName: d.online_table_name, - pipelineId: d.pipeline_id, - })); - -export const unmarshalUpdateOnlineStoreRequestSchema: z.ZodType = - z - .object({ - online_store: z.lazy(() => unmarshalOnlineStoreSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - onlineStore: d.online_store, - updateMask: d.update_mask, - })); +export const unmarshalPublishTableRequestSchema: z.ZodType = z + .object({ + source_table_name: z.string().optional(), + publish_spec: z.lazy(() => unmarshalPublishSpecSchema).optional(), + }) + .transform(d => ({ + sourceTableName: d.source_table_name, + publishSpec: d.publish_spec, + })); + +export const unmarshalPublishTableResponseSchema: z.ZodType = z + .object({ + online_table_name: z.string().optional(), + pipeline_id: z.string().optional(), + }) + .transform(d => ({ + onlineTableName: d.online_table_name, + pipelineId: d.pipeline_id, + })); + +export const unmarshalUpdateOnlineStoreRequestSchema: z.ZodType = z + .object({ + online_store: z.lazy(() => unmarshalOnlineStoreSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + onlineStore: d.online_store, + updateMask: d.update_mask, + })); export const marshalCreateOnlineStoreRequestSchema: z.ZodType = z .object({ @@ -308,10 +296,7 @@ export const marshalOnlineStoreSchema: z.ZodType = z .object({ name: z.string().optional(), creator: z.string().optional(), - creationTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + creationTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), state: z.enum(OnlineStore_State).optional(), capacity: z.string().optional(), readReplicaCount: z.number().optional(), @@ -362,7 +347,7 @@ export const marshalPublishTableResponseSchema: z.ZodType = z export const marshalUpdateOnlineStoreRequestSchema: z.ZodType = z .object({ onlineStore: z.lazy(() => marshalOnlineStoreSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ online_store: d.onlineStore, diff --git a/packages/featurestore/src/v1/utils.ts b/packages/featurestore/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/featurestore/src/v1/utils.ts +++ b/packages/featurestore/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/featurestore/tsconfig.json b/packages/featurestore/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/featurestore/tsconfig.json +++ b/packages/featurestore/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/files/package.json b/packages/files/package.json index eef0d8b5..e359da06 100644 --- a/packages/files/package.json +++ b/packages/files/package.json @@ -1,12 +1,12 @@ { "name": "@databricks/sdk-files", "version": "0.1.0", - "description": "Databricks Files service client", + "description": "", "type": "module", "exports": { - "./v1": { - "types": "./dist/v1/index.d.ts", - "import": "./dist/v1/index.js" + "./v2": { + "types": "./dist/v2/index.d.ts", + "import": "./dist/v2/index.js" } }, "files": [ @@ -15,19 +15,22 @@ ], "scripts": { "build": "tsc -b", - "lint": "eslint src tests --ext .ts", - "lint:fix": "eslint src tests --ext .ts --fix", - "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"", - "format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", "typecheck": "tsc --noEmit", "clean": "rm -rf dist tsconfig.tsbuildinfo", - "test": "vitest run", - "test:browser": "vitest run --config vitest.config.browser.ts" + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" }, "author": "Databricks", "license": "Apache-2.0", "dependencies": { - "@databricks/sdk-databricks": "*" + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" }, "engines": { "node": ">=22.0.0" diff --git a/packages/files/src/v2/client.ts b/packages/files/src/v2/client.ts new file mode 100644 index 00000000..99428cfd --- /dev/null +++ b/packages/files/src/v2/client.ts @@ -0,0 +1,330 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + AddBlock, + AddBlock_Response, + Close, + Close_Response, + Create, + Create_Response, + Delete, + Delete_Response, + GetStatus, + GetStatus_Response, + ListStatus, + ListStatus_Response, + MkDirs, + MkDirs_Response, + Move, + Move_Response, + Put, + Put_Response, + Read, + Read_Response, +} from './model'; +import { + marshalAddBlockSchema, + marshalCloseSchema, + marshalCreateSchema, + marshalDeleteSchema, + marshalMkDirsSchema, + marshalMoveSchema, + marshalPutSchema, + unmarshalAddBlock_ResponseSchema, + unmarshalClose_ResponseSchema, + unmarshalCreate_ResponseSchema, + unmarshalDelete_ResponseSchema, + unmarshalGetStatus_ResponseSchema, + unmarshalListStatus_ResponseSchema, + unmarshalMkDirs_ResponseSchema, + unmarshalMove_ResponseSchema, + unmarshalPut_ResponseSchema, + unmarshalRead_ResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** + * Appends a block of data to the stream specified by the input handle. If the handle does not + * exist, this call will throw an exception with ``RESOURCE_DOES_NOT_EXIST``. + * + * If the block of data exceeds 1 MB, this call will throw an exception with ``MAX_BLOCK_SIZE_EXCEEDED``. + */ + async addBlock(signal: AbortSignal | undefined, req: AddBlock, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/add-block`; + const body = marshalRequest(req, marshalAddBlockSchema); + let resp: AddBlock_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalAddBlock_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Closes the stream specified by the input handle. If the handle does not exist, this call + * throws an exception with ``RESOURCE_DOES_NOT_EXIST``. + */ + async close(signal: AbortSignal | undefined, req: Close, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/close`; + const body = marshalRequest(req, marshalCloseSchema); + let resp: Close_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalClose_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Opens a stream to write to a file and returns a handle to this stream. + * There is a 10 minute idle timeout on this handle. If a file or directory already exists on the given path + * and __overwrite__ is set to false, this call will throw an exception with ``RESOURCE_ALREADY_EXISTS``. + * + * A typical workflow for file upload would be: + * + * 1. Issue a ``create`` call and get a handle. + * 2. Issue one or more ``add-block`` calls with the handle you have. + * 3. Issue a ``close`` call with the handle you have. + */ + async create(signal: AbortSignal | undefined, req: Create, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/create`; + const body = marshalRequest(req, marshalCreateSchema); + let resp: Create_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreate_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Delete the file or directory (optionally recursively delete all files in the directory). + * This call throws an exception with `IO_ERROR` if the path is a non-empty directory and `recursive` is set to + * `false` or on other similar errors. + * + * When you delete a large number of files, the delete operation is done in increments. The call returns + * a response after approximately 45 seconds with an error message (503 Service Unavailable) asking you to + * re-invoke the delete operation until the directory structure is fully deleted. + * + * For operations that delete more than 10K files, we discourage using the DBFS REST API, but advise you to + * perform such operations in the context of a cluster, using + * the [File system utility (dbutils.fs)](/dev-tools/databricks-utils.html#dbutils-fs). `dbutils.fs` + * covers the functional scope of the DBFS REST API, but from notebooks. Running such operations using notebooks + * provides better control and manageability, such as selective deletes, and the possibility to automate periodic + * delete jobs. + */ + async delete(signal: AbortSignal | undefined, req: Delete, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/delete`; + const body = marshalRequest(req, marshalDeleteSchema); + let resp: Delete_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDelete_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Gets the file information for a file or directory. + * If the file or directory does not exist, this call throws an exception with `RESOURCE_DOES_NOT_EXIST`. + */ + async getStatus(signal: AbortSignal | undefined, req: GetStatus, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/get-status`; + const params = new URLSearchParams(); + if (req.path !== undefined) { + params.append('path', req.path); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: GetStatus_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetStatus_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * List the contents of a directory, or details of the file. If the file or directory does not exist, this call + * throws an exception with `RESOURCE_DOES_NOT_EXIST`. + * + * When calling list on a large directory, the list operation will time out after approximately 60 seconds. + * We strongly recommend using list only on directories containing less than 10K files and discourage using + * the DBFS REST API for operations that list more than 10K files. Instead, we recommend that you perform such + * operations in the context of a cluster, using + * the [File system utility (dbutils.fs)](/dev-tools/databricks-utils.html#dbutils-fs), which provides the same + * functionality without timing out. + */ + async list(signal: AbortSignal | undefined, req: ListStatus, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/list`; + const params = new URLSearchParams(); + if (req.path !== undefined) { + params.append('path', req.path); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListStatus_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListStatus_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Creates the given directory and necessary parent directories if they do not exist. + * If a file (not a directory) exists at any prefix of the input path, this call throws an exception with `RESOURCE_ALREADY_EXISTS`. + * **Note**: If this operation fails, it might have succeeded in creating some of the necessary parent directories. + */ + async mkdirs(signal: AbortSignal | undefined, req: MkDirs, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/mkdirs`; + const body = marshalRequest(req, marshalMkDirsSchema); + let resp: MkDirs_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalMkDirs_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Moves a file from one location to another location within DBFS. + * If the source file does not exist, this call throws an exception with `RESOURCE_DOES_NOT_EXIST`. + * If a file already exists in the destination path, this call throws an exception with `RESOURCE_ALREADY_EXISTS`. + * If the given source path is a directory, this call always recursively moves all files. + */ + async move(signal: AbortSignal | undefined, req: Move, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/move`; + const body = marshalRequest(req, marshalMoveSchema); + let resp: Move_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalMove_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Uploads a file through the use of multipart form post. + * It is mainly used for streaming uploads, but can also be used as a convenient single call for data upload. + * + * Alternatively you can pass contents as base64 string. + * + * The amount of data that can be passed (when not streaming) using the __contents__ parameter is limited to 1 MB. + * `MAX_BLOCK_SIZE_EXCEEDED` will be thrown if this limit is exceeded. + * + * If you want to upload large files, use the streaming upload. For details, see :method:dbfs/create, + * :method:dbfs/addBlock, :method:dbfs/close. + */ + async put(signal: AbortSignal | undefined, req: Put, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/put`; + const body = marshalRequest(req, marshalPutSchema); + let resp: Put_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalPut_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Returns the contents of a file. If the file does not exist, this call throws an exception with `RESOURCE_DOES_NOT_EXIST`. + * If the path is a directory, the read length is negative, or if the offset is negative, this call throws an exception with + * `INVALID_PARAMETER_VALUE`. If the read length exceeds 1 MB, this call throws an + * exception with `MAX_READ_SIZE_EXCEEDED`. + * + * If `offset + length` exceeds the number of bytes in a file, it reads the contents until the end of file. + */ + async read(signal: AbortSignal | undefined, req: Read, options?: Options): Promise { + const url = `${this.host}/api/2.0/dbfs/read`; + const params = new URLSearchParams(); + if (req.path !== undefined) { + params.append('path', req.path); + } + if (req.offset !== undefined) { + params.append('offset', String(req.offset)); + } + if (req.length !== undefined) { + params.append('length', String(req.length)); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: Read_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalRead_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/files/src/v2/index.ts b/packages/files/src/v2/index.ts new file mode 100644 index 00000000..18d422f8 --- /dev/null +++ b/packages/files/src/v2/index.ts @@ -0,0 +1,31 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { +} from './model'; + +export type { + AddBlock, + AddBlock_Response, + Close, + Close_Response, + Create, + Create_Response, + Delete, + Delete_Response, + FileInfo, + GetStatus, + GetStatus_Response, + ListStatus, + ListStatus_Response, + MkDirs, + MkDirs_Response, + Move, + Move_Response, + Put, + Put_Response, + Read, + Read_Response, +} from './model'; diff --git a/packages/files/src/v2/model.ts b/packages/files/src/v2/model.ts new file mode 100644 index 00000000..60a3bb7e --- /dev/null +++ b/packages/files/src/v2/model.ts @@ -0,0 +1,505 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +export interface AddBlock { + /** The handle on an open stream. */ + handle?: number | undefined; + /** The base64-encoded data to append to the stream. This has a limit of 1 MB. */ + data?: Uint8Array | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface AddBlock_Response {} + +export interface Close { + /** The handle on an open stream. */ + handle?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface Close_Response {} + +export interface Create { + /** The path of the new file. The path should be the absolute DBFS path. */ + path?: string | undefined; + /** The flag that specifies whether to overwrite existing file/files. */ + overwrite?: boolean | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface Create_Response { + /** Handle which should subsequently be passed into the AddBlock and Close calls when writing to a file through a stream. */ + handle?: number | undefined; +} + +export interface Delete { + /** The path of the file or directory to delete. The path should be the absolute DBFS path. */ + path?: string | undefined; + /** Whether or not to recursively delete the directory's contents. Deleting empty directories can be done without providing the recursive flag. */ + recursive?: boolean | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface Delete_Response {} + +/** Stores the attributes of a file or directory. */ +export interface FileInfo { + /** The absolute path of the file or directory. */ + path?: string | undefined; + /** True if the path is a directory. */ + isDir?: boolean | undefined; + /** The length of the file in bytes. This field is omitted for directories. */ + fileSize?: number | undefined; + /** Last modification time of given file in milliseconds since epoch. */ + modificationTime?: number | undefined; +} + +export interface GetStatus { + /** The path of the file or directory. The path should be the absolute DBFS path. */ + path?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetStatus_Response { + /** The absolute path of the file or directory. */ + path?: string | undefined; + /** True if the path is a directory. */ + isDir?: boolean | undefined; + /** The length of the file in bytes. This field is omitted for directories. */ + fileSize?: number | undefined; + /** Last modification time of given file in milliseconds since epoch. */ + modificationTime?: number | undefined; +} + +export interface ListStatus { + /** The path of the file or directory. The path should be the absolute DBFS path. */ + path?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListStatus_Response { + /** A list of FileInfo's that describe contents of directory or file. See example above. */ + files?: FileInfo[] | undefined; +} + +export interface MkDirs { + /** The path of the new directory. The path should be the absolute DBFS path. */ + path?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface MkDirs_Response {} + +export interface Move { + /** The source path of the file or directory. The path should be the absolute DBFS path. */ + sourcePath?: string | undefined; + /** The destination path of the file or directory. The path should be the absolute DBFS path. */ + destinationPath?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface Move_Response {} + +export interface Put { + /** The path of the new file. The path should be the absolute DBFS path. */ + path?: string | undefined; + /** This parameter might be absent, and instead a posted file will be used. */ + contents?: Uint8Array | undefined; + /** The flag that specifies whether to overwrite existing file/files. */ + overwrite?: boolean | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface Put_Response {} + +export interface Read { + /** The path of the file to read. The path should be the absolute DBFS path. */ + path?: string | undefined; + /** The offset to read from in bytes. */ + offset?: number | undefined; + /** + * 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?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface Read_Response { + /** + * 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?: number | undefined; + /** The base64-encoded contents of the file read. */ + data?: Uint8Array | undefined; +} + +export const unmarshalAddBlockSchema: z.ZodType = z + .object({ + handle: z.number().optional(), + data: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + }) + .transform(d => ({ + handle: d.handle, + data: d.data, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalAddBlock_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalCloseSchema: z.ZodType = z + .object({ + handle: z.number().optional(), + }) + .transform(d => ({ + handle: d.handle, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalClose_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalCreateSchema: z.ZodType = z + .object({ + path: z.string().optional(), + overwrite: z.boolean().optional(), + }) + .transform(d => ({ + path: d.path, + overwrite: d.overwrite, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreate_ResponseSchema: z.ZodType = z + .object({ + handle: z.number().optional(), + }) + .transform(d => ({ + handle: d.handle, + })); + +export const unmarshalDeleteSchema: z.ZodType = z + .object({ + path: z.string().optional(), + recursive: z.boolean().optional(), + }) + .transform(d => ({ + path: d.path, + recursive: d.recursive, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDelete_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalFileInfoSchema: z.ZodType = z + .object({ + path: z.string().optional(), + is_dir: z.boolean().optional(), + file_size: z.number().optional(), + modification_time: z.number().optional(), + }) + .transform(d => ({ + path: d.path, + isDir: d.is_dir, + fileSize: d.file_size, + modificationTime: d.modification_time, + })); + +export const unmarshalGetStatusSchema: z.ZodType = z + .object({ + path: z.string().optional(), + }) + .transform(d => ({ + path: d.path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetStatus_ResponseSchema: z.ZodType = z + .object({ + path: z.string().optional(), + is_dir: z.boolean().optional(), + file_size: z.number().optional(), + modification_time: z.number().optional(), + }) + .transform(d => ({ + path: d.path, + isDir: d.is_dir, + fileSize: d.file_size, + modificationTime: d.modification_time, + })); + +export const unmarshalListStatusSchema: z.ZodType = z + .object({ + path: z.string().optional(), + }) + .transform(d => ({ + path: d.path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListStatus_ResponseSchema: z.ZodType = z + .object({ + files: z.array(z.lazy(() => unmarshalFileInfoSchema)).optional(), + }) + .transform(d => ({ + files: d.files, + })); + +export const unmarshalMkDirsSchema: z.ZodType = z + .object({ + path: z.string().optional(), + }) + .transform(d => ({ + path: d.path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalMkDirs_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalMoveSchema: z.ZodType = z + .object({ + source_path: z.string().optional(), + destination_path: z.string().optional(), + }) + .transform(d => ({ + sourcePath: d.source_path, + destinationPath: d.destination_path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalMove_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalPutSchema: z.ZodType = z + .object({ + path: z.string().optional(), + contents: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + overwrite: z.boolean().optional(), + }) + .transform(d => ({ + path: d.path, + contents: d.contents, + overwrite: d.overwrite, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalPut_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalReadSchema: z.ZodType = z + .object({ + path: z.string().optional(), + offset: z.number().optional(), + length: z.number().optional(), + }) + .transform(d => ({ + path: d.path, + offset: d.offset, + length: d.length, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalRead_ResponseSchema: z.ZodType = z + .object({ + bytes_read: z.number().optional(), + data: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + }) + .transform(d => ({ + bytesRead: d.bytes_read, + data: d.data, + })); + +export const marshalAddBlockSchema: z.ZodType = z + .object({ + handle: z.number().optional(), + data: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + }) + .transform(d => ({ + handle: d.handle, + data: d.data, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalAddBlock_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalCloseSchema: z.ZodType = z + .object({ + handle: z.number().optional(), + }) + .transform(d => ({ + handle: d.handle, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalClose_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalCreateSchema: z.ZodType = z + .object({ + path: z.string().optional(), + overwrite: z.boolean().optional(), + }) + .transform(d => ({ + path: d.path, + overwrite: d.overwrite, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreate_ResponseSchema: z.ZodType = z + .object({ + handle: z.number().optional(), + }) + .transform(d => ({ + handle: d.handle, + })); + +export const marshalDeleteSchema: z.ZodType = z + .object({ + path: z.string().optional(), + recursive: z.boolean().optional(), + }) + .transform(d => ({ + path: d.path, + recursive: d.recursive, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDelete_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalFileInfoSchema: z.ZodType = z + .object({ + path: z.string().optional(), + isDir: z.boolean().optional(), + fileSize: z.number().optional(), + modificationTime: z.number().optional(), + }) + .transform(d => ({ + path: d.path, + is_dir: d.isDir, + file_size: d.fileSize, + modification_time: d.modificationTime, + })); + +export const marshalGetStatusSchema: z.ZodType = z + .object({ + path: z.string().optional(), + }) + .transform(d => ({ + path: d.path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetStatus_ResponseSchema: z.ZodType = z + .object({ + path: z.string().optional(), + isDir: z.boolean().optional(), + fileSize: z.number().optional(), + modificationTime: z.number().optional(), + }) + .transform(d => ({ + path: d.path, + is_dir: d.isDir, + file_size: d.fileSize, + modification_time: d.modificationTime, + })); + +export const marshalListStatusSchema: z.ZodType = z + .object({ + path: z.string().optional(), + }) + .transform(d => ({ + path: d.path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListStatus_ResponseSchema: z.ZodType = z + .object({ + files: z.array(z.lazy(() => marshalFileInfoSchema)).optional(), + }) + .transform(d => ({ + files: d.files, + })); + +export const marshalMkDirsSchema: z.ZodType = z + .object({ + path: z.string().optional(), + }) + .transform(d => ({ + path: d.path, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalMkDirs_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalMoveSchema: z.ZodType = z + .object({ + sourcePath: z.string().optional(), + destinationPath: z.string().optional(), + }) + .transform(d => ({ + source_path: d.sourcePath, + destination_path: d.destinationPath, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalMove_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalPutSchema: z.ZodType = z + .object({ + path: z.string().optional(), + contents: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + overwrite: z.boolean().optional(), + }) + .transform(d => ({ + path: d.path, + contents: d.contents, + overwrite: d.overwrite, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalPut_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalReadSchema: z.ZodType = z + .object({ + path: z.string().optional(), + offset: z.number().optional(), + length: z.number().optional(), + }) + .transform(d => ({ + path: d.path, + offset: d.offset, + length: d.length, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalRead_ResponseSchema: z.ZodType = z + .object({ + bytesRead: z.number().optional(), + data: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + }) + .transform(d => ({ + bytes_read: d.bytesRead, + data: d.data, + })); diff --git a/packages/files/src/v2/utils.ts b/packages/files/src/v2/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/files/src/v2/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/files/tsconfig.json b/packages/files/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/files/tsconfig.json +++ b/packages/files/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/functions/package.json b/packages/functions/package.json index fc6e99d4..a2028620 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/functions/src/v1/client.ts b/packages/functions/src/v1/client.ts index 23aaafa6..9f156218 100644 --- a/packages/functions/src/v1/client.ts +++ b/packages/functions/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateFunctionRequest, DeleteFunction, @@ -47,28 +42,20 @@ export class Client { /** * **WARNING: This API is experimental and will change in future versions** - * + * * Creates a new function - * + * * The user must have the following permissions in order for the function to be created: * - **USE_CATALOG** on the function's parent catalog * - **USE_SCHEMA** and **CREATE_FUNCTION** on the function's parent schema */ - async createFunction( - signal: AbortSignal | undefined, - req: CreateFunctionRequest, - options?: Options - ): Promise { + async createFunction(signal: AbortSignal | undefined, req: CreateFunctionRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/functions`; const body = marshalRequest(req, marshalCreateFunctionRequestSchema); let resp: FunctionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFunctionInfoSchema); }; await execute(signal, call, options); @@ -85,11 +72,7 @@ export class Client { * - Is the owner of the function's parent schema and have the **USE_CATALOG** privilege on its parent catalog * - Is the owner of the function itself and have both the **USE_CATALOG** privilege on its parent catalog and the **USE_SCHEMA** privilege on its parent schema */ - async deleteFunction( - signal: AbortSignal | undefined, - req: DeleteFunction, - options?: Options - ): Promise { + async deleteFunction(signal: AbortSignal | undefined, req: DeleteFunction, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -100,11 +83,7 @@ export class Client { let resp: DeleteFunction_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteFunction_ResponseSchema); }; await execute(signal, call, options); @@ -122,11 +101,7 @@ export class Client { * - Have the **USE_CATALOG** privilege on the function's parent catalog and be the owner of the function * - Have the **USE_CATALOG** privilege on the function's parent catalog, the **USE_SCHEMA** privilege on the function's parent schema, and the **EXECUTE** privilege on the function itself */ - async getFunction( - signal: AbortSignal | undefined, - req: GetFunction, - options?: Options - ): Promise { + async getFunction(signal: AbortSignal | undefined, req: GetFunction, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -137,11 +112,7 @@ export class Client { let resp: FunctionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFunctionInfoSchema); }; await execute(signal, call, options); @@ -156,17 +127,13 @@ export class Client { * If the user is a metastore admin, all functions are returned in the output list. * Otherwise, the user must have the **USE_CATALOG** privilege on the catalog and the **USE_SCHEMA** privilege on the schema, and the output list contains only functions for which either the user has the **EXECUTE** privilege or the user is the owner. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listFunctions( - signal: AbortSignal | undefined, - req: ListFunctions, - options?: Options - ): Promise { + async listFunctions(signal: AbortSignal | undefined, req: ListFunctions, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/functions`; const params = new URLSearchParams(); if (req.catalogName !== undefined) { @@ -189,11 +156,7 @@ export class Client { let resp: ListFunctions_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListFunctions_ResponseSchema); }; await execute(signal, call, options); @@ -203,11 +166,8 @@ export class Client { return resp; } - async *listFunctionsIter( - signal: AbortSignal | undefined, - req: ListFunctions, - options?: Options - ): AsyncGenerator { + + async *listFunctionsIter(signal: AbortSignal | undefined, req: ListFunctions, options?: Options): AsyncGenerator { const pageReq: ListFunctions = {...req}; for (;;) { const resp = await this.listFunctions(signal, pageReq, options); @@ -221,6 +181,7 @@ export class Client { } } + /** * Updates the function that matches the supplied name. * Only the owner of the function can be updated. If the user is not a metastore admin, the user must be a member of the group that is the new function owner. @@ -229,21 +190,13 @@ export class Client { * - Is the owner of the function's parent schema and has the **USE_CATALOG** privilege on its parent catalog * - Is the owner of the function itself and has the **USE_CATALOG** privilege on its parent catalog as well as the **USE_SCHEMA** privilege on the function's parent schema. */ - async updateFunction( - signal: AbortSignal | undefined, - req: UpdateFunction, - options?: Options - ): Promise { + async updateFunction(signal: AbortSignal | undefined, req: UpdateFunction, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/functions/${req.fullNameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateFunctionSchema); let resp: FunctionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFunctionInfoSchema); }; await execute(signal, call, options); diff --git a/packages/functions/src/v1/index.ts b/packages/functions/src/v1/index.ts index fe59a233..cccf24e6 100644 --- a/packages/functions/src/v1/index.ts +++ b/packages/functions/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { @@ -28,6 +29,8 @@ export type { GetFunction, ListFunctions, ListFunctions_Response, + SecretDependency, TableDependency, UpdateFunction, + VolumeDependency, } from './model'; diff --git a/packages/functions/src/v1/model.ts b/packages/functions/src/v1/model.ts index 02f720de..2c549c9a 100644 --- a/packages/functions/src/v1/model.ts +++ b/packages/functions/src/v1/model.ts @@ -27,6 +27,7 @@ export enum ColumnTypeName { GEOMETRY = 'GEOMETRY', GEOGRAPHY = 'GEOGRAPHY', TIME = 'TIME', + FILE = 'FILE', TABLE_TYPE = 'TABLE_TYPE', } @@ -160,13 +161,17 @@ export interface DeleteFunction_Response {} /** * A dependency of a SQL object. One of the following fields must be defined: - * __table__, __function__, __connection__, or __credential__. + * __table__, __function__, __connection__, __credential__, __volume__, or __secret__. */ export interface Dependency { table?: TableDependency | undefined; function?: FunctionDependency | undefined; connection?: ConnectionDependency | undefined; credential?: CredentialDependency | undefined; + /** A dependency on a Unity Catalog volume. */ + volume?: VolumeDependency | undefined; + /** A dependency on a Unity Catalog secret. */ + secret?: SecretDependency | undefined; } /** A list of dependencies. */ @@ -312,6 +317,12 @@ export interface ListFunctions_Response { nextPageToken?: string | undefined; } +/** A secret that is dependent on a SQL object. */ +export interface SecretDependency { + /** Full name of the dependent secret, in the form of __catalog_name__.__schema_name__.__secret_name__. */ + secretFullName?: string | undefined; +} + /** A table that is dependent on a SQL object. */ export interface TableDependency { /** Full name of the dependent table, in the form of __catalog_name__.__schema_name__.__table_name__. */ @@ -383,23 +394,26 @@ export interface UpdateFunction { browseOnly?: boolean | undefined; } -export const unmarshalConnectionDependencySchema: z.ZodType = - z - .object({ - connection_name: z.string().optional(), - }) - .transform(d => ({ - connectionName: d.connection_name, - })); +/** A volume that is dependent on a SQL object. */ +export interface VolumeDependency { + /** Full name of the dependent volume, in the form of __catalog_name__.__schema_name__.__volume_name__. */ + volumeFullName?: string | undefined; +} + +export const unmarshalConnectionDependencySchema: z.ZodType = z + .object({ + connection_name: z.string().optional(), + }) + .transform(d => ({ + connectionName: d.connection_name, + })); export const unmarshalCreateFunctionSchema: z.ZodType = z .object({ name: z.string().optional(), catalog_name: z.string().optional(), schema_name: z.string().optional(), - input_params: z - .lazy(() => unmarshalFunctionParameterInfosSchema) - .optional(), + input_params: z.lazy(() => unmarshalFunctionParameterInfosSchema).optional(), data_type: z.enum(ColumnTypeName).optional(), full_data_type: z.string().optional(), routine_body: z.enum(FunctionInfo_RoutineBody).optional(), @@ -410,18 +424,14 @@ export const unmarshalCreateFunctionSchema: z.ZodType = z is_null_call: z.boolean().optional(), security_type: z.enum(FunctionInfo_SecurityType).optional(), specific_name: z.string().optional(), - return_params: z - .lazy(() => unmarshalFunctionParameterInfosSchema) - .optional(), + return_params: z.lazy(() => unmarshalFunctionParameterInfosSchema).optional(), external_name: z.string().optional(), external_language: z.string().optional(), sql_path: z.string().optional(), owner: z.string().optional(), comment: z.string().optional(), properties: z.string().optional(), - routine_dependencies: z - .lazy(() => unmarshalDependencyListSchema) - .optional(), + routine_dependencies: z.lazy(() => unmarshalDependencyListSchema).optional(), metastore_id: z.string().optional(), full_name: z.string().optional(), created_at: z.number().optional(), @@ -464,23 +474,21 @@ export const unmarshalCreateFunctionSchema: z.ZodType = z browseOnly: d.browse_only, })); -export const unmarshalCreateFunctionRequestSchema: z.ZodType = - z - .object({ - function_info: z.lazy(() => unmarshalCreateFunctionSchema).optional(), - }) - .transform(d => ({ - functionInfo: d.function_info, - })); - -export const unmarshalCredentialDependencySchema: z.ZodType = - z - .object({ - credential_name: z.string().optional(), - }) - .transform(d => ({ - credentialName: d.credential_name, - })); +export const unmarshalCreateFunctionRequestSchema: z.ZodType = z + .object({ + function_info: z.lazy(() => unmarshalCreateFunctionSchema).optional(), + }) + .transform(d => ({ + functionInfo: d.function_info, + })); + +export const unmarshalCredentialDependencySchema: z.ZodType = z + .object({ + credential_name: z.string().optional(), + }) + .transform(d => ({ + credentialName: d.credential_name, + })); export const unmarshalDeleteFunctionSchema: z.ZodType = z .object({ @@ -493,8 +501,9 @@ export const unmarshalDeleteFunctionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteFunction_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteFunction_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalDependencySchema: z.ZodType = z .object({ @@ -502,12 +511,16 @@ export const unmarshalDependencySchema: z.ZodType = z function: z.lazy(() => unmarshalFunctionDependencySchema).optional(), connection: z.lazy(() => unmarshalConnectionDependencySchema).optional(), credential: z.lazy(() => unmarshalCredentialDependencySchema).optional(), + volume: z.lazy(() => unmarshalVolumeDependencySchema).optional(), + secret: z.lazy(() => unmarshalSecretDependencySchema).optional(), }) .transform(d => ({ table: d.table, function: d.function, connection: d.connection, credential: d.credential, + volume: d.volume, + secret: d.secret, })); export const unmarshalDependencyListSchema: z.ZodType = z @@ -518,23 +531,20 @@ export const unmarshalDependencyListSchema: z.ZodType = z dependencies: d.dependencies, })); -export const unmarshalFunctionDependencySchema: z.ZodType = - z - .object({ - function_full_name: z.string().optional(), - }) - .transform(d => ({ - functionFullName: d.function_full_name, - })); +export const unmarshalFunctionDependencySchema: z.ZodType = z + .object({ + function_full_name: z.string().optional(), + }) + .transform(d => ({ + functionFullName: d.function_full_name, + })); export const unmarshalFunctionInfoSchema: z.ZodType = z .object({ name: z.string().optional(), catalog_name: z.string().optional(), schema_name: z.string().optional(), - input_params: z - .lazy(() => unmarshalFunctionParameterInfosSchema) - .optional(), + input_params: z.lazy(() => unmarshalFunctionParameterInfosSchema).optional(), data_type: z.enum(ColumnTypeName).optional(), full_data_type: z.string().optional(), routine_body: z.enum(FunctionInfo_RoutineBody).optional(), @@ -545,18 +555,14 @@ export const unmarshalFunctionInfoSchema: z.ZodType = z is_null_call: z.boolean().optional(), security_type: z.enum(FunctionInfo_SecurityType).optional(), specific_name: z.string().optional(), - return_params: z - .lazy(() => unmarshalFunctionParameterInfosSchema) - .optional(), + return_params: z.lazy(() => unmarshalFunctionParameterInfosSchema).optional(), external_name: z.string().optional(), external_language: z.string().optional(), sql_path: z.string().optional(), owner: z.string().optional(), comment: z.string().optional(), properties: z.string().optional(), - routine_dependencies: z - .lazy(() => unmarshalDependencyListSchema) - .optional(), + routine_dependencies: z.lazy(() => unmarshalDependencyListSchema).optional(), metastore_id: z.string().optional(), full_name: z.string().optional(), created_at: z.number().optional(), @@ -599,47 +605,43 @@ export const unmarshalFunctionInfoSchema: z.ZodType = z browseOnly: d.browse_only, })); -export const unmarshalFunctionParameterInfoSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - type_text: z.string().optional(), - type_json: z.string().optional(), - type_name: z.enum(ColumnTypeName).optional(), - type_precision: z.number().optional(), - type_scale: z.number().optional(), - type_interval_type: z.string().optional(), - position: z.number().optional(), - parameter_mode: z.enum(FunctionParameterMode).optional(), - parameter_type: z.enum(FunctionParameterType).optional(), - parameter_default: z.string().optional(), - comment: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - typeText: d.type_text, - typeJson: d.type_json, - typeName: d.type_name, - typePrecision: d.type_precision, - typeScale: d.type_scale, - typeIntervalType: d.type_interval_type, - position: d.position, - parameterMode: d.parameter_mode, - parameterType: d.parameter_type, - parameterDefault: d.parameter_default, - comment: d.comment, - })); - -export const unmarshalFunctionParameterInfosSchema: z.ZodType = - z - .object({ - parameters: z - .array(z.lazy(() => unmarshalFunctionParameterInfoSchema)) - .optional(), - }) - .transform(d => ({ - parameters: d.parameters, - })); +export const unmarshalFunctionParameterInfoSchema: z.ZodType = z + .object({ + name: z.string().optional(), + type_text: z.string().optional(), + type_json: z.string().optional(), + type_name: z.enum(ColumnTypeName).optional(), + type_precision: z.number().optional(), + type_scale: z.number().optional(), + type_interval_type: z.string().optional(), + position: z.number().optional(), + parameter_mode: z.enum(FunctionParameterMode).optional(), + parameter_type: z.enum(FunctionParameterType).optional(), + parameter_default: z.string().optional(), + comment: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + typeText: d.type_text, + typeJson: d.type_json, + typeName: d.type_name, + typePrecision: d.type_precision, + typeScale: d.type_scale, + typeIntervalType: d.type_interval_type, + position: d.position, + parameterMode: d.parameter_mode, + parameterType: d.parameter_type, + parameterDefault: d.parameter_default, + comment: d.comment, + })); + +export const unmarshalFunctionParameterInfosSchema: z.ZodType = z + .object({ + parameters: z.array(z.lazy(() => unmarshalFunctionParameterInfoSchema)).optional(), + }) + .transform(d => ({ + parameters: d.parameters, + })); export const unmarshalGetFunctionSchema: z.ZodType = z .object({ @@ -668,16 +670,23 @@ export const unmarshalListFunctionsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListFunctions_ResponseSchema: z.ZodType = - z - .object({ - functions: z.array(z.lazy(() => unmarshalFunctionInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - functions: d.functions, - nextPageToken: d.next_page_token, - })); +export const unmarshalListFunctions_ResponseSchema: z.ZodType = z + .object({ + functions: z.array(z.lazy(() => unmarshalFunctionInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + functions: d.functions, + nextPageToken: d.next_page_token, + })); + +export const unmarshalSecretDependencySchema: z.ZodType = z + .object({ + secret_full_name: z.string().optional(), + }) + .transform(d => ({ + secretFullName: d.secret_full_name, + })); export const unmarshalTableDependencySchema: z.ZodType = z .object({ @@ -693,9 +702,7 @@ export const unmarshalUpdateFunctionSchema: z.ZodType = z name: z.string().optional(), catalog_name: z.string().optional(), schema_name: z.string().optional(), - input_params: z - .lazy(() => unmarshalFunctionParameterInfosSchema) - .optional(), + input_params: z.lazy(() => unmarshalFunctionParameterInfosSchema).optional(), data_type: z.enum(ColumnTypeName).optional(), full_data_type: z.string().optional(), routine_body: z.enum(FunctionInfo_RoutineBody).optional(), @@ -706,18 +713,14 @@ export const unmarshalUpdateFunctionSchema: z.ZodType = z is_null_call: z.boolean().optional(), security_type: z.enum(FunctionInfo_SecurityType).optional(), specific_name: z.string().optional(), - return_params: z - .lazy(() => unmarshalFunctionParameterInfosSchema) - .optional(), + return_params: z.lazy(() => unmarshalFunctionParameterInfosSchema).optional(), external_name: z.string().optional(), external_language: z.string().optional(), sql_path: z.string().optional(), owner: z.string().optional(), comment: z.string().optional(), properties: z.string().optional(), - routine_dependencies: z - .lazy(() => unmarshalDependencyListSchema) - .optional(), + routine_dependencies: z.lazy(() => unmarshalDependencyListSchema).optional(), metastore_id: z.string().optional(), full_name: z.string().optional(), created_at: z.number().optional(), @@ -761,6 +764,14 @@ export const unmarshalUpdateFunctionSchema: z.ZodType = z browseOnly: d.browse_only, })); +export const unmarshalVolumeDependencySchema: z.ZodType = z + .object({ + volume_full_name: z.string().optional(), + }) + .transform(d => ({ + volumeFullName: d.volume_full_name, + })); + export const marshalConnectionDependencySchema: z.ZodType = z .object({ connectionName: z.string().optional(), @@ -862,7 +873,9 @@ export const marshalDeleteFunctionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteFunction_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteFunction_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDependencySchema: z.ZodType = z .object({ @@ -870,12 +883,16 @@ export const marshalDependencySchema: z.ZodType = z function: z.lazy(() => marshalFunctionDependencySchema).optional(), connection: z.lazy(() => marshalConnectionDependencySchema).optional(), credential: z.lazy(() => marshalCredentialDependencySchema).optional(), + volume: z.lazy(() => marshalVolumeDependencySchema).optional(), + secret: z.lazy(() => marshalSecretDependencySchema).optional(), }) .transform(d => ({ table: d.table, function: d.function, connection: d.connection, credential: d.credential, + volume: d.volume, + secret: d.secret, })); export const marshalDependencyListSchema: z.ZodType = z @@ -992,9 +1009,7 @@ export const marshalFunctionParameterInfoSchema: z.ZodType = z export const marshalFunctionParameterInfosSchema: z.ZodType = z .object({ - parameters: z - .array(z.lazy(() => marshalFunctionParameterInfoSchema)) - .optional(), + parameters: z.array(z.lazy(() => marshalFunctionParameterInfoSchema)).optional(), }) .transform(d => ({ parameters: d.parameters, @@ -1037,6 +1052,14 @@ export const marshalListFunctions_ResponseSchema: z.ZodType = z next_page_token: d.nextPageToken, })); +export const marshalSecretDependencySchema: z.ZodType = z + .object({ + secretFullName: z.string().optional(), + }) + .transform(d => ({ + secret_full_name: d.secretFullName, + })); + export const marshalTableDependencySchema: z.ZodType = z .object({ tableFullName: z.string().optional(), @@ -1112,3 +1135,11 @@ export const marshalUpdateFunctionSchema: z.ZodType = z function_id: d.functionId, browse_only: d.browseOnly, })); + +export const marshalVolumeDependencySchema: z.ZodType = z + .object({ + volumeFullName: z.string().optional(), + }) + .transform(d => ({ + volume_full_name: d.volumeFullName, + })); diff --git a/packages/functions/src/v1/utils.ts b/packages/functions/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/functions/src/v1/utils.ts +++ b/packages/functions/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/functions/tsconfig.json b/packages/functions/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/functions/tsconfig.json +++ b/packages/functions/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/genie/package.json b/packages/genie/package.json index df336585..fcc68920 100644 --- a/packages/genie/package.json +++ b/packages/genie/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/genie/src/v1/client.ts b/packages/genie/src/v1/client.ts index d3e83937..8414ec4a 100644 --- a/packages/genie/src/v1/client.ts +++ b/packages/genie/src/v1/client.ts @@ -1,18 +1,13 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. import type {Call, Options} from '@databricks/sdk-databricks/api'; -import {execute} from '@databricks/sdk-databricks/api'; +import {execute, retryOn} from '@databricks/sdk-databricks/api'; import type {Logger} from '@databricks/sdk-databricks/logger'; import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { GenieCreateConversationMessageRequest, GenieCreateEvalRunRequest, @@ -60,6 +55,7 @@ import type { GenieUpdateSpaceRequest, } from './model'; import { + MessageStatus_MessageStatus, marshalGenieCreateConversationMessageRequestSchema, marshalGenieCreateEvalRunRequestSchema, marshalGenieCreateMessageCommentRequestSchema, @@ -88,6 +84,8 @@ import { unmarshalGenieStartConversationResponseSchema, } from './model'; +class StillRunningError extends Error {} + export class Client { private readonly host: string; private readonly httpClient: HttpClient; @@ -103,21 +101,13 @@ export class Client { } /** Creates a Genie space from a serialized payload. */ - async createSpace( - signal: AbortSignal | undefined, - req: GenieCreateSpaceRequest, - options?: Options - ): Promise { + async createSpace(signal: AbortSignal | undefined, req: GenieCreateSpaceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces`; const body = marshalRequest(req, marshalGenieCreateSpaceRequestSchema); let resp: GenieSpace | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieSpaceSchema); }; await execute(signal, call, options); @@ -131,24 +121,13 @@ export class Client { * Create new message in a [conversation](:method:genie/startconversation). * The AI response uses all previously created messages in the conversation to respond. */ - async genieCreateConversationMessage( - signal: AbortSignal | undefined, - req: GenieCreateConversationMessageRequest, - options?: Options - ): Promise { + async genieCreateConversationMessage(signal: AbortSignal | undefined, req: GenieCreateConversationMessageRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`; - const body = marshalRequest( - req, - marshalGenieCreateConversationMessageRequestSchema - ); + const body = marshalRequest(req, marshalGenieCreateConversationMessageRequestSchema); let resp: GenieMessage | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieMessageSchema); }; await execute(signal, call, options); @@ -158,22 +137,43 @@ export class Client { return resp; } - /** Create and run evaluations for multiple benchmark questions in a Genie space. */ - async genieCreateEvalRun( +async genieCreateConversationMessageWaiter( signal: AbortSignal | undefined, - req: GenieCreateEvalRunRequest, + req: GenieCreateConversationMessageRequest, options?: Options - ): Promise { + ): Promise { + const resp = await this.genieCreateConversationMessage(signal, req, options); + if (resp.messageId === undefined) { + throw new Error( + 'response field messageId required for polling is missing' + ); + } + if (req.conversationId === undefined) { + throw new Error( + 'request field conversationId required for polling is missing' + ); + } + if (req.spaceId === undefined) { + throw new Error( + 'request field spaceId required for polling is missing' + ); + } + return new GenieCreateConversationMessageWaiter( + this, + resp.messageId, + req.conversationId, + req.spaceId, + ); + } + + /** Create and run evaluations for multiple benchmark questions in a Genie space. */ + async genieCreateEvalRun(signal: AbortSignal | undefined, req: GenieCreateEvalRunRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`; const body = marshalRequest(req, marshalGenieCreateEvalRunRequestSchema); let resp: GenieEvalRunResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema); }; await execute(signal, call, options); @@ -184,24 +184,13 @@ export class Client { } /** Create a comment on a conversation message. */ - async genieCreateMessageComment( - signal: AbortSignal | undefined, - req: GenieCreateMessageCommentRequest, - options?: Options - ): Promise { + async genieCreateMessageComment(signal: AbortSignal | undefined, req: GenieCreateMessageCommentRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`; - const body = marshalRequest( - req, - marshalGenieCreateMessageCommentRequestSchema - ); + const body = marshalRequest(req, marshalGenieCreateMessageCommentRequestSchema); let resp: GenieMessageComment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieMessageCommentSchema); }; await execute(signal, call, options); @@ -212,64 +201,34 @@ export class Client { } /** Delete a conversation. */ - async genieDeleteConversation( - signal: AbortSignal | undefined, - req: GenieDeleteConversationRequest, - options?: Options - ): Promise { + async genieDeleteConversation(signal: AbortSignal | undefined, req: GenieDeleteConversationRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Delete a conversation message. */ - async genieDeleteConversationMessage( - signal: AbortSignal | undefined, - req: GenieDeleteConversationMessageRequest, - options?: Options - ): Promise { + async genieDeleteConversationMessage(signal: AbortSignal | undefined, req: GenieDeleteConversationMessageRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Execute the SQL for a message query attachment. Use this API when the query attachment has expired and needs to be re-executed. */ - async genieExecuteMessageAttachmentQuery( - signal: AbortSignal | undefined, - req: GenieExecuteMessageAttachmentQueryRequest, - options?: Options - ): Promise { + async genieExecuteMessageAttachmentQuery(signal: AbortSignal | undefined, req: GenieExecuteMessageAttachmentQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/execute-query`; - const body = marshalRequest( - req, - marshalGenieExecuteMessageAttachmentQueryRequestSchema - ); + const body = marshalRequest(req, marshalGenieExecuteMessageAttachmentQueryRequestSchema); let resp: GenieGetMessageQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGetMessageQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -279,28 +238,14 @@ export class Client { } /** DEPRECATED: Use [Execute Message Attachment Query](:method:genie/executemessageattachmentquery) instead. */ - async genieExecuteMessageQuery( - signal: AbortSignal | undefined, - req: GenieExecuteMessageQueryRequest, - options?: Options - ): Promise { + async genieExecuteMessageQuery(signal: AbortSignal | undefined, req: GenieExecuteMessageQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/execute-query`; - const body = marshalRequest( - req, - marshalGenieExecuteMessageQueryRequestSchema - ); + const body = marshalRequest(req, marshalGenieExecuteMessageQueryRequestSchema); let resp: GenieGetMessageQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGetMessageQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -313,11 +258,11 @@ export class Client { * Initiates a new SQL execution and returns a `download_id` and `download_id_signature` that you can use to track the progress of the download. * The query result is stored in an external link and can be retrieved using the [Get Download Full Query Result](:method:genie/getdownloadfullqueryresult) API. * Both `download_id` and `download_id_signature` must be provided when calling the Get endpoint. - * + * * ---- - * + * * ### **Warning: Databricks strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.** - * + * * When you use the `EXTERNAL_LINKS` disposition, a * short-lived, URL is generated, which can be * used to download the results directly @@ -325,37 +270,23 @@ export class Client { * short-lived is * embedded in this URL, you should protect * the URL. - * + * * Because URLs are already generated with * embedded temporary s, * you must not set an `Authorization` header in the download requests. - * + * * See [Execute Statement](:method:statementexecution/executestatement) for more details. - * + * * ---- */ - async genieGenerateDownloadFullQueryResult( - signal: AbortSignal | undefined, - req: GenieGenerateDownloadFullQueryResultRequest, - options?: Options - ): Promise { + async genieGenerateDownloadFullQueryResult(signal: AbortSignal | undefined, req: GenieGenerateDownloadFullQueryResultRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads`; - const body = marshalRequest( - req, - marshalGenieGenerateDownloadFullQueryResultRequestSchema - ); + const body = marshalRequest(req, marshalGenieGenerateDownloadFullQueryResultRequestSchema); let resp: GenieGenerateDownloadFullQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGenerateDownloadFullQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGenerateDownloadFullQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -365,20 +296,12 @@ export class Client { } /** Get message from conversation. */ - async genieGetConversationMessage( - signal: AbortSignal | undefined, - req: GenieGetConversationMessageRequest, - options?: Options - ): Promise { + async genieGetConversationMessage(signal: AbortSignal | undefined, req: GenieGetConversationMessageRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}`; let resp: GenieMessage | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieMessageSchema); }; await execute(signal, call, options); @@ -392,11 +315,11 @@ export class Client { * After [Generating a Full Query Result Download](:method:genie/generatedownloadfullqueryresult) and successfully receiving a `download_id` and `download_id_signature`, use this API to poll the download progress. * Both `download_id` and `download_id_signature` are required to call this endpoint. * When the download is complete, the API returns the result in the `EXTERNAL_LINKS` disposition, containing one or more external links to the query result files. - * + * * ---- - * + * * ### **Warning: Databricks strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.** - * + * * When you use the `EXTERNAL_LINKS` disposition, a * short-lived, URL is generated, which can be * used to download the results directly @@ -404,20 +327,16 @@ export class Client { * short-lived is * embedded in this URL, you should protect * the URL. - * + * * Because URLs are already generated with * embedded temporary s, * you must not set an `Authorization` header in the download requests. - * + * * See [Execute Statement](:method:statementexecution/executestatement) for more details. - * + * * ---- */ - async genieGetDownloadFullQueryResult( - signal: AbortSignal | undefined, - req: GenieGetDownloadFullQueryResultRequest, - options?: Options - ): Promise { + async genieGetDownloadFullQueryResult(signal: AbortSignal | undefined, req: GenieGetDownloadFullQueryResultRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/downloads/${req.downloadId ?? ''}`; const params = new URLSearchParams(); if (req.downloadIdSignature !== undefined) { @@ -428,15 +347,8 @@ export class Client { let resp: GenieGetDownloadFullQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGetDownloadFullQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGetDownloadFullQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -446,20 +358,12 @@ export class Client { } /** Get details for evaluation results. */ - async genieGetEvalResultDetails( - signal: AbortSignal | undefined, - req: GenieGetEvalResultDetailsRequest, - options?: Options - ): Promise { + async genieGetEvalResultDetails(signal: AbortSignal | undefined, req: GenieGetEvalResultDetailsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results/${req.resultId ?? ''}`; let resp: GenieEvalResultDetails | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieEvalResultDetailsSchema); }; await execute(signal, call, options); @@ -470,20 +374,12 @@ export class Client { } /** Get evaluation run details. */ - async genieGetEvalRun( - signal: AbortSignal | undefined, - req: GenieGetEvalRunRequest, - options?: Options - ): Promise { + async genieGetEvalRun(signal: AbortSignal | undefined, req: GenieGetEvalRunRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}`; let resp: GenieEvalRunResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieEvalRunResponseSchema); }; await execute(signal, call, options); @@ -497,24 +393,13 @@ export class Client { * Get the result of SQL query if the message has a query attachment. * This is only available if a message has a query attachment and the message status is `EXECUTING_QUERY` OR `COMPLETED`. */ - async genieGetMessageAttachmentQueryResult( - signal: AbortSignal | undefined, - req: GenieGetMessageAttachmentQueryResultRequest, - options?: Options - ): Promise { + async genieGetMessageAttachmentQueryResult(signal: AbortSignal | undefined, req: GenieGetMessageAttachmentQueryResultRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/attachments/${req.attachmentId ?? ''}/query-result`; let resp: GenieGetMessageQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGetMessageQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -524,24 +409,13 @@ export class Client { } /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */ - async genieGetMessageQueryResult( - signal: AbortSignal | undefined, - req: GenieGetMessageQueryResultRequest, - options?: Options - ): Promise { + async genieGetMessageQueryResult(signal: AbortSignal | undefined, req: GenieGetMessageQueryResultRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result`; let resp: GenieGetMessageQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGetMessageQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -551,24 +425,13 @@ export class Client { } /** DEPRECATED: Use [Get Message Attachment Query Result](:method:genie/getmessageattachmentqueryresult) instead. */ - async genieGetQueryResultByAttachment( - signal: AbortSignal | undefined, - req: GenieGetQueryResultByAttachmentRequest, - options?: Options - ): Promise { + async genieGetQueryResultByAttachment(signal: AbortSignal | undefined, req: GenieGetQueryResultByAttachmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/query-result/${req.attachmentId ?? ''}`; let resp: GenieGetMessageQueryResultResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieGetMessageQueryResultResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieGetMessageQueryResultResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -578,29 +441,18 @@ export class Client { } /** Get details of a Genie Space. */ - async genieGetSpace( - signal: AbortSignal | undefined, - req: GenieGetSpaceRequest, - options?: Options - ): Promise { + async genieGetSpace(signal: AbortSignal | undefined, req: GenieGetSpaceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`; const params = new URLSearchParams(); if (req.includeSerializedSpace !== undefined) { - params.append( - 'include_serialized_space', - String(req.includeSerializedSpace) - ); + params.append('include_serialized_space', String(req.includeSerializedSpace)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: GenieSpace | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieSpaceSchema); }; await execute(signal, call, options); @@ -611,11 +463,7 @@ export class Client { } /** List all comments across all messages in a conversation. */ - async genieListConversationComments( - signal: AbortSignal | undefined, - req: GenieListConversationCommentsRequest, - options?: Options - ): Promise { + async genieListConversationComments(signal: AbortSignal | undefined, req: GenieListConversationCommentsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/list-comments`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -629,15 +477,8 @@ export class Client { let resp: GenieListConversationCommentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieListConversationCommentsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieListConversationCommentsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -647,11 +488,7 @@ export class Client { } /** List messages in a conversation */ - async genieListConversationMessages( - signal: AbortSignal | undefined, - req: GenieListConversationMessagesRequest, - options?: Options - ): Promise { + async genieListConversationMessages(signal: AbortSignal | undefined, req: GenieListConversationMessagesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -665,15 +502,8 @@ export class Client { let resp: GenieListConversationMessagesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieListConversationMessagesResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieListConversationMessagesResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -683,11 +513,7 @@ export class Client { } /** Get a list of conversations in a Genie Space. */ - async genieListConversations( - signal: AbortSignal | undefined, - req: GenieListConversationsRequest, - options?: Options - ): Promise { + async genieListConversations(signal: AbortSignal | undefined, req: GenieListConversationsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -704,15 +530,8 @@ export class Client { let resp: GenieListConversationsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieListConversationsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieListConversationsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -722,11 +541,7 @@ export class Client { } /** List evaluation results for a specific evaluation run. */ - async genieListEvalResults( - signal: AbortSignal | undefined, - req: GenieListEvalResultsRequest, - options?: Options - ): Promise { + async genieListEvalResults(signal: AbortSignal | undefined, req: GenieListEvalResultsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs/${req.evalRunId ?? ''}/results`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -740,15 +555,8 @@ export class Client { let resp: GenieListEvalResultsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieListEvalResultsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieListEvalResultsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -758,11 +566,7 @@ export class Client { } /** Lists all evaluation runs in a space. */ - async genieListEvalRuns( - signal: AbortSignal | undefined, - req: GenieListEvalRunsRequest, - options?: Options - ): Promise { + async genieListEvalRuns(signal: AbortSignal | undefined, req: GenieListEvalRunsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/eval-runs`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -776,11 +580,7 @@ export class Client { let resp: GenieListEvalRunsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieListEvalRunsResponseSchema); }; await execute(signal, call, options); @@ -791,11 +591,7 @@ export class Client { } /** List comments on a specific conversation message. */ - async genieListMessageComments( - signal: AbortSignal | undefined, - req: GenieListMessageCommentsRequest, - options?: Options - ): Promise { + async genieListMessageComments(signal: AbortSignal | undefined, req: GenieListMessageCommentsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/comments`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -809,15 +605,8 @@ export class Client { let resp: GenieListMessageCommentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieListMessageCommentsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieListMessageCommentsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -827,11 +616,7 @@ export class Client { } /** Get list of Genie Spaces. */ - async genieListSpaces( - signal: AbortSignal | undefined, - req: GenieListSpacesRequest, - options?: Options - ): Promise { + async genieListSpaces(signal: AbortSignal | undefined, req: GenieListSpacesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -845,11 +630,7 @@ export class Client { let resp: GenieListSpacesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieListSpacesResponseSchema); }; await execute(signal, call, options); @@ -860,50 +641,25 @@ export class Client { } /** Send feedback for a message. */ - async genieSendMessageFeedback( - signal: AbortSignal | undefined, - req: GenieSendMessageFeedbackRequest, - options?: Options - ): Promise { + async genieSendMessageFeedback(signal: AbortSignal | undefined, req: GenieSendMessageFeedbackRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/conversations/${req.conversationId ?? ''}/messages/${req.messageId ?? ''}/feedback`; - const body = marshalRequest( - req, - marshalGenieSendMessageFeedbackRequestSchema - ); + const body = marshalRequest(req, marshalGenieSendMessageFeedbackRequestSchema); const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Start a new conversation. */ - async genieStartConversation( - signal: AbortSignal | undefined, - req: GenieStartConversationMessageRequest, - options?: Options - ): Promise { + async genieStartConversation(signal: AbortSignal | undefined, req: GenieStartConversationMessageRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}/start-conversation`; - const body = marshalRequest( - req, - marshalGenieStartConversationMessageRequestSchema - ); + const body = marshalRequest(req, marshalGenieStartConversationMessageRequestSchema); let resp: GenieStartConversationResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGenieStartConversationResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGenieStartConversationResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -912,40 +668,53 @@ export class Client { return resp; } - /** Move a Genie Space to the trash. */ - async genieTrashSpace( +async genieStartConversationWaiter( signal: AbortSignal | undefined, - req: GenieTrashSpaceRequest, + req: GenieStartConversationMessageRequest, options?: Options - ): Promise { + ): Promise { + const resp = await this.genieStartConversation(signal, req, options); + if (resp.messageId === undefined) { + throw new Error( + 'response field messageId required for polling is missing' + ); + } + if (resp.conversationId === undefined) { + throw new Error( + 'response field conversationId required for polling is missing' + ); + } + if (req.spaceId === undefined) { + throw new Error( + 'request field spaceId required for polling is missing' + ); + } + return new GenieStartConversationWaiter( + this, + resp.messageId, + resp.conversationId, + req.spaceId, + ); + } + + /** Move a Genie Space to the trash. */ + async genieTrashSpace(signal: AbortSignal | undefined, req: GenieTrashSpaceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Updates a Genie space with a serialized payload. */ - async updateSpace( - signal: AbortSignal | undefined, - req: GenieUpdateSpaceRequest, - options?: Options - ): Promise { + async updateSpace(signal: AbortSignal | undefined, req: GenieUpdateSpaceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/genie/spaces/${req.spaceId ?? ''}`; const body = marshalRequest(req, marshalGenieUpdateSpaceRequestSchema); let resp: GenieSpace | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGenieSpaceSchema); }; await execute(signal, call, options); @@ -955,3 +724,187 @@ export class Client { return resp; } } + +export class GenieCreateConversationMessageWaiter { + constructor( + private readonly client: Client, + readonly messageId: string, + readonly conversationId: string, + readonly spaceId: string, + ) {} + + /** + * Polls until the operation reaches a terminal state. + * + * Throws if a failure state is reached. + */ + async wait( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + let result: GenieMessage | undefined; + + const call: Call = async (callSignal?: AbortSignal): Promise => { + const pollResp = await this.client.genieGetConversationMessage( + callSignal, + { + messageId: this.messageId, + conversationId: this.conversationId, + spaceId: this.spaceId, + }, + options + ); + + const status = pollResp.status; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case MessageStatus_MessageStatus.COMPLETED: + result = pollResp; + return; + case MessageStatus_MessageStatus.FAILED: + { + const msg = '(no message)'; + throw new Error(`terminal state ${status}: ${msg}`); + } + default: + throw new StillRunningError(); + } + }; + + const retryOptions: Options = { + retrier: () => + retryOn({}, (err: Error) => { + return err instanceof StillRunningError; + }), + }; + await execute(signal, call, retryOptions); + if (result === undefined) { + throw new Error('API call completed without a result.'); + } + return result; + } + + /** Checks whether the operation has reached a terminal state. */ + async done( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + const pollResp = await this.client.genieGetConversationMessage( + signal, + { + messageId: this.messageId, + conversationId: this.conversationId, + spaceId: this.spaceId, + }, + options + ); + + const status = pollResp.status; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case MessageStatus_MessageStatus.COMPLETED: + case MessageStatus_MessageStatus.FAILED: + return true; + default: + return false; + } + } +} + +export class GenieStartConversationWaiter { + constructor( + private readonly client: Client, + readonly messageId: string, + readonly conversationId: string, + readonly spaceId: string, + ) {} + + /** + * Polls until the operation reaches a terminal state. + * + * Throws if a failure state is reached. + */ + async wait( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + let result: GenieMessage | undefined; + + const call: Call = async (callSignal?: AbortSignal): Promise => { + const pollResp = await this.client.genieGetConversationMessage( + callSignal, + { + messageId: this.messageId, + conversationId: this.conversationId, + spaceId: this.spaceId, + }, + options + ); + + const status = pollResp.status; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case MessageStatus_MessageStatus.COMPLETED: + result = pollResp; + return; + case MessageStatus_MessageStatus.FAILED: + { + const msg = '(no message)'; + throw new Error(`terminal state ${status}: ${msg}`); + } + default: + throw new StillRunningError(); + } + }; + + const retryOptions: Options = { + retrier: () => + retryOn({}, (err: Error) => { + return err instanceof StillRunningError; + }), + }; + await execute(signal, call, retryOptions); + if (result === undefined) { + throw new Error('API call completed without a result.'); + } + return result; + } + + /** Checks whether the operation has reached a terminal state. */ + async done( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + const pollResp = await this.client.genieGetConversationMessage( + signal, + { + messageId: this.messageId, + conversationId: this.conversationId, + spaceId: this.spaceId, + }, + options + ); + + const status = pollResp.status; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case MessageStatus_MessageStatus.COMPLETED: + case MessageStatus_MessageStatus.FAILED: + return true; + default: + return false; + } + } +} diff --git a/packages/genie/src/v1/index.ts b/packages/genie/src/v1/index.ts index 964a8636..12b8628e 100644 --- a/packages/genie/src/v1/index.ts +++ b/packages/genie/src/v1/index.ts @@ -1,6 +1,7 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. -export {Client} from './client'; + +export {Client, GenieCreateConversationMessageWaiter, GenieStartConversationWaiter} from './client'; export { ColumnTypeName, diff --git a/packages/genie/src/v1/model.ts b/packages/genie/src/v1/model.ts index bf156cf7..e9dedfdd 100644 --- a/packages/genie/src/v1/model.ts +++ b/packages/genie/src/v1/model.ts @@ -27,6 +27,7 @@ export enum ColumnTypeName { GEOMETRY = 'GEOMETRY', GEOGRAPHY = 'GEOGRAPHY', TIME = 'TIME', + FILE = 'FILE', TABLE_TYPE = 'TABLE_TYPE', } @@ -35,10 +36,10 @@ export enum ErrorCode { /** * Unknown error. This error generally should not be returned explicitly, but will be used * as a fallback if the error enum is missing from the message for some reason. - * + * * It's assigned tag 0 to follow the best practice from * https://developers.google.com/protocol-buffers/docs/style#enums - * + * * TODO(PLAT-55898): Add custom option to declare HTTP and gRPC mappings. * Maps to: * - google.rpc.Code: UNKNOWN = 2; @@ -49,10 +50,10 @@ export enum ErrorCode { * Internal error. This means that some invariants expected by the underlying system have been * broken. This error code is reserved for serious errors, which generally cannot be resolved * by the user. - * + * * Prefer this over all kinds of detailed error messages (e.g IO_ERROR), unless there's some * automation that relies on the custom error code. - * + * * Maps to: * - google.rpc.Code: INTERNAL = 13; * - HTTP code: 500 Internal Server Error @@ -62,12 +63,12 @@ export enum ErrorCode { * The service is currently unavailable. This is most likely a transient condition, which can be * corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent * operations. - * + * * Prefer this over SERVICE_UNDER_MAINTENANCE, WORKSPACE_TEMPORARILY_UNAVAILABLE. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on how to pick this vs RESOURCE_EXHAUSTED. - * + * * Maps to: * - google.rpc.Code: UNAVAILABLE = 14; * - HTTP code: 503 Service Unavailable @@ -82,9 +83,9 @@ export enum ErrorCode { /** * The request is invalid. Prefer more specific error code whenever possible. * Also see similar recommendation for the google.rpc.Code.FAILED_PRECONDITION. - * + * * Prefer this error code over MALFORMED_REQUEST, INVALID_STATE, UNPARSEABLE_HTTP_ERROR. - * + * * Maps to: * - google.rpc.Code: FAILED_PRECONDITION = 9; * - HTTP code: 400 Bad Request @@ -104,7 +105,7 @@ export enum ErrorCode { * the deadline to expire. When possible - implementations should make sure further processing of * the request is aborted, e.g. by throwing an exception instead of making the RPC request, * making the database query, etc. - * + * * Maps to: * - google.rpc.Code: DEADLINE_EXCEEDED = 4; * - HTTP code: 504 Gateway Timeout @@ -113,7 +114,7 @@ export enum ErrorCode { /** * The operation was canceled by the caller. An example - client closed the connection without * waiting for a response. - * + * * Maps to: * - google.rpc.Code: CANCELLED = 1; * - HTTP code: 499 Client Closed Request @@ -123,10 +124,10 @@ export enum ErrorCode { * The operation is rejected because of either rate limiting or resource quota, * such as the client has sent too many requests recently or the client has allocated too many * resources. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on how to pick this vs TEMPORARILY_UNAVAILABLE. - * + * * Maps to: * - google.rpc.Code: RESOURCE_EXHAUSTED = 8; * - HTTP code: 429 Too Many Requests @@ -135,7 +136,7 @@ export enum ErrorCode { /** * The operation was aborted, typically due to a concurrency issue such as a sequencer * check failure, transaction abort, or transaction conflict. - * + * * Maps to: * - google.rpc.Code: ABORTED = 10; * - HTTP code: 409 Conflict @@ -144,7 +145,7 @@ export enum ErrorCode { /** * Operation was performed on a resource that does not exist, * e.g. file or directory was not found. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -153,9 +154,9 @@ export enum ErrorCode { /** * Operation was rejected due a conflict with an existing resource, e.g. attempted to create * file or directory that already exists. - * + * * Prefer this over RESOURCE_CONFLICT. - * + * * Maps to: * - google.rpc.Code: ALREADY_EXISTS = 6; * - HTTP code: 409 Conflict @@ -163,11 +164,11 @@ export enum ErrorCode { ALREADY_EXISTS = 'ALREADY_EXISTS', /** * The request does not have valid authentication (AuthN) credentials for the operation. - * + * * Prefer this over CUSTOMER_UNAUTHORIZED, unless you need to keep consistent behavior with legacy * code. * For authorization (AuthZ) errors use PERMISSION_DENIED. - * + * * Maps to: * - google.rpc.Code: UNAUTHENTICATED = 16; * - HTTP code: 401 Unauthorized @@ -182,7 +183,7 @@ export enum ErrorCode { * not know whether it is because the domain name is completely wrong (non-transient situation) or * the domain name is valid but the DNS server does not have an entry for this domain name yet (transient * situation). Hence, `UNAVAILABLE` is suitable for this case. - * + * * Maps to: * - google.rpc.Code: UNAVAILABLE = 14; * - HTTP code: 503 Service Unavailable @@ -190,7 +191,7 @@ export enum ErrorCode { UNAVAILABLE = 'UNAVAILABLE', /** * Supplied value for a parameter was invalid (e.g., giving a number for a string parameter). - * + * * Maps to: * - google.rpc.Code: INVALID_ARGUMENT = 3; * - HTTP code: 400 Bad Request @@ -199,7 +200,7 @@ export enum ErrorCode { /** * Indicates that the given API endpoint does not exist. Legacy, when possible - NOT_IMPLEMENTED * should be used instead to indicate that API doesn't exist. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -221,7 +222,7 @@ export enum ErrorCode { * use CUSTOMER_UNAUTHORIZED instead for those errors. * This error code does not imply the request is valid or the requested entity exists or * satisfies other pre-conditions. - * + * * Maps to: * - google.rpc.Code: PERMISSION_DENIED = 7; * - HTTP code: 403 Forbidden @@ -231,9 +232,9 @@ export enum ErrorCode { * NOTE: Deprecated due to inconsistent mapping in legacy code, see * https://docs.google.com/document/d/17TZIKX_Y39cJMBr333lc-d5dTvvBLSu3DPUyGU5eMJg/edit?disco=AAAAzVGt6FA. * Prefer using NOT_FOUND or PERMISSION_DENIED. - * + * * If a given user/entity is trying to use a feature which has been disabled. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -241,20 +242,20 @@ export enum ErrorCode { FEATURE_DISABLED = 'FEATURE_DISABLED', /** * The request does not have valid authentication (AuthN) credentials for the operation. - * + * * For authentication (AuthN) errors prefer using UNAUTHENTICATED, unless you need to keep * consistent behavior with legacy code. * For authorization (AuthZ) errors use PERMISSION_DENIED. - * + * * Important: name is confusing, this error code is for authentication (AuthN) errors, not * authorization (AuthZ) errors. It maps to 401 Unauthorized and suffers from the same confusing * naming. See https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 - "[...] status code * indicates that the request has not been applied because it lacks valid authentication * credentials for the target resource. [...] If the request included authentication credentials, * then the 401 response indicates that authorization has been refused for those credentials." - * + * * Also, see https://stackoverflow.com/a/6937030/16352922, it covers it pretty well. - * + * * Maps to: * - google.rpc.Code: UNAUTHENTICATED = 16; * - HTTP code: 401 Unauthorized @@ -263,12 +264,12 @@ export enum ErrorCode { /** * The operation is rejected because of request rate limit, for example rate limiting applied to * users, workspaces, IP addresses, etc. - * + * * Prefer a more generic RESOURCE_EXHAUSTED for the new use cases. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on the rate limiting vs throttling. - * + * * Maps to: * - google.rpc.Code: RESOURCE_EXHAUSTED = 8; * - HTTP code: 429 Too Many Requests @@ -285,7 +286,7 @@ export enum ErrorCode { UNPARSEABLE_HTTP_ERROR = 'UNPARSEABLE_HTTP_ERROR', /** * The operation is not implemented or is not supported/enabled in this service. - * + * * Maps to: * - google.rpc.Code: UNIMPLEMENTED = 12; * - HTTP code: 501 Not Implemented @@ -293,14 +294,14 @@ export enum ErrorCode { NOT_IMPLEMENTED = 'NOT_IMPLEMENTED', /** * Unrecoverable data loss or corruption. - * + * * One of the major use cases is to indicate that server failed to validate the integrity of * the request. This error can occur when the checksum specified in the `X-Databricks-Checksum` * request header (or trailer) doesn't match the actual request content checksum. - * + * * Note, in case of the severe corruption that results in a malformed request, the server may * send a generic `400 Bad Request` response rather than sending this error code. - * + * * Maps to: * - google.rpc.Code: DATA_LOSS = 15; * - HTTP code: 500 Internal Server Error @@ -318,7 +319,7 @@ export enum ErrorCode { * NOTE: Deprecated, prefer using ALREADY_EXISTS. * Unlike ALREADY_EXISTS - this maps to HTTP code 400 Bad Request due to legacy reasons, * remapping will be a backwards incompatible change. - * + * * Operation was performed on a resource that already exists. */ RESOURCE_ALREADY_EXISTS = 'RESOURCE_ALREADY_EXISTS', @@ -326,7 +327,7 @@ export enum ErrorCode { * NOTE: Deprecated, prefer using NOT_FOUND - see the note for the RESOURCE_ALREADY_EXISTS, * because this pair of codes is related and RESOURCE_ALREADY_EXISTS has bad mapping to the HTTP * codes we added new error codes NOT_FOUND and ALREADY_EXISTS, and recommend to use them instead. - * + * * Operation was performed on a resource that does not exist. */ RESOURCE_DOES_NOT_EXIST = 'RESOURCE_DOES_NOT_EXIST', @@ -574,7 +575,7 @@ export enum GenieFeedbackRating { * https://github.com/protocolbuffers/protobuf/blob/450d24ca820750c5db5112a6f0b0c2efb9758021/src/google/protobuf/struct.proto * `NullValue` is a singleton enumeration to represent the null value for the * `Value` type union. - * + * * The JSON representation for `NullValue` is JSON `null`. */ export enum NullValue { @@ -1051,9 +1052,9 @@ export interface GenieEvalResultDetails { manualAssessment?: boolean | undefined; /** * 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. @@ -1063,7 +1064,7 @@ export interface GenieEvalResultDetails { * - 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. @@ -1076,7 +1077,7 @@ export interface GenieEvalResultDetails { * - 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) @@ -1483,6 +1484,11 @@ export interface GenieSpace { * This field provides the structure of the JSON string that represents the space's layout and components. */ serializedSpace?: string | undefined; + /** + * ETag for this space. Pass this value back in the update request to prevent overwriting + * concurrent changes. + */ + etag?: string | undefined; } export interface GenieStartConversationMessageRequest { @@ -1527,13 +1533,18 @@ export interface GenieUpdateSpaceRequest { description?: string | undefined; /** Optional warehouse override */ warehouseId?: string | undefined; + /** + * 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 | undefined; } /** * 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. */ export interface ListValue { @@ -1692,7 +1703,7 @@ export interface StatementStatus { * 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. */ export interface Struct { @@ -1713,7 +1724,15 @@ export interface TextAttachment { /** A single thought in the AI's reasoning process for a query. */ export interface Thought { - /** The category of this thought. */ + /** + * 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 | undefined; /** The md formatted content for this thought. */ content?: string | undefined; @@ -1726,7 +1745,7 @@ export interface Thought { * 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. */ export interface Value { @@ -1803,9 +1822,7 @@ export const unmarshalColumnMaskSchema: z.ZodType = z .object({ function_name: z.string().optional(), using_column_names: z.array(z.string()).optional(), - using_arguments: z - .array(z.lazy(() => unmarshalPolicyFunctionArgumentSchema)) - .optional(), + using_arguments: z.array(z.lazy(() => unmarshalPolicyFunctionArgumentSchema)).optional(), }) .transform(d => ({ functionName: d.function_name, @@ -1813,18 +1830,17 @@ export const unmarshalColumnMaskSchema: z.ZodType = z usingArguments: d.using_arguments, })); -export const unmarshalDatabricksServiceExceptionProtoSchema: z.ZodType = - z - .object({ - error_code: z.enum(ErrorCode).optional(), - message: z.string().optional(), - stack_trace: z.string().optional(), - }) - .transform(d => ({ - errorCode: d.error_code, - message: d.message, - stackTrace: d.stack_trace, - })); +export const unmarshalDatabricksServiceExceptionProtoSchema: z.ZodType = z + .object({ + error_code: z.enum(ErrorCode).optional(), + message: z.string().optional(), + stack_trace: z.string().optional(), + }) + .transform(d => ({ + errorCode: d.error_code, + message: d.message, + stackTrace: d.stack_trace, + })); export const unmarshalExternalLinkSchema: z.ZodType = z .object({ @@ -1850,618 +1866,558 @@ export const unmarshalExternalLinkSchema: z.ZodType = z nextChunkInternalLink: d.next_chunk_internal_link, })); -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalExternalLink_HttpHeadersEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalExternalLink_HttpHeadersEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalGenieAttachmentSchema: z.ZodType = z + .object({ + text: z.lazy(() => unmarshalTextAttachmentSchema).optional(), + query: z.lazy(() => unmarshalGenieQueryAttachmentSchema).optional(), + suggested_questions: z.lazy(() => unmarshalGenieSuggestedQuestionsAttachmentSchema).optional(), + attachment_id: z.string().optional(), + }) + .transform(d => ({ + text: d.text, + query: d.query, + suggestedQuestions: d.suggested_questions, + attachmentId: d.attachment_id, + })); + +export const unmarshalGenieConversationSchema: z.ZodType = z + .object({ + id: z.string().optional(), + space_id: z.string().optional(), + user_id: z.number().optional(), + created_timestamp: z.number().optional(), + last_updated_timestamp: z.number().optional(), + title: z.string().optional(), + conversation_id: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + spaceId: d.space_id, + userId: d.user_id, + createdTimestamp: d.created_timestamp, + lastUpdatedTimestamp: d.last_updated_timestamp, + title: d.title, + conversationId: d.conversation_id, + })); + +export const unmarshalGenieConversationSummarySchema: z.ZodType = z + .object({ + conversation_id: z.string().optional(), + title: z.string().optional(), + created_timestamp: z.number().optional(), + }) + .transform(d => ({ + conversationId: d.conversation_id, + title: d.title, + createdTimestamp: d.created_timestamp, + })); + +export const unmarshalGenieCreateConversationMessageRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + content: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + content: d.content, + })); + +export const unmarshalGenieCreateEvalRunRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + benchmark_question_ids: z.array(z.string()).optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + benchmarkQuestionIds: d.benchmark_question_ids, + })); + +export const unmarshalGenieCreateMessageCommentRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + content: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + content: d.content, + })); + +export const unmarshalGenieCreateSpaceRequestSchema: z.ZodType = z + .object({ + warehouse_id: z.string().optional(), + parent_path: z.string().optional(), + serialized_space: z.string().optional(), + title: z.string().optional(), + description: z.string().optional(), + }) + .transform(d => ({ + warehouseId: d.warehouse_id, + parentPath: d.parent_path, + serializedSpace: d.serialized_space, + title: d.title, + description: d.description, + })); + +export const unmarshalGenieDeleteConversationMessageRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + })); + +export const unmarshalGenieDeleteConversationRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + })); + +export const unmarshalGenieEvalResponseSchema: z.ZodType = z + .object({ + response: z.string().optional(), + sql_execution_result: z.lazy(() => unmarshalStatementResponseSchema).optional(), + response_type: z.enum(GenieEvalResponseType).optional(), + }) + .transform(d => ({ + response: d.response, + sqlExecutionResult: d.sql_execution_result, + responseType: d.response_type, + })); + +export const unmarshalGenieEvalResultSchema: z.ZodType = z + .object({ + result_id: z.string().optional(), + space_id: z.string().optional(), + benchmark_question_id: z.string().optional(), + status: z.enum(EvaluationStatusType).optional(), + question: z.string().optional(), + benchmark_answer: z.string().optional(), + created_by_user: z.number().optional(), + }) + .transform(d => ({ + resultId: d.result_id, + spaceId: d.space_id, + benchmarkQuestionId: d.benchmark_question_id, + status: d.status, + question: d.question, + benchmarkAnswer: d.benchmark_answer, + createdByUser: d.created_by_user, + })); + +export const unmarshalGenieEvalResultDetailsSchema: z.ZodType = z + .object({ + result_id: z.string().optional(), + space_id: z.string().optional(), + benchmark_question_id: z.string().optional(), + eval_run_status: z.enum(EvaluationStatusType).optional(), + assessment: z.enum(GenieEvalAssessment).optional(), + manual_assessment: z.boolean().optional(), + assessment_reasons: z.array(z.enum(ScoreReason)).optional(), + actual_response: z.array(z.lazy(() => unmarshalGenieEvalResponseSchema)).optional(), + expected_response: z.array(z.lazy(() => unmarshalGenieEvalResponseSchema)).optional(), + }) + .transform(d => ({ + resultId: d.result_id, + spaceId: d.space_id, + benchmarkQuestionId: d.benchmark_question_id, + evalRunStatus: d.eval_run_status, + assessment: d.assessment, + manualAssessment: d.manual_assessment, + assessmentReasons: d.assessment_reasons, + actualResponse: d.actual_response, + expectedResponse: d.expected_response, + })); + +export const unmarshalGenieEvalRunResponseSchema: z.ZodType = z + .object({ + eval_run_id: z.string().optional(), + eval_run_status: z.enum(EvaluationStatusType).optional(), + run_by_user: z.number().optional(), + created_timestamp: z.number().optional(), + num_questions: z.number().optional(), + num_correct: z.number().optional(), + num_needs_review: z.number().optional(), + num_done: z.number().optional(), + last_updated_timestamp: z.number().optional(), + }) + .transform(d => ({ + evalRunId: d.eval_run_id, + evalRunStatus: d.eval_run_status, + runByUser: d.run_by_user, + createdTimestamp: d.created_timestamp, + numQuestions: d.num_questions, + numCorrect: d.num_correct, + numNeedsReview: d.num_needs_review, + numDone: d.num_done, + lastUpdatedTimestamp: d.last_updated_timestamp, + })); + +export const unmarshalGenieExecuteMessageAttachmentQueryRequestSchema: z.ZodType = z + .object({ + message_id: z.string().optional(), + space_id: z.string().optional(), + conversation_id: z.string().optional(), + attachment_id: z.string().optional(), + }) + .transform(d => ({ + messageId: d.message_id, + spaceId: d.space_id, + conversationId: d.conversation_id, + attachmentId: d.attachment_id, + })); + +export const unmarshalGenieExecuteMessageQueryRequestSchema: z.ZodType = z + .object({ + message_id: z.string().optional(), + space_id: z.string().optional(), + conversation_id: z.string().optional(), + }) + .transform(d => ({ + messageId: d.message_id, + spaceId: d.space_id, + conversationId: d.conversation_id, + })); + +export const unmarshalGenieFeedbackSchema: z.ZodType = z + .object({ + rating: z.enum(GenieFeedbackRating).optional(), + comment: z.string().optional(), + }) + .transform(d => ({ + rating: d.rating, + comment: d.comment, + })); + +export const unmarshalGenieGenerateDownloadFullQueryResultRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + attachment_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + attachmentId: d.attachment_id, + })); + +export const unmarshalGenieGenerateDownloadFullQueryResultResponseSchema: z.ZodType = z + .object({ + download_id: z.string().optional(), + download_id_signature: z.string().optional(), + }) + .transform(d => ({ + downloadId: d.download_id, + downloadIdSignature: d.download_id_signature, + })); + +export const unmarshalGenieGetConversationMessageRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + })); + +export const unmarshalGenieGetDownloadFullQueryResultRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + attachment_id: z.string().optional(), + download_id: z.string().optional(), + download_id_signature: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + attachmentId: d.attachment_id, + downloadId: d.download_id, + downloadIdSignature: d.download_id_signature, + })); + +export const unmarshalGenieGetDownloadFullQueryResultResponseSchema: z.ZodType = z + .object({ + statement_response: z.lazy(() => unmarshalStatementResponseSchema).optional(), + }) + .transform(d => ({ + statementResponse: d.statement_response, + })); + +export const unmarshalGenieGetEvalResultDetailsRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + eval_run_id: z.string().optional(), + result_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + evalRunId: d.eval_run_id, + resultId: d.result_id, + })); + +export const unmarshalGenieGetEvalRunRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + eval_run_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + evalRunId: d.eval_run_id, + })); + +export const unmarshalGenieGetMessageAttachmentQueryResultRequestSchema: z.ZodType = z + .object({ + message_id: z.string().optional(), + space_id: z.string().optional(), + conversation_id: z.string().optional(), + attachment_id: z.string().optional(), + }) + .transform(d => ({ + messageId: d.message_id, + spaceId: d.space_id, + conversationId: d.conversation_id, + attachmentId: d.attachment_id, + })); + +export const unmarshalGenieGetMessageQueryResultRequestSchema: z.ZodType = z + .object({ + message_id: z.string().optional(), + space_id: z.string().optional(), + conversation_id: z.string().optional(), + }) + .transform(d => ({ + messageId: d.message_id, + spaceId: d.space_id, + conversationId: d.conversation_id, + })); + +export const unmarshalGenieGetMessageQueryResultResponseSchema: z.ZodType = z + .object({ + statement_response: z.lazy(() => unmarshalStatementResponseSchema).optional(), + }) + .transform(d => ({ + statementResponse: d.statement_response, + })); + +export const unmarshalGenieGetQueryResultByAttachmentRequestSchema: z.ZodType = z + .object({ + message_id: z.string().optional(), + space_id: z.string().optional(), + conversation_id: z.string().optional(), + attachment_id: z.string().optional(), + }) + .transform(d => ({ + messageId: d.message_id, + spaceId: d.space_id, + conversationId: d.conversation_id, + attachmentId: d.attachment_id, + })); + +export const unmarshalGenieGetSpaceRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + include_serialized_space: z.boolean().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + includeSerializedSpace: d.include_serialized_space, + })); + +export const unmarshalGenieListConversationCommentsRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalGenieListConversationCommentsResponseSchema: z.ZodType = z + .object({ + comments: z.array(z.lazy(() => unmarshalGenieMessageCommentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + comments: d.comments, + nextPageToken: d.next_page_token, + })); + +export const unmarshalGenieListConversationMessagesRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalGenieListConversationMessagesResponseSchema: z.ZodType = z + .object({ + messages: z.array(z.lazy(() => unmarshalGenieMessageSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + messages: d.messages, + nextPageToken: d.next_page_token, + })); + +export const unmarshalGenieListConversationsRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + include_all: z.boolean().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + pageSize: d.page_size, + pageToken: d.page_token, + includeAll: d.include_all, + })); + +export const unmarshalGenieListConversationsResponseSchema: z.ZodType = z + .object({ + conversations: z.array(z.lazy(() => unmarshalGenieConversationSummarySchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + conversations: d.conversations, + nextPageToken: d.next_page_token, + })); + +export const unmarshalGenieListEvalResultsRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + eval_run_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + evalRunId: d.eval_run_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); -export const unmarshalGenieAttachmentSchema: z.ZodType = z +export const unmarshalGenieListEvalResultsResponseSchema: z.ZodType = z .object({ - text: z.lazy(() => unmarshalTextAttachmentSchema).optional(), - query: z.lazy(() => unmarshalGenieQueryAttachmentSchema).optional(), - suggested_questions: z - .lazy(() => unmarshalGenieSuggestedQuestionsAttachmentSchema) - .optional(), - attachment_id: z.string().optional(), + eval_results: z.array(z.lazy(() => unmarshalGenieEvalResultSchema)).optional(), + next_page_token: z.string().optional(), }) .transform(d => ({ - text: d.text, - query: d.query, - suggestedQuestions: d.suggested_questions, - attachmentId: d.attachment_id, + evalResults: d.eval_results, + nextPageToken: d.next_page_token, })); -export const unmarshalGenieConversationSchema: z.ZodType = z +export const unmarshalGenieListEvalRunsRequestSchema: z.ZodType = z .object({ - id: z.string().optional(), space_id: z.string().optional(), - user_id: z.number().optional(), - created_timestamp: z.number().optional(), - last_updated_timestamp: z.number().optional(), - title: z.string().optional(), - conversation_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), }) .transform(d => ({ - id: d.id, spaceId: d.space_id, - userId: d.user_id, - createdTimestamp: d.created_timestamp, - lastUpdatedTimestamp: d.last_updated_timestamp, - title: d.title, - conversationId: d.conversation_id, + pageSize: d.page_size, + pageToken: d.page_token, })); -export const unmarshalGenieConversationSummarySchema: z.ZodType = - z - .object({ - conversation_id: z.string().optional(), - title: z.string().optional(), - created_timestamp: z.number().optional(), - }) - .transform(d => ({ - conversationId: d.conversation_id, - title: d.title, - createdTimestamp: d.created_timestamp, - })); - -export const unmarshalGenieCreateConversationMessageRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - content: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - content: d.content, - })); - -export const unmarshalGenieCreateEvalRunRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - benchmark_question_ids: z.array(z.string()).optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - benchmarkQuestionIds: d.benchmark_question_ids, - })); - -export const unmarshalGenieCreateMessageCommentRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - content: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - content: d.content, - })); - -export const unmarshalGenieCreateSpaceRequestSchema: z.ZodType = - z - .object({ - warehouse_id: z.string().optional(), - parent_path: z.string().optional(), - serialized_space: z.string().optional(), - title: z.string().optional(), - description: z.string().optional(), - }) - .transform(d => ({ - warehouseId: d.warehouse_id, - parentPath: d.parent_path, - serializedSpace: d.serialized_space, - title: d.title, - description: d.description, - })); - -export const unmarshalGenieDeleteConversationMessageRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - })); - -export const unmarshalGenieDeleteConversationRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - })); - -export const unmarshalGenieEvalResponseSchema: z.ZodType = z +export const unmarshalGenieListEvalRunsResponseSchema: z.ZodType = z .object({ - response: z.string().optional(), - sql_execution_result: z - .lazy(() => unmarshalStatementResponseSchema) - .optional(), - response_type: z.enum(GenieEvalResponseType).optional(), + eval_runs: z.array(z.lazy(() => unmarshalGenieEvalRunResponseSchema)).optional(), + next_page_token: z.string().optional(), }) .transform(d => ({ - response: d.response, - sqlExecutionResult: d.sql_execution_result, - responseType: d.response_type, + evalRuns: d.eval_runs, + nextPageToken: d.next_page_token, })); -export const unmarshalGenieEvalResultSchema: z.ZodType = z +export const unmarshalGenieListMessageCommentsRequestSchema: z.ZodType = z .object({ - result_id: z.string().optional(), space_id: z.string().optional(), - benchmark_question_id: z.string().optional(), - status: z.enum(EvaluationStatusType).optional(), - question: z.string().optional(), - benchmark_answer: z.string().optional(), - created_by_user: z.number().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), }) .transform(d => ({ - resultId: d.result_id, spaceId: d.space_id, - benchmarkQuestionId: d.benchmark_question_id, - status: d.status, - question: d.question, - benchmarkAnswer: d.benchmark_answer, - createdByUser: d.created_by_user, + conversationId: d.conversation_id, + messageId: d.message_id, + pageSize: d.page_size, + pageToken: d.page_token, })); -export const unmarshalGenieEvalResultDetailsSchema: z.ZodType = - z - .object({ - result_id: z.string().optional(), - space_id: z.string().optional(), - benchmark_question_id: z.string().optional(), - eval_run_status: z.enum(EvaluationStatusType).optional(), - assessment: z.enum(GenieEvalAssessment).optional(), - manual_assessment: z.boolean().optional(), - assessment_reasons: z.array(z.enum(ScoreReason)).optional(), - actual_response: z - .array(z.lazy(() => unmarshalGenieEvalResponseSchema)) - .optional(), - expected_response: z - .array(z.lazy(() => unmarshalGenieEvalResponseSchema)) - .optional(), - }) - .transform(d => ({ - resultId: d.result_id, - spaceId: d.space_id, - benchmarkQuestionId: d.benchmark_question_id, - evalRunStatus: d.eval_run_status, - assessment: d.assessment, - manualAssessment: d.manual_assessment, - assessmentReasons: d.assessment_reasons, - actualResponse: d.actual_response, - expectedResponse: d.expected_response, - })); - -export const unmarshalGenieEvalRunResponseSchema: z.ZodType = - z - .object({ - eval_run_id: z.string().optional(), - eval_run_status: z.enum(EvaluationStatusType).optional(), - run_by_user: z.number().optional(), - created_timestamp: z.number().optional(), - num_questions: z.number().optional(), - num_correct: z.number().optional(), - num_needs_review: z.number().optional(), - num_done: z.number().optional(), - last_updated_timestamp: z.number().optional(), - }) - .transform(d => ({ - evalRunId: d.eval_run_id, - evalRunStatus: d.eval_run_status, - runByUser: d.run_by_user, - createdTimestamp: d.created_timestamp, - numQuestions: d.num_questions, - numCorrect: d.num_correct, - numNeedsReview: d.num_needs_review, - numDone: d.num_done, - lastUpdatedTimestamp: d.last_updated_timestamp, - })); - -export const unmarshalGenieExecuteMessageAttachmentQueryRequestSchema: z.ZodType = - z - .object({ - message_id: z.string().optional(), - space_id: z.string().optional(), - conversation_id: z.string().optional(), - attachment_id: z.string().optional(), - }) - .transform(d => ({ - messageId: d.message_id, - spaceId: d.space_id, - conversationId: d.conversation_id, - attachmentId: d.attachment_id, - })); - -export const unmarshalGenieExecuteMessageQueryRequestSchema: z.ZodType = - z - .object({ - message_id: z.string().optional(), - space_id: z.string().optional(), - conversation_id: z.string().optional(), - }) - .transform(d => ({ - messageId: d.message_id, - spaceId: d.space_id, - conversationId: d.conversation_id, - })); +export const unmarshalGenieListMessageCommentsResponseSchema: z.ZodType = z + .object({ + comments: z.array(z.lazy(() => unmarshalGenieMessageCommentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + comments: d.comments, + nextPageToken: d.next_page_token, + })); -export const unmarshalGenieFeedbackSchema: z.ZodType = z +export const unmarshalGenieListSpacesRequestSchema: z.ZodType = z .object({ - rating: z.enum(GenieFeedbackRating).optional(), - comment: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), }) .transform(d => ({ - rating: d.rating, - comment: d.comment, + pageSize: d.page_size, + pageToken: d.page_token, })); -export const unmarshalGenieGenerateDownloadFullQueryResultRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - attachment_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - attachmentId: d.attachment_id, - })); - -export const unmarshalGenieGenerateDownloadFullQueryResultResponseSchema: z.ZodType = - z - .object({ - download_id: z.string().optional(), - download_id_signature: z.string().optional(), - }) - .transform(d => ({ - downloadId: d.download_id, - downloadIdSignature: d.download_id_signature, - })); - -export const unmarshalGenieGetConversationMessageRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - })); - -export const unmarshalGenieGetDownloadFullQueryResultRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - attachment_id: z.string().optional(), - download_id: z.string().optional(), - download_id_signature: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - attachmentId: d.attachment_id, - downloadId: d.download_id, - downloadIdSignature: d.download_id_signature, - })); - -export const unmarshalGenieGetDownloadFullQueryResultResponseSchema: z.ZodType = - z - .object({ - statement_response: z - .lazy(() => unmarshalStatementResponseSchema) - .optional(), - }) - .transform(d => ({ - statementResponse: d.statement_response, - })); - -export const unmarshalGenieGetEvalResultDetailsRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - eval_run_id: z.string().optional(), - result_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - evalRunId: d.eval_run_id, - resultId: d.result_id, - })); - -export const unmarshalGenieGetEvalRunRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - eval_run_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - evalRunId: d.eval_run_id, - })); - -export const unmarshalGenieGetMessageAttachmentQueryResultRequestSchema: z.ZodType = - z - .object({ - message_id: z.string().optional(), - space_id: z.string().optional(), - conversation_id: z.string().optional(), - attachment_id: z.string().optional(), - }) - .transform(d => ({ - messageId: d.message_id, - spaceId: d.space_id, - conversationId: d.conversation_id, - attachmentId: d.attachment_id, - })); - -export const unmarshalGenieGetMessageQueryResultRequestSchema: z.ZodType = - z - .object({ - message_id: z.string().optional(), - space_id: z.string().optional(), - conversation_id: z.string().optional(), - }) - .transform(d => ({ - messageId: d.message_id, - spaceId: d.space_id, - conversationId: d.conversation_id, - })); - -export const unmarshalGenieGetMessageQueryResultResponseSchema: z.ZodType = - z - .object({ - statement_response: z - .lazy(() => unmarshalStatementResponseSchema) - .optional(), - }) - .transform(d => ({ - statementResponse: d.statement_response, - })); - -export const unmarshalGenieGetQueryResultByAttachmentRequestSchema: z.ZodType = - z - .object({ - message_id: z.string().optional(), - space_id: z.string().optional(), - conversation_id: z.string().optional(), - attachment_id: z.string().optional(), - }) - .transform(d => ({ - messageId: d.message_id, - spaceId: d.space_id, - conversationId: d.conversation_id, - attachmentId: d.attachment_id, - })); - -export const unmarshalGenieGetSpaceRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - include_serialized_space: z.boolean().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - includeSerializedSpace: d.include_serialized_space, - })); - -export const unmarshalGenieListConversationCommentsRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalGenieListConversationCommentsResponseSchema: z.ZodType = - z - .object({ - comments: z - .array(z.lazy(() => unmarshalGenieMessageCommentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - comments: d.comments, - nextPageToken: d.next_page_token, - })); - -export const unmarshalGenieListConversationMessagesRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalGenieListConversationMessagesResponseSchema: z.ZodType = - z - .object({ - messages: z.array(z.lazy(() => unmarshalGenieMessageSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - messages: d.messages, - nextPageToken: d.next_page_token, - })); - -export const unmarshalGenieListConversationsRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - include_all: z.boolean().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - pageSize: d.page_size, - pageToken: d.page_token, - includeAll: d.include_all, - })); - -export const unmarshalGenieListConversationsResponseSchema: z.ZodType = - z - .object({ - conversations: z - .array(z.lazy(() => unmarshalGenieConversationSummarySchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - conversations: d.conversations, - nextPageToken: d.next_page_token, - })); - -export const unmarshalGenieListEvalResultsRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - eval_run_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - evalRunId: d.eval_run_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalGenieListEvalResultsResponseSchema: z.ZodType = - z - .object({ - eval_results: z - .array(z.lazy(() => unmarshalGenieEvalResultSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - evalResults: d.eval_results, - nextPageToken: d.next_page_token, - })); - -export const unmarshalGenieListEvalRunsRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalGenieListEvalRunsResponseSchema: z.ZodType = - z - .object({ - eval_runs: z - .array(z.lazy(() => unmarshalGenieEvalRunResponseSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - evalRuns: d.eval_runs, - nextPageToken: d.next_page_token, - })); - -export const unmarshalGenieListMessageCommentsRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalGenieListMessageCommentsResponseSchema: z.ZodType = - z - .object({ - comments: z - .array(z.lazy(() => unmarshalGenieMessageCommentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - comments: d.comments, - nextPageToken: d.next_page_token, - })); - -export const unmarshalGenieListSpacesRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalGenieListSpacesResponseSchema: z.ZodType = - z - .object({ - spaces: z.array(z.lazy(() => unmarshalGenieSpaceSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - spaces: d.spaces, - nextPageToken: d.next_page_token, - })); +export const unmarshalGenieListSpacesResponseSchema: z.ZodType = z + .object({ + spaces: z.array(z.lazy(() => unmarshalGenieSpaceSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + spaces: d.spaces, + nextPageToken: d.next_page_token, + })); export const unmarshalGenieMessageSchema: z.ZodType = z .object({ @@ -2473,9 +2429,7 @@ export const unmarshalGenieMessageSchema: z.ZodType = z last_updated_timestamp: z.number().optional(), status: z.enum(MessageStatus_MessageStatus).optional(), content: z.string().optional(), - attachments: z - .array(z.lazy(() => unmarshalGenieAttachmentSchema)) - .optional(), + attachments: z.array(z.lazy(() => unmarshalGenieAttachmentSchema)).optional(), query_result: z.lazy(() => unmarshalResultSchema).optional(), error: z.lazy(() => unmarshalMessageErrorSchema).optional(), message_id: z.string().optional(), @@ -2497,83 +2451,75 @@ export const unmarshalGenieMessageSchema: z.ZodType = z feedback: d.feedback, })); -export const unmarshalGenieMessageCommentSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - message_comment_id: z.string().optional(), - user_id: z.number().optional(), - content: z.string().optional(), - created_timestamp: z.number().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - messageCommentId: d.message_comment_id, - userId: d.user_id, - content: d.content, - createdTimestamp: d.created_timestamp, - })); - -export const unmarshalGenieQueryAttachmentSchema: z.ZodType = - z - .object({ - title: z.string().optional(), - query: z.string().optional(), - description: z.string().optional(), - last_updated_timestamp: z.number().optional(), - parameters: z - .array(z.lazy(() => unmarshalQueryAttachmentParameterSchema)) - .optional(), - id: z.string().optional(), - statement_id: z.string().optional(), - query_result_metadata: z - .lazy(() => unmarshalGenieResultMetadataSchema) - .optional(), - thoughts: z.array(z.lazy(() => unmarshalThoughtSchema)).optional(), - }) - .transform(d => ({ - title: d.title, - query: d.query, - description: d.description, - lastUpdatedTimestamp: d.last_updated_timestamp, - parameters: d.parameters, - id: d.id, - statementId: d.statement_id, - queryResultMetadata: d.query_result_metadata, - thoughts: d.thoughts, - })); - -export const unmarshalGenieResultMetadataSchema: z.ZodType = - z - .object({ - row_count: z.number().optional(), - is_truncated: z.boolean().optional(), - }) - .transform(d => ({ - rowCount: d.row_count, - isTruncated: d.is_truncated, - })); - -export const unmarshalGenieSendMessageFeedbackRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - conversation_id: z.string().optional(), - message_id: z.string().optional(), - rating: z.enum(GenieFeedbackRating).optional(), - comment: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - conversationId: d.conversation_id, - messageId: d.message_id, - rating: d.rating, - comment: d.comment, - })); +export const unmarshalGenieMessageCommentSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + message_comment_id: z.string().optional(), + user_id: z.number().optional(), + content: z.string().optional(), + created_timestamp: z.number().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + messageCommentId: d.message_comment_id, + userId: d.user_id, + content: d.content, + createdTimestamp: d.created_timestamp, + })); + +export const unmarshalGenieQueryAttachmentSchema: z.ZodType = z + .object({ + title: z.string().optional(), + query: z.string().optional(), + description: z.string().optional(), + last_updated_timestamp: z.number().optional(), + parameters: z.array(z.lazy(() => unmarshalQueryAttachmentParameterSchema)).optional(), + id: z.string().optional(), + statement_id: z.string().optional(), + query_result_metadata: z.lazy(() => unmarshalGenieResultMetadataSchema).optional(), + thoughts: z.array(z.lazy(() => unmarshalThoughtSchema)).optional(), + }) + .transform(d => ({ + title: d.title, + query: d.query, + description: d.description, + lastUpdatedTimestamp: d.last_updated_timestamp, + parameters: d.parameters, + id: d.id, + statementId: d.statement_id, + queryResultMetadata: d.query_result_metadata, + thoughts: d.thoughts, + })); + +export const unmarshalGenieResultMetadataSchema: z.ZodType = z + .object({ + row_count: z.number().optional(), + is_truncated: z.boolean().optional(), + }) + .transform(d => ({ + rowCount: d.row_count, + isTruncated: d.is_truncated, + })); + +export const unmarshalGenieSendMessageFeedbackRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + conversation_id: z.string().optional(), + message_id: z.string().optional(), + rating: z.enum(GenieFeedbackRating).optional(), + comment: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + conversationId: d.conversation_id, + messageId: d.message_id, + rating: d.rating, + comment: d.comment, + })); export const unmarshalGenieSpaceSchema: z.ZodType = z .object({ @@ -2583,6 +2529,7 @@ export const unmarshalGenieSpaceSchema: z.ZodType = z warehouse_id: z.string().optional(), parent_path: z.string().optional(), serialized_space: z.string().optional(), + etag: z.string().optional(), }) .transform(d => ({ spaceId: d.space_id, @@ -2591,68 +2538,66 @@ export const unmarshalGenieSpaceSchema: z.ZodType = z warehouseId: d.warehouse_id, parentPath: d.parent_path, serializedSpace: d.serialized_space, + etag: d.etag, })); -export const unmarshalGenieStartConversationMessageRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - content: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - content: d.content, - })); - -export const unmarshalGenieStartConversationResponseSchema: z.ZodType = - z - .object({ - message_id: z.string().optional(), - message: z.lazy(() => unmarshalGenieMessageSchema).optional(), - conversation_id: z.string().optional(), - conversation: z.lazy(() => unmarshalGenieConversationSchema).optional(), - }) - .transform(d => ({ - messageId: d.message_id, - message: d.message, - conversationId: d.conversation_id, - conversation: d.conversation, - })); - -export const unmarshalGenieSuggestedQuestionsAttachmentSchema: z.ZodType = - z - .object({ - questions: z.array(z.string()).optional(), - }) - .transform(d => ({ - questions: d.questions, - })); - -export const unmarshalGenieTrashSpaceRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - })); - -export const unmarshalGenieUpdateSpaceRequestSchema: z.ZodType = - z - .object({ - space_id: z.string().optional(), - serialized_space: z.string().optional(), - title: z.string().optional(), - description: z.string().optional(), - warehouse_id: z.string().optional(), - }) - .transform(d => ({ - spaceId: d.space_id, - serializedSpace: d.serialized_space, - title: d.title, - description: d.description, - warehouseId: d.warehouse_id, - })); +export const unmarshalGenieStartConversationMessageRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + content: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + content: d.content, + })); + +export const unmarshalGenieStartConversationResponseSchema: z.ZodType = z + .object({ + message_id: z.string().optional(), + message: z.lazy(() => unmarshalGenieMessageSchema).optional(), + conversation_id: z.string().optional(), + conversation: z.lazy(() => unmarshalGenieConversationSchema).optional(), + }) + .transform(d => ({ + messageId: d.message_id, + message: d.message, + conversationId: d.conversation_id, + conversation: d.conversation, + })); + +export const unmarshalGenieSuggestedQuestionsAttachmentSchema: z.ZodType = z + .object({ + questions: z.array(z.string()).optional(), + }) + .transform(d => ({ + questions: d.questions, + })); + +export const unmarshalGenieTrashSpaceRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + })); + +export const unmarshalGenieUpdateSpaceRequestSchema: z.ZodType = z + .object({ + space_id: z.string().optional(), + serialized_space: z.string().optional(), + title: z.string().optional(), + description: z.string().optional(), + warehouse_id: z.string().optional(), + etag: z.string().optional(), + }) + .transform(d => ({ + spaceId: d.space_id, + serializedSpace: d.serialized_space, + title: d.title, + description: d.description, + warehouseId: d.warehouse_id, + etag: d.etag, + })); export const unmarshalListValueSchema: z.ZodType = z .object({ @@ -2662,16 +2607,15 @@ export const unmarshalListValueSchema: z.ZodType = z values: d.values, })); -export const unmarshalMapStringValueEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.lazy(() => unmarshalValueSchema).optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalMapStringValueEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.lazy(() => unmarshalValueSchema).optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalMessageErrorSchema: z.ZodType = z .object({ @@ -2683,33 +2627,31 @@ export const unmarshalMessageErrorSchema: z.ZodType = z type: d.type, })); -export const unmarshalMessageStatusSchema: z.ZodType = z.object( - {} -); - -export const unmarshalPolicyFunctionArgumentSchema: z.ZodType = - z - .object({ - column: z.string().optional(), - constant: z.string().optional(), - }) - .transform(d => ({ - column: d.column, - constant: d.constant, - })); - -export const unmarshalQueryAttachmentParameterSchema: z.ZodType = - z - .object({ - keyword: z.string().optional(), - value: z.string().optional(), - sql_type: z.string().optional(), - }) - .transform(d => ({ - keyword: d.keyword, - value: d.value, - sqlType: d.sql_type, - })); +export const unmarshalMessageStatusSchema: z.ZodType = z + .object({ + }); + +export const unmarshalPolicyFunctionArgumentSchema: z.ZodType = z + .object({ + column: z.string().optional(), + constant: z.string().optional(), + }) + .transform(d => ({ + column: d.column, + constant: d.constant, + })); + +export const unmarshalQueryAttachmentParameterSchema: z.ZodType = z + .object({ + keyword: z.string().optional(), + value: z.string().optional(), + sql_type: z.string().optional(), + }) + .transform(d => ({ + keyword: d.keyword, + value: d.value, + sqlType: d.sql_type, + })); export const unmarshalResultSchema: z.ZodType = z .object({ @@ -2727,9 +2669,7 @@ export const unmarshalResultSchema: z.ZodType = z export const unmarshalResultDataSchema: z.ZodType = z .object({ - external_links: z - .array(z.lazy(() => unmarshalExternalLinkSchema)) - .optional(), + external_links: z.array(z.lazy(() => unmarshalExternalLinkSchema)).optional(), data_array: z.array(z.lazy(() => unmarshalListValueSchema)).optional(), chunk_index: z.number().optional(), row_offset: z.number().optional(), @@ -2796,9 +2736,7 @@ export const unmarshalStatementResponseSchema: z.ZodType = z export const unmarshalStatementStatusSchema: z.ZodType = z .object({ state: z.enum(StatementStatus_State).optional(), - error: z - .lazy(() => unmarshalDatabricksServiceExceptionProtoSchema) - .optional(), + error: z.lazy(() => unmarshalDatabricksServiceExceptionProtoSchema).optional(), sql_state: z.string().optional(), }) .transform(d => ({ @@ -2809,9 +2747,7 @@ export const unmarshalStatementStatusSchema: z.ZodType = z export const unmarshalStructSchema: z.ZodType = z .object({ - fields: z - .array(z.lazy(() => unmarshalMapStringValueEntrySchema)) - .optional(), + fields: z.array(z.lazy(() => unmarshalMapStringValueEntrySchema)).optional(), }) .transform(d => ({ fields: d.fields, @@ -2822,9 +2758,7 @@ export const unmarshalTextAttachmentSchema: z.ZodType = z content: z.string().optional(), id: z.string().optional(), phase: z.enum(ResponsePhase).optional(), - verification_metadata: z - .lazy(() => unmarshalVerificationMetadataSchema) - .optional(), + verification_metadata: z.lazy(() => unmarshalVerificationMetadataSchema).optional(), purpose: z.enum(TextAttachmentPurpose).optional(), }) .transform(d => ({ @@ -2863,16 +2797,15 @@ export const unmarshalValueSchema: z.ZodType = z listValue: d.list_value, })); -export const unmarshalVerificationMetadataSchema: z.ZodType = - z - .object({ - section: z.enum(VerificationSection).optional(), - index: z.number().optional(), - }) - .transform(d => ({ - section: d.section, - index: d.index, - })); +export const unmarshalVerificationMetadataSchema: z.ZodType = z + .object({ + section: z.enum(VerificationSection).optional(), + index: z.number().optional(), + }) + .transform(d => ({ + section: d.section, + index: d.index, + })); export const marshalChunkInfoSchema: z.ZodType = z .object({ @@ -2926,9 +2859,7 @@ export const marshalColumnMaskSchema: z.ZodType = z .object({ functionName: z.string().optional(), usingColumnNames: z.array(z.string()).optional(), - usingArguments: z - .array(z.lazy(() => marshalPolicyFunctionArgumentSchema)) - .optional(), + usingArguments: z.array(z.lazy(() => marshalPolicyFunctionArgumentSchema)).optional(), }) .transform(d => ({ function_name: d.functionName, @@ -2987,9 +2918,7 @@ export const marshalGenieAttachmentSchema: z.ZodType = z .object({ text: z.lazy(() => marshalTextAttachmentSchema).optional(), query: z.lazy(() => marshalGenieQueryAttachmentSchema).optional(), - suggestedQuestions: z - .lazy(() => marshalGenieSuggestedQuestionsAttachmentSchema) - .optional(), + suggestedQuestions: z.lazy(() => marshalGenieSuggestedQuestionsAttachmentSchema).optional(), attachmentId: z.string().optional(), }) .transform(d => ({ @@ -3146,12 +3075,8 @@ export const marshalGenieEvalResultDetailsSchema: z.ZodType = z assessment: z.enum(GenieEvalAssessment).optional(), manualAssessment: z.boolean().optional(), assessmentReasons: z.array(z.enum(ScoreReason)).optional(), - actualResponse: z - .array(z.lazy(() => marshalGenieEvalResponseSchema)) - .optional(), - expectedResponse: z - .array(z.lazy(() => marshalGenieEvalResponseSchema)) - .optional(), + actualResponse: z.array(z.lazy(() => marshalGenieEvalResponseSchema)).optional(), + expectedResponse: z.array(z.lazy(() => marshalGenieEvalResponseSchema)).optional(), }) .transform(d => ({ result_id: d.resultId, @@ -3189,20 +3114,19 @@ export const marshalGenieEvalRunResponseSchema: z.ZodType = z last_updated_timestamp: d.lastUpdatedTimestamp, })); -export const marshalGenieExecuteMessageAttachmentQueryRequestSchema: z.ZodType = - z - .object({ - messageId: z.string().optional(), - spaceId: z.string().optional(), - conversationId: z.string().optional(), - attachmentId: z.string().optional(), - }) - .transform(d => ({ - message_id: d.messageId, - space_id: d.spaceId, - conversation_id: d.conversationId, - attachment_id: d.attachmentId, - })); +export const marshalGenieExecuteMessageAttachmentQueryRequestSchema: z.ZodType = z + .object({ + messageId: z.string().optional(), + spaceId: z.string().optional(), + conversationId: z.string().optional(), + attachmentId: z.string().optional(), + }) + .transform(d => ({ + message_id: d.messageId, + space_id: d.spaceId, + conversation_id: d.conversationId, + attachment_id: d.attachmentId, + })); export const marshalGenieExecuteMessageQueryRequestSchema: z.ZodType = z .object({ @@ -3226,31 +3150,29 @@ export const marshalGenieFeedbackSchema: z.ZodType = z comment: d.comment, })); -export const marshalGenieGenerateDownloadFullQueryResultRequestSchema: z.ZodType = - z - .object({ - spaceId: z.string().optional(), - conversationId: z.string().optional(), - messageId: z.string().optional(), - attachmentId: z.string().optional(), - }) - .transform(d => ({ - space_id: d.spaceId, - conversation_id: d.conversationId, - message_id: d.messageId, - attachment_id: d.attachmentId, - })); - -export const marshalGenieGenerateDownloadFullQueryResultResponseSchema: z.ZodType = - z - .object({ - downloadId: z.string().optional(), - downloadIdSignature: z.string().optional(), - }) - .transform(d => ({ - download_id: d.downloadId, - download_id_signature: d.downloadIdSignature, - })); +export const marshalGenieGenerateDownloadFullQueryResultRequestSchema: z.ZodType = z + .object({ + spaceId: z.string().optional(), + conversationId: z.string().optional(), + messageId: z.string().optional(), + attachmentId: z.string().optional(), + }) + .transform(d => ({ + space_id: d.spaceId, + conversation_id: d.conversationId, + message_id: d.messageId, + attachment_id: d.attachmentId, + })); + +export const marshalGenieGenerateDownloadFullQueryResultResponseSchema: z.ZodType = z + .object({ + downloadId: z.string().optional(), + downloadIdSignature: z.string().optional(), + }) + .transform(d => ({ + download_id: d.downloadId, + download_id_signature: d.downloadIdSignature, + })); export const marshalGenieGetConversationMessageRequestSchema: z.ZodType = z .object({ @@ -3312,20 +3234,19 @@ export const marshalGenieGetEvalRunRequestSchema: z.ZodType = z eval_run_id: d.evalRunId, })); -export const marshalGenieGetMessageAttachmentQueryResultRequestSchema: z.ZodType = - z - .object({ - messageId: z.string().optional(), - spaceId: z.string().optional(), - conversationId: z.string().optional(), - attachmentId: z.string().optional(), - }) - .transform(d => ({ - message_id: d.messageId, - space_id: d.spaceId, - conversation_id: d.conversationId, - attachment_id: d.attachmentId, - })); +export const marshalGenieGetMessageAttachmentQueryResultRequestSchema: z.ZodType = z + .object({ + messageId: z.string().optional(), + spaceId: z.string().optional(), + conversationId: z.string().optional(), + attachmentId: z.string().optional(), + }) + .transform(d => ({ + message_id: d.messageId, + space_id: d.spaceId, + conversation_id: d.conversationId, + attachment_id: d.attachmentId, + })); export const marshalGenieGetMessageQueryResultRequestSchema: z.ZodType = z .object({ @@ -3387,9 +3308,7 @@ export const marshalGenieListConversationCommentsRequestSchema: z.ZodType = z export const marshalGenieListConversationCommentsResponseSchema: z.ZodType = z .object({ - comments: z - .array(z.lazy(() => marshalGenieMessageCommentSchema)) - .optional(), + comments: z.array(z.lazy(() => marshalGenieMessageCommentSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -3437,9 +3356,7 @@ export const marshalGenieListConversationsRequestSchema: z.ZodType = z export const marshalGenieListConversationsResponseSchema: z.ZodType = z .object({ - conversations: z - .array(z.lazy(() => marshalGenieConversationSummarySchema)) - .optional(), + conversations: z.array(z.lazy(() => marshalGenieConversationSummarySchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -3485,9 +3402,7 @@ export const marshalGenieListEvalRunsRequestSchema: z.ZodType = z export const marshalGenieListEvalRunsResponseSchema: z.ZodType = z .object({ - evalRuns: z - .array(z.lazy(() => marshalGenieEvalRunResponseSchema)) - .optional(), + evalRuns: z.array(z.lazy(() => marshalGenieEvalRunResponseSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -3513,9 +3428,7 @@ export const marshalGenieListMessageCommentsRequestSchema: z.ZodType = z export const marshalGenieListMessageCommentsResponseSchema: z.ZodType = z .object({ - comments: z - .array(z.lazy(() => marshalGenieMessageCommentSchema)) - .optional(), + comments: z.array(z.lazy(() => marshalGenieMessageCommentSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -3601,14 +3514,10 @@ export const marshalGenieQueryAttachmentSchema: z.ZodType = z query: z.string().optional(), description: z.string().optional(), lastUpdatedTimestamp: z.number().optional(), - parameters: z - .array(z.lazy(() => marshalQueryAttachmentParameterSchema)) - .optional(), + parameters: z.array(z.lazy(() => marshalQueryAttachmentParameterSchema)).optional(), id: z.string().optional(), statementId: z.string().optional(), - queryResultMetadata: z - .lazy(() => marshalGenieResultMetadataSchema) - .optional(), + queryResultMetadata: z.lazy(() => marshalGenieResultMetadataSchema).optional(), thoughts: z.array(z.lazy(() => marshalThoughtSchema)).optional(), }) .transform(d => ({ @@ -3657,6 +3566,7 @@ export const marshalGenieSpaceSchema: z.ZodType = z warehouseId: z.string().optional(), parentPath: z.string().optional(), serializedSpace: z.string().optional(), + etag: z.string().optional(), }) .transform(d => ({ space_id: d.spaceId, @@ -3665,6 +3575,7 @@ export const marshalGenieSpaceSchema: z.ZodType = z warehouse_id: d.warehouseId, parent_path: d.parentPath, serialized_space: d.serializedSpace, + etag: d.etag, })); export const marshalGenieStartConversationMessageRequestSchema: z.ZodType = z @@ -3714,6 +3625,7 @@ export const marshalGenieUpdateSpaceRequestSchema: z.ZodType = z title: z.string().optional(), description: z.string().optional(), warehouseId: z.string().optional(), + etag: z.string().optional(), }) .transform(d => ({ space_id: d.spaceId, @@ -3721,6 +3633,7 @@ export const marshalGenieUpdateSpaceRequestSchema: z.ZodType = z title: d.title, description: d.description, warehouse_id: d.warehouseId, + etag: d.etag, })); export const marshalListValueSchema: z.ZodType = z @@ -3751,7 +3664,9 @@ export const marshalMessageErrorSchema: z.ZodType = z type: d.type, })); -export const marshalMessageStatusSchema: z.ZodType = z.object({}); +export const marshalMessageStatusSchema: z.ZodType = z + .object({ + }); export const marshalPolicyFunctionArgumentSchema: z.ZodType = z .object({ @@ -3858,9 +3773,7 @@ export const marshalStatementResponseSchema: z.ZodType = z export const marshalStatementStatusSchema: z.ZodType = z .object({ state: z.enum(StatementStatus_State).optional(), - error: z - .lazy(() => marshalDatabricksServiceExceptionProtoSchema) - .optional(), + error: z.lazy(() => marshalDatabricksServiceExceptionProtoSchema).optional(), sqlState: z.string().optional(), }) .transform(d => ({ @@ -3882,9 +3795,7 @@ export const marshalTextAttachmentSchema: z.ZodType = z content: z.string().optional(), id: z.string().optional(), phase: z.enum(ResponsePhase).optional(), - verificationMetadata: z - .lazy(() => marshalVerificationMetadataSchema) - .optional(), + verificationMetadata: z.lazy(() => marshalVerificationMetadataSchema).optional(), purpose: z.enum(TextAttachmentPurpose).optional(), }) .transform(d => ({ diff --git a/packages/genie/src/v1/utils.ts b/packages/genie/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/genie/src/v1/utils.ts +++ b/packages/genie/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/genie/tsconfig.json b/packages/genie/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/genie/tsconfig.json +++ b/packages/genie/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/globalinitscripts/package.json b/packages/globalinitscripts/package.json new file mode 100644 index 00000000..dae615c9 --- /dev/null +++ b/packages/globalinitscripts/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-globalinitscripts", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v2": { + "types": "./dist/v2/index.d.ts", + "import": "./dist/v2/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/globalinitscripts/src/v2/client.ts b/packages/globalinitscripts/src/v2/client.ts new file mode 100644 index 00000000..0fe5903a --- /dev/null +++ b/packages/globalinitscripts/src/v2/client.ts @@ -0,0 +1,134 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + CreateGlobalInitScript, + CreateGlobalInitScript_Response, + DeleteGlobalInitScript, + DeleteGlobalInitScript_Response, + GetGlobalInitScript, + GlobalInitScriptDetails, + ListGlobalInitScripts, + ListGlobalInitScripts_Response, + UpdateGlobalInitScript, + UpdateGlobalInitScript_Response, +} from './model'; +import { + marshalCreateGlobalInitScriptSchema, + marshalUpdateGlobalInitScriptSchema, + unmarshalCreateGlobalInitScript_ResponseSchema, + unmarshalDeleteGlobalInitScript_ResponseSchema, + unmarshalGlobalInitScriptDetailsSchema, + unmarshalListGlobalInitScripts_ResponseSchema, + unmarshalUpdateGlobalInitScript_ResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** Creates a new global init script in this workspace. */ + async createGlobalInitScript(signal: AbortSignal | undefined, req: CreateGlobalInitScript, options?: Options): Promise { + const url = `${this.host}/api/2.0/global-init-scripts`; + const body = marshalRequest(req, marshalCreateGlobalInitScriptSchema); + let resp: CreateGlobalInitScript_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateGlobalInitScript_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Deletes a global init script. */ + async deleteGlobalInitScript(signal: AbortSignal | undefined, req: DeleteGlobalInitScript, options?: Options): Promise { + const url = `${this.host}/api/2.0/global-init-scripts/${req.scriptId ?? ''}`; + let resp: DeleteGlobalInitScript_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('DELETE', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteGlobalInitScript_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Gets all the details of a script, including its Base64-encoded contents. */ + async getGlobalInitScript(signal: AbortSignal | undefined, req: GetGlobalInitScript, options?: Options): Promise { + const url = `${this.host}/api/2.0/global-init-scripts/${req.scriptId ?? ''}`; + let resp: GlobalInitScriptDetails | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGlobalInitScriptDetailsSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Get a list of all global init scripts for this workspace. This returns all properties for each script but **not** the script contents. + * To retrieve the contents of a script, use the [get a global init script](:method:globalinitscripts/get) operation. + */ + async listGlobalInitScripts(signal: AbortSignal | undefined, _req: ListGlobalInitScripts, options?: Options): Promise { + const url = `${this.host}/api/2.0/global-init-scripts`; + let resp: ListGlobalInitScripts_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListGlobalInitScripts_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Updates a global init script, specifying only the fields to change. All fields are optional. + * Unspecified fields retain their current value. + */ + async updateGlobalInitScript(signal: AbortSignal | undefined, req: UpdateGlobalInitScript, options?: Options): Promise { + const url = `${this.host}/api/2.0/global-init-scripts/${req.scriptId ?? ''}`; + const body = marshalRequest(req, marshalUpdateGlobalInitScriptSchema); + let resp: UpdateGlobalInitScript_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('PATCH', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdateGlobalInitScript_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/globalinitscripts/src/v2/index.ts b/packages/globalinitscripts/src/v2/index.ts new file mode 100644 index 00000000..0874a6ce --- /dev/null +++ b/packages/globalinitscripts/src/v2/index.ts @@ -0,0 +1,20 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { +} from './model'; + +export type { + CreateGlobalInitScript, + CreateGlobalInitScript_Response, + DeleteGlobalInitScript, + DeleteGlobalInitScript_Response, + GetGlobalInitScript, + GlobalInitScriptDetails, + ListGlobalInitScripts, + ListGlobalInitScripts_Response, + UpdateGlobalInitScript, + UpdateGlobalInitScript_Response, +} from './model'; diff --git a/packages/globalinitscripts/src/v2/model.ts b/packages/globalinitscripts/src/v2/model.ts new file mode 100644 index 00000000..e8fd9b74 --- /dev/null +++ b/packages/globalinitscripts/src/v2/model.ts @@ -0,0 +1,295 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +export interface CreateGlobalInitScript { + /** The name of the script */ + name?: string | undefined; + /** The Base64-encoded content of the script. */ + script?: Uint8Array | undefined; + /** + * 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?: number | undefined; + /** Specifies whether the script is enabled. The script runs only if enabled. */ + enabled?: boolean | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface CreateGlobalInitScript_Response { + /** The global init script ID. */ + scriptId?: string | undefined; +} + +export interface DeleteGlobalInitScript { + /** The ID of the global init script. */ + scriptId?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeleteGlobalInitScript_Response {} + +export interface GetGlobalInitScript { + /** The ID of the global init script. */ + scriptId?: string | undefined; +} + +export interface GlobalInitScriptDetails { + /** The global init script ID. */ + scriptId?: string | undefined; + /** The name of the script */ + name?: string | undefined; + /** The position of a script, where 0 represents the first script to run, 1 is the second script to run, in ascending order. */ + position?: number | undefined; + /** Specifies whether the script is enabled. The script runs only if enabled. */ + enabled?: boolean | undefined; + /** The username of the user who created the script. */ + createdBy?: string | undefined; + /** Time when the script was created, represented as a Unix timestamp in milliseconds. */ + createdAt?: number | undefined; + /** The username of the user who last updated the script */ + updatedBy?: string | undefined; + /** Time when the script was updated, represented as a Unix timestamp in milliseconds. */ + updatedAt?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ListGlobalInitScripts {} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListGlobalInitScripts_Response { + scripts?: GlobalInitScriptDetails[] | undefined; +} + +export interface UpdateGlobalInitScript { + /** The ID of the global init script. */ + scriptId?: string | undefined; + /** The name of the script */ + name?: string | undefined; + /** The Base64-encoded content of the script. */ + script?: Uint8Array | undefined; + /** + * 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?: number | undefined; + /** Specifies whether the script is enabled. The script runs only if enabled. */ + enabled?: boolean | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface UpdateGlobalInitScript_Response {} + +export const unmarshalCreateGlobalInitScriptSchema: z.ZodType = z + .object({ + name: z.string().optional(), + script: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + position: z.number().optional(), + enabled: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + script: d.script, + position: d.position, + enabled: d.enabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateGlobalInitScript_ResponseSchema: z.ZodType = z + .object({ + script_id: z.string().optional(), + }) + .transform(d => ({ + scriptId: d.script_id, + })); + +export const unmarshalDeleteGlobalInitScriptSchema: z.ZodType = z + .object({ + script_id: z.string().optional(), + }) + .transform(d => ({ + scriptId: d.script_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeleteGlobalInitScript_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalGetGlobalInitScriptSchema: z.ZodType = z + .object({ + script_id: z.string().optional(), + }) + .transform(d => ({ + scriptId: d.script_id, + })); + +export const unmarshalGlobalInitScriptDetailsSchema: z.ZodType = z + .object({ + script_id: z.string().optional(), + name: z.string().optional(), + position: z.number().optional(), + enabled: z.boolean().optional(), + created_by: z.string().optional(), + created_at: z.number().optional(), + updated_by: z.string().optional(), + updated_at: z.number().optional(), + }) + .transform(d => ({ + scriptId: d.script_id, + name: d.name, + position: d.position, + enabled: d.enabled, + createdBy: d.created_by, + createdAt: d.created_at, + updatedBy: d.updated_by, + updatedAt: d.updated_at, + })); + +export const unmarshalListGlobalInitScriptsSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListGlobalInitScripts_ResponseSchema: z.ZodType = z + .object({ + scripts: z.array(z.lazy(() => unmarshalGlobalInitScriptDetailsSchema)).optional(), + }) + .transform(d => ({ + scripts: d.scripts, + })); + +export const unmarshalUpdateGlobalInitScriptSchema: z.ZodType = z + .object({ + script_id: z.string().optional(), + name: z.string().optional(), + script: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + position: z.number().optional(), + enabled: z.boolean().optional(), + }) + .transform(d => ({ + scriptId: d.script_id, + name: d.name, + script: d.script, + position: d.position, + enabled: d.enabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalUpdateGlobalInitScript_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalCreateGlobalInitScriptSchema: z.ZodType = z + .object({ + name: z.string().optional(), + script: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + position: z.number().optional(), + enabled: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + script: d.script, + position: d.position, + enabled: d.enabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreateGlobalInitScript_ResponseSchema: z.ZodType = z + .object({ + scriptId: z.string().optional(), + }) + .transform(d => ({ + script_id: d.scriptId, + })); + +export const marshalDeleteGlobalInitScriptSchema: z.ZodType = z + .object({ + scriptId: z.string().optional(), + }) + .transform(d => ({ + script_id: d.scriptId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeleteGlobalInitScript_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalGetGlobalInitScriptSchema: z.ZodType = z + .object({ + scriptId: z.string().optional(), + }) + .transform(d => ({ + script_id: d.scriptId, + })); + +export const marshalGlobalInitScriptDetailsSchema: z.ZodType = z + .object({ + scriptId: z.string().optional(), + name: z.string().optional(), + position: z.number().optional(), + enabled: z.boolean().optional(), + createdBy: z.string().optional(), + createdAt: z.number().optional(), + updatedBy: z.string().optional(), + updatedAt: z.number().optional(), + }) + .transform(d => ({ + script_id: d.scriptId, + name: d.name, + position: d.position, + enabled: d.enabled, + created_by: d.createdBy, + created_at: d.createdAt, + updated_by: d.updatedBy, + updated_at: d.updatedAt, + })); + +export const marshalListGlobalInitScriptsSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListGlobalInitScripts_ResponseSchema: z.ZodType = z + .object({ + scripts: z.array(z.lazy(() => marshalGlobalInitScriptDetailsSchema)).optional(), + }) + .transform(d => ({ + scripts: d.scripts, + })); + +export const marshalUpdateGlobalInitScriptSchema: z.ZodType = z + .object({ + scriptId: z.string().optional(), + name: z.string().optional(), + script: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + position: z.number().optional(), + enabled: z.boolean().optional(), + }) + .transform(d => ({ + script_id: d.scriptId, + name: d.name, + script: d.script, + position: d.position, + enabled: d.enabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalUpdateGlobalInitScript_ResponseSchema: z.ZodType = z + .object({ + }); diff --git a/packages/globalinitscripts/src/v2/utils.ts b/packages/globalinitscripts/src/v2/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/globalinitscripts/src/v2/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/globalinitscripts/tsconfig.json b/packages/globalinitscripts/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/globalinitscripts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/grants/package.json b/packages/grants/package.json index add691c6..5505f233 100644 --- a/packages/grants/package.json +++ b/packages/grants/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/grants/src/v1/client.ts b/packages/grants/src/v1/client.ts index 2dbe6f44..f56b7d0b 100644 --- a/packages/grants/src/v1/client.ts +++ b/packages/grants/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { EffectivePrivilegeAssignment, GetEffectivePermissions, @@ -52,17 +47,13 @@ export class Client { /** * Gets the effective permissions for a securable. Includes inherited permissions from any parent securables. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async getEffectivePermissions( - signal: AbortSignal | undefined, - req: GetEffectivePermissions, - options?: Options - ): Promise { + async getEffectivePermissions(signal: AbortSignal | undefined, req: GetEffectivePermissions, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/effective-permissions/${req.securableType ?? ''}/${req.securableFullName ?? ''}`; const params = new URLSearchParams(); if (req.principal !== undefined) { @@ -79,15 +70,8 @@ export class Client { let resp: GetEffectivePermissions_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetEffectivePermissions_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetEffectivePermissions_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -98,17 +82,13 @@ export class Client { /** * Gets the permissions for a securable. Does not include inherited permissions. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async getPermissions( - signal: AbortSignal | undefined, - req: GetPermissions, - options?: Options - ): Promise { + async getPermissions(signal: AbortSignal | undefined, req: GetPermissions, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/permissions/${req.securableType ?? ''}/${req.securableFullName ?? ''}`; const params = new URLSearchParams(); if (req.principal !== undefined) { @@ -121,21 +101,14 @@ export class Client { params.append('page_token', req.pageToken); } if (req.includeDeletedPrincipals !== undefined) { - params.append( - 'include_deleted_principals', - String(req.includeDeletedPrincipals) - ); + params.append('include_deleted_principals', String(req.includeDeletedPrincipals)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: GetPermissions_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGetPermissions_ResponseSchema); }; await execute(signal, call, options); @@ -149,21 +122,14 @@ export class Client { * Lists the effective privilege assignments for a securable. Includes inherited privileges. * Paginated version of Get Effective Permissions API. */ - async listEffectivePrivilegeAssignments( - signal: AbortSignal | undefined, - req: ListEffectivePrivilegeAssignmentsRequest, - options?: Options - ): Promise { + async listEffectivePrivilegeAssignments(signal: AbortSignal | undefined, req: ListEffectivePrivilegeAssignmentsRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/effective-privilege-assignments/${req.securableType ?? ''}/${req.fullName ?? ''}`; const params = new URLSearchParams(); if (req.principal !== undefined) { params.append('principal', req.principal); } if (req.includeDeletedPrincipals !== undefined) { - params.append( - 'include_deleted_principals', - String(req.includeDeletedPrincipals) - ); + params.append('include_deleted_principals', String(req.includeDeletedPrincipals)); } if (req.pageSize !== undefined) { params.append('page_size', String(req.pageSize)); @@ -176,15 +142,8 @@ export class Client { let resp: ListEffectivePrivilegeAssignmentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListEffectivePrivilegeAssignmentsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListEffectivePrivilegeAssignmentsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -193,18 +152,11 @@ export class Client { return resp; } - async *listEffectivePrivilegeAssignmentsIter( - signal: AbortSignal | undefined, - req: ListEffectivePrivilegeAssignmentsRequest, - options?: Options - ): AsyncGenerator { + + async *listEffectivePrivilegeAssignmentsIter(signal: AbortSignal | undefined, req: ListEffectivePrivilegeAssignmentsRequest, options?: Options): AsyncGenerator { const pageReq: ListEffectivePrivilegeAssignmentsRequest = {...req}; for (;;) { - const resp = await this.listEffectivePrivilegeAssignments( - signal, - pageReq, - options - ); + const resp = await this.listEffectivePrivilegeAssignments(signal, pageReq, options); for (const item of resp.effectivePrivilegeAssignments ?? []) { yield item; } @@ -215,25 +167,19 @@ export class Client { } } + /** * Lists the privilege assignments for a securable. Does not include inherited privileges. * Paginated version of Get Permissions API. */ - async listPrivilegeAssignments( - signal: AbortSignal | undefined, - req: ListPrivilegeAssignmentsRequest, - options?: Options - ): Promise { + async listPrivilegeAssignments(signal: AbortSignal | undefined, req: ListPrivilegeAssignmentsRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/privilege-assignments/${req.securableType ?? ''}/${req.fullName ?? ''}`; const params = new URLSearchParams(); if (req.principal !== undefined) { params.append('principal', req.principal); } if (req.includeDeletedPrincipals !== undefined) { - params.append( - 'include_deleted_principals', - String(req.includeDeletedPrincipals) - ); + params.append('include_deleted_principals', String(req.includeDeletedPrincipals)); } if (req.pageSize !== undefined) { params.append('page_size', String(req.pageSize)); @@ -246,15 +192,8 @@ export class Client { let resp: ListPrivilegeAssignmentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListPrivilegeAssignmentsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListPrivilegeAssignmentsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -263,18 +202,11 @@ export class Client { return resp; } - async *listPrivilegeAssignmentsIter( - signal: AbortSignal | undefined, - req: ListPrivilegeAssignmentsRequest, - options?: Options - ): AsyncGenerator { + + async *listPrivilegeAssignmentsIter(signal: AbortSignal | undefined, req: ListPrivilegeAssignmentsRequest, options?: Options): AsyncGenerator { const pageReq: ListPrivilegeAssignmentsRequest = {...req}; for (;;) { - const resp = await this.listPrivilegeAssignments( - signal, - pageReq, - options - ); + const resp = await this.listPrivilegeAssignments(signal, pageReq, options); for (const item of resp.privilegeAssignments ?? []) { yield item; } @@ -285,22 +217,15 @@ export class Client { } } + /** Updates the permissions for a securable. */ - async updatePermissions( - signal: AbortSignal | undefined, - req: UpdatePermissions, - options?: Options - ): Promise { + async updatePermissions(signal: AbortSignal | undefined, req: UpdatePermissions, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/permissions/${req.securableType ?? ''}/${req.securableFullName ?? ''}`; const body = marshalRequest(req, marshalUpdatePermissionsSchema); let resp: UpdatePermissions_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUpdatePermissions_ResponseSchema); }; await execute(signal, call, options); diff --git a/packages/grants/src/v1/index.ts b/packages/grants/src/v1/index.ts index 8015e2fc..0a8fae5e 100644 --- a/packages/grants/src/v1/index.ts +++ b/packages/grants/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { EffectivePrivilege, diff --git a/packages/grants/src/v1/model.ts b/packages/grants/src/v1/model.ts index e49dd25b..ed036326 100644 --- a/packages/grants/src/v1/model.ts +++ b/packages/grants/src/v1/model.ts @@ -35,7 +35,7 @@ export interface GetEffectivePermissions { * 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 @@ -71,7 +71,7 @@ export interface GetPermissions { * 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 @@ -139,7 +139,7 @@ export interface ListPrivilegeAssignmentsRequest { * 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, page length is the server configured value. * If set to * - lesser than 0: invalid parameter error @@ -174,9 +174,9 @@ export interface PermissionsChange { remove?: string[] | undefined; /** * An opaque internal ID that identifies the principal whose privileges should be removed. - * + * * This field is intended for removing privileges associated with a deleted user. When set, only the entries specified in the remove field are processed; any entries in the add field will be rejected. - * + * * Only one of principal or principal_id should be specified, never both at the same time. */ principalId?: number | undefined; @@ -209,62 +209,54 @@ export interface UpdatePermissions_Response { privilegeAssignments?: PrivilegeAssignment[] | undefined; } -export const unmarshalEffectivePrivilegeSchema: z.ZodType = - z - .object({ - privilege: z.string().optional(), - inherited_from_type: z.string().optional(), - inherited_from_name: z.string().optional(), - }) - .transform(d => ({ - privilege: d.privilege, - inheritedFromType: d.inherited_from_type, - inheritedFromName: d.inherited_from_name, - })); - -export const unmarshalEffectivePrivilegeAssignmentSchema: z.ZodType = - z - .object({ - principal: z.string().optional(), - privileges: z - .array(z.lazy(() => unmarshalEffectivePrivilegeSchema)) - .optional(), - }) - .transform(d => ({ - principal: d.principal, - privileges: d.privileges, - })); - -export const unmarshalGetEffectivePermissionsSchema: z.ZodType = - z - .object({ - securable_type: z.string().optional(), - securable_full_name: z.string().optional(), - principal: z.string().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - securableFullName: d.securable_full_name, - principal: d.principal, - maxResults: d.max_results, - pageToken: d.page_token, - })); +export const unmarshalEffectivePrivilegeSchema: z.ZodType = z + .object({ + privilege: z.string().optional(), + inherited_from_type: z.string().optional(), + inherited_from_name: z.string().optional(), + }) + .transform(d => ({ + privilege: d.privilege, + inheritedFromType: d.inherited_from_type, + inheritedFromName: d.inherited_from_name, + })); + +export const unmarshalEffectivePrivilegeAssignmentSchema: z.ZodType = z + .object({ + principal: z.string().optional(), + privileges: z.array(z.lazy(() => unmarshalEffectivePrivilegeSchema)).optional(), + }) + .transform(d => ({ + principal: d.principal, + privileges: d.privileges, + })); + +export const unmarshalGetEffectivePermissionsSchema: z.ZodType = z + .object({ + securable_type: z.string().optional(), + securable_full_name: z.string().optional(), + principal: z.string().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + securableFullName: d.securable_full_name, + principal: d.principal, + maxResults: d.max_results, + pageToken: d.page_token, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetEffectivePermissions_ResponseSchema: z.ZodType = - z - .object({ - next_page_token: z.string().optional(), - privilege_assignments: z - .array(z.lazy(() => unmarshalEffectivePrivilegeAssignmentSchema)) - .optional(), - }) - .transform(d => ({ - nextPageToken: d.next_page_token, - privilegeAssignments: d.privilege_assignments, - })); +export const unmarshalGetEffectivePermissions_ResponseSchema: z.ZodType = z + .object({ + next_page_token: z.string().optional(), + privilege_assignments: z.array(z.lazy(() => unmarshalEffectivePrivilegeAssignmentSchema)).optional(), + }) + .transform(d => ({ + nextPageToken: d.next_page_token, + privilegeAssignments: d.privilege_assignments, + })); export const unmarshalGetPermissionsSchema: z.ZodType = z .object({ @@ -285,82 +277,71 @@ export const unmarshalGetPermissionsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetPermissions_ResponseSchema: z.ZodType = - z - .object({ - next_page_token: z.string().optional(), - privilege_assignments: z - .array(z.lazy(() => unmarshalPrivilegeAssignmentSchema)) - .optional(), - }) - .transform(d => ({ - nextPageToken: d.next_page_token, - privilegeAssignments: d.privilege_assignments, - })); - -export const unmarshalListEffectivePrivilegeAssignmentsRequestSchema: z.ZodType = - z - .object({ - securable_type: z.string().optional(), - full_name: z.string().optional(), - principal: z.string().optional(), - include_deleted_principals: z.boolean().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - fullName: d.full_name, - principal: d.principal, - includeDeletedPrincipals: d.include_deleted_principals, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListEffectivePrivilegeAssignmentsResponseSchema: z.ZodType = - z - .object({ - effective_privilege_assignments: z - .array(z.lazy(() => unmarshalEffectivePrivilegeAssignmentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - effectivePrivilegeAssignments: d.effective_privilege_assignments, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListPrivilegeAssignmentsRequestSchema: z.ZodType = - z - .object({ - securable_type: z.string().optional(), - full_name: z.string().optional(), - principal: z.string().optional(), - include_deleted_principals: z.boolean().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - fullName: d.full_name, - principal: d.principal, - includeDeletedPrincipals: d.include_deleted_principals, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListPrivilegeAssignmentsResponseSchema: z.ZodType = - z - .object({ - privilege_assignments: z - .array(z.lazy(() => unmarshalPrivilegeAssignmentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - privilegeAssignments: d.privilege_assignments, - nextPageToken: d.next_page_token, - })); +export const unmarshalGetPermissions_ResponseSchema: z.ZodType = z + .object({ + next_page_token: z.string().optional(), + privilege_assignments: z.array(z.lazy(() => unmarshalPrivilegeAssignmentSchema)).optional(), + }) + .transform(d => ({ + nextPageToken: d.next_page_token, + privilegeAssignments: d.privilege_assignments, + })); + +export const unmarshalListEffectivePrivilegeAssignmentsRequestSchema: z.ZodType = z + .object({ + securable_type: z.string().optional(), + full_name: z.string().optional(), + principal: z.string().optional(), + include_deleted_principals: z.boolean().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + fullName: d.full_name, + principal: d.principal, + includeDeletedPrincipals: d.include_deleted_principals, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListEffectivePrivilegeAssignmentsResponseSchema: z.ZodType = z + .object({ + effective_privilege_assignments: z.array(z.lazy(() => unmarshalEffectivePrivilegeAssignmentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + effectivePrivilegeAssignments: d.effective_privilege_assignments, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListPrivilegeAssignmentsRequestSchema: z.ZodType = z + .object({ + securable_type: z.string().optional(), + full_name: z.string().optional(), + principal: z.string().optional(), + include_deleted_principals: z.boolean().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + fullName: d.full_name, + principal: d.principal, + includeDeletedPrincipals: d.include_deleted_principals, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListPrivilegeAssignmentsResponseSchema: z.ZodType = z + .object({ + privilege_assignments: z.array(z.lazy(() => unmarshalPrivilegeAssignmentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + privilegeAssignments: d.privilege_assignments, + nextPageToken: d.next_page_token, + })); export const unmarshalPermissionsChangeSchema: z.ZodType = z .object({ @@ -376,18 +357,17 @@ export const unmarshalPermissionsChangeSchema: z.ZodType = z principalId: d.principal_id, })); -export const unmarshalPrivilegeAssignmentSchema: z.ZodType = - z - .object({ - principal: z.string().optional(), - privileges: z.array(z.string()).optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - principal: d.principal, - privileges: d.privileges, - principalId: d.principal_id, - })); +export const unmarshalPrivilegeAssignmentSchema: z.ZodType = z + .object({ + principal: z.string().optional(), + privileges: z.array(z.string()).optional(), + principal_id: z.number().optional(), + }) + .transform(d => ({ + principal: d.principal, + privileges: d.privileges, + principalId: d.principal_id, + })); export const unmarshalUpdatePermissionsSchema: z.ZodType = z .object({ @@ -402,16 +382,13 @@ export const unmarshalUpdatePermissionsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdatePermissions_ResponseSchema: z.ZodType = - z - .object({ - privilege_assignments: z - .array(z.lazy(() => unmarshalPrivilegeAssignmentSchema)) - .optional(), - }) - .transform(d => ({ - privilegeAssignments: d.privilege_assignments, - })); +export const unmarshalUpdatePermissions_ResponseSchema: z.ZodType = z + .object({ + privilege_assignments: z.array(z.lazy(() => unmarshalPrivilegeAssignmentSchema)).optional(), + }) + .transform(d => ({ + privilegeAssignments: d.privilege_assignments, + })); export const marshalEffectivePrivilegeSchema: z.ZodType = z .object({ @@ -428,9 +405,7 @@ export const marshalEffectivePrivilegeSchema: z.ZodType = z export const marshalEffectivePrivilegeAssignmentSchema: z.ZodType = z .object({ principal: z.string().optional(), - privileges: z - .array(z.lazy(() => marshalEffectivePrivilegeSchema)) - .optional(), + privileges: z.array(z.lazy(() => marshalEffectivePrivilegeSchema)).optional(), }) .transform(d => ({ principal: d.principal, @@ -457,9 +432,7 @@ export const marshalGetEffectivePermissionsSchema: z.ZodType = z export const marshalGetEffectivePermissions_ResponseSchema: z.ZodType = z .object({ nextPageToken: z.string().optional(), - privilegeAssignments: z - .array(z.lazy(() => marshalEffectivePrivilegeAssignmentSchema)) - .optional(), + privilegeAssignments: z.array(z.lazy(() => marshalEffectivePrivilegeAssignmentSchema)).optional(), }) .transform(d => ({ next_page_token: d.nextPageToken, @@ -488,46 +461,40 @@ export const marshalGetPermissionsSchema: z.ZodType = z export const marshalGetPermissions_ResponseSchema: z.ZodType = z .object({ nextPageToken: z.string().optional(), - privilegeAssignments: z - .array(z.lazy(() => marshalPrivilegeAssignmentSchema)) - .optional(), + privilegeAssignments: z.array(z.lazy(() => marshalPrivilegeAssignmentSchema)).optional(), }) .transform(d => ({ next_page_token: d.nextPageToken, privilege_assignments: d.privilegeAssignments, })); -export const marshalListEffectivePrivilegeAssignmentsRequestSchema: z.ZodType = - z - .object({ - securableType: z.string().optional(), - fullName: z.string().optional(), - principal: z.string().optional(), - includeDeletedPrincipals: z.boolean().optional(), - pageSize: z.number().optional(), - pageToken: z.string().optional(), - }) - .transform(d => ({ - securable_type: d.securableType, - full_name: d.fullName, - principal: d.principal, - include_deleted_principals: d.includeDeletedPrincipals, - page_size: d.pageSize, - page_token: d.pageToken, - })); - -export const marshalListEffectivePrivilegeAssignmentsResponseSchema: z.ZodType = - z - .object({ - effectivePrivilegeAssignments: z - .array(z.lazy(() => marshalEffectivePrivilegeAssignmentSchema)) - .optional(), - nextPageToken: z.string().optional(), - }) - .transform(d => ({ - effective_privilege_assignments: d.effectivePrivilegeAssignments, - next_page_token: d.nextPageToken, - })); +export const marshalListEffectivePrivilegeAssignmentsRequestSchema: z.ZodType = z + .object({ + securableType: z.string().optional(), + fullName: z.string().optional(), + principal: z.string().optional(), + includeDeletedPrincipals: z.boolean().optional(), + pageSize: z.number().optional(), + pageToken: z.string().optional(), + }) + .transform(d => ({ + securable_type: d.securableType, + full_name: d.fullName, + principal: d.principal, + include_deleted_principals: d.includeDeletedPrincipals, + page_size: d.pageSize, + page_token: d.pageToken, + })); + +export const marshalListEffectivePrivilegeAssignmentsResponseSchema: z.ZodType = z + .object({ + effectivePrivilegeAssignments: z.array(z.lazy(() => marshalEffectivePrivilegeAssignmentSchema)).optional(), + nextPageToken: z.string().optional(), + }) + .transform(d => ({ + effective_privilege_assignments: d.effectivePrivilegeAssignments, + next_page_token: d.nextPageToken, + })); export const marshalListPrivilegeAssignmentsRequestSchema: z.ZodType = z .object({ @@ -549,9 +516,7 @@ export const marshalListPrivilegeAssignmentsRequestSchema: z.ZodType = z export const marshalListPrivilegeAssignmentsResponseSchema: z.ZodType = z .object({ - privilegeAssignments: z - .array(z.lazy(() => marshalPrivilegeAssignmentSchema)) - .optional(), + privilegeAssignments: z.array(z.lazy(() => marshalPrivilegeAssignmentSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -600,9 +565,7 @@ export const marshalUpdatePermissionsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalUpdatePermissions_ResponseSchema: z.ZodType = z .object({ - privilegeAssignments: z - .array(z.lazy(() => marshalPrivilegeAssignmentSchema)) - .optional(), + privilegeAssignments: z.array(z.lazy(() => marshalPrivilegeAssignmentSchema)).optional(), }) .transform(d => ({ privilege_assignments: d.privilegeAssignments, diff --git a/packages/grants/src/v1/utils.ts b/packages/grants/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/grants/src/v1/utils.ts +++ b/packages/grants/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/grants/tsconfig.json b/packages/grants/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/grants/tsconfig.json +++ b/packages/grants/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/iam/package.json b/packages/iam/package.json index 187a821d..5b54b104 100644 --- a/packages/iam/package.json +++ b/packages/iam/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/iam/src/v2/client.ts b/packages/iam/src/v2/client.ts index a8981059..183c928e 100644 --- a/packages/iam/src/v2/client.ts +++ b/packages/iam/src/v2/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { AccountAccessIdentityRule, CreateAccountAccessIdentityRuleRequest, @@ -51,6 +46,7 @@ import type { GetWorkspaceAccessDetailRequest, GetWorkspaceAssignmentDetailProxyRequest, GetWorkspaceAssignmentDetailRequest, + GetWorkspaceIdentityDetailRequest, Group, ListAccountAccessIdentityRulesRequest, ListAccountAccessIdentityRulesResponse, @@ -93,9 +89,11 @@ import type { UpdateUserRequest, UpdateWorkspaceAssignmentDetailProxyRequest, UpdateWorkspaceAssignmentDetailRequest, + UpdateWorkspaceIdentityDetailRequest, User, WorkspaceAccessDetail, WorkspaceAssignmentDetail, + WorkspaceIdentityDetail, } from './model'; import { marshalAccountAccessIdentityRuleSchema, @@ -110,6 +108,7 @@ import { marshalServicePrincipalSchema, marshalUserSchema, marshalWorkspaceAssignmentDetailSchema, + marshalWorkspaceIdentityDetailSchema, unmarshalAccountAccessIdentityRuleSchema, unmarshalDirectGroupMemberSchema, unmarshalGroupSchema, @@ -128,6 +127,7 @@ import { unmarshalUserSchema, unmarshalWorkspaceAccessDetailSchema, unmarshalWorkspaceAssignmentDetailSchema, + unmarshalWorkspaceIdentityDetailSchema, } from './model'; export class Client { @@ -148,11 +148,7 @@ export class Client { * Creates a new account access identity rule for a given account. * This allows administrators to explicitly allow or deny specific principals from accessing the account. */ - async createAccountAccessIdentityRule( - signal: AbortSignal | undefined, - req: CreateAccountAccessIdentityRuleRequest, - options?: Options - ): Promise { + async createAccountAccessIdentityRule(signal: AbortSignal | undefined, req: CreateAccountAccessIdentityRuleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/${req.parent ?? ''}/account-access-identity-rules`; const params = new URLSearchParams(); if (req.externalPrincipalId !== undefined) { @@ -160,18 +156,11 @@ export class Client { } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.accountAccessIdentityRule, - marshalAccountAccessIdentityRuleSchema - ); + const body = marshalRequest(req.accountAccessIdentityRule, marshalAccountAccessIdentityRuleSchema); let resp: AccountAccessIdentityRule | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAccountAccessIdentityRuleSchema); }; await execute(signal, call, options); @@ -182,38 +171,22 @@ export class Client { } /** Deletes an account access identity rule for a given principal. */ - async deleteAccountAccessIdentityRule( - signal: AbortSignal | undefined, - req: DeleteAccountAccessIdentityRuleRequest, - options?: Options - ): Promise { + async deleteAccountAccessIdentityRule(signal: AbortSignal | undefined, req: DeleteAccountAccessIdentityRuleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/${req.parent ?? ''}/account-access-identity-rules/${req.externalPrincipalId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Gets an account access identity rule for a given principal. */ - async getAccountAccessIdentityRule( - signal: AbortSignal | undefined, - req: GetAccountAccessIdentityRuleRequest, - options?: Options - ): Promise { + async getAccountAccessIdentityRule(signal: AbortSignal | undefined, req: GetAccountAccessIdentityRuleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/${req.parent ?? ''}/account-access-identity-rules/${req.externalPrincipalId ?? ''}`; let resp: AccountAccessIdentityRule | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAccountAccessIdentityRuleSchema); }; await execute(signal, call, options); @@ -228,11 +201,7 @@ export class Client { * These rules control which principals (users, service principals, groups) from the customer's IdP * are allowed or denied access to the account. */ - async listAccountAccessIdentityRules( - signal: AbortSignal | undefined, - req: ListAccountAccessIdentityRulesRequest, - options?: Options - ): Promise { + async listAccountAccessIdentityRules(signal: AbortSignal | undefined, req: ListAccountAccessIdentityRulesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/${req.parent ?? ''}/account-access-identity-rules`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -249,15 +218,8 @@ export class Client { let resp: ListAccountAccessIdentityRulesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListAccountAccessIdentityRulesResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListAccountAccessIdentityRulesResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -267,11 +229,7 @@ export class Client { } /** Creates a group membership (assigns a principal to a group). */ - async createDirectGroupMember( - signal: AbortSignal | undefined, - req: CreateDirectGroupMemberRequest, - options?: Options - ): Promise { + async createDirectGroupMember(signal: AbortSignal | undefined, req: CreateDirectGroupMemberRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.groupId ?? '')}/direct-members`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -279,18 +237,11 @@ export class Client { } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.directGroupMember, - marshalDirectGroupMemberSchema - ); + const body = marshalRequest(req.directGroupMember, marshalDirectGroupMemberSchema); let resp: DirectGroupMember | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDirectGroupMemberSchema); }; await execute(signal, call, options); @@ -301,24 +252,13 @@ export class Client { } /** Creates a group membership (assigns a principal to a group). */ - async createDirectGroupMemberProxy( - signal: AbortSignal | undefined, - req: CreateDirectGroupMemberProxyRequest, - options?: Options - ): Promise { + async createDirectGroupMemberProxy(signal: AbortSignal | undefined, req: CreateDirectGroupMemberProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.groupId ?? '')}/direct-members`; - const body = marshalRequest( - req.directGroupMember, - marshalDirectGroupMemberSchema - ); + const body = marshalRequest(req.directGroupMember, marshalDirectGroupMemberSchema); let resp: DirectGroupMember | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDirectGroupMemberSchema); }; await execute(signal, call, options); @@ -329,11 +269,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async createGroup( - signal: AbortSignal | undefined, - req: CreateGroupRequest, - options?: Options - ): Promise { + async createGroup(signal: AbortSignal | undefined, req: CreateGroupRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/groups`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -345,11 +281,7 @@ export class Client { let resp: Group | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGroupSchema); }; await execute(signal, call, options); @@ -360,21 +292,13 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async createGroupProxy( - signal: AbortSignal | undefined, - req: CreateGroupProxyRequest, - options?: Options - ): Promise { + async createGroupProxy(signal: AbortSignal | undefined, req: CreateGroupProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups`; const body = marshalRequest(req.group, marshalGroupSchema); let resp: Group | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGroupSchema); }; await execute(signal, call, options); @@ -385,11 +309,7 @@ export class Client { } /** Deletes a group membership (unassigns a principal from a group). */ - async deleteDirectGroupMember( - signal: AbortSignal | undefined, - req: DeleteDirectGroupMemberRequest, - options?: Options - ): Promise { + async deleteDirectGroupMember(signal: AbortSignal | undefined, req: DeleteDirectGroupMemberRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.groupId ?? '')}/direct-members/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -399,39 +319,23 @@ export class Client { const fullUrl = query !== '' ? `${url}?${query}` : url; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Deletes a group membership (unassigns a principal from a group). */ - async deleteDirectGroupMemberProxy( - signal: AbortSignal | undefined, - req: DeleteDirectGroupMemberProxyRequest, - options?: Options - ): Promise { + async deleteDirectGroupMemberProxy(signal: AbortSignal | undefined, req: DeleteDirectGroupMemberProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.groupId ?? '')}/direct-members/${String(req.principalId ?? '')}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** TODO: Write description later when this method is implemented */ - async deleteGroup( - signal: AbortSignal | undefined, - req: DeleteGroupRequest, - options?: Options - ): Promise { + async deleteGroup(signal: AbortSignal | undefined, req: DeleteGroupRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -441,39 +345,23 @@ export class Client { const fullUrl = query !== '' ? `${url}?${query}` : url; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** TODO: Write description later when this method is implemented */ - async deleteGroupProxy( - signal: AbortSignal | undefined, - req: DeleteGroupProxyRequest, - options?: Options - ): Promise { + async deleteGroupProxy(signal: AbortSignal | undefined, req: DeleteGroupProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.internalId ?? '')}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Gets a provisioned direct member of a group. */ - async getDirectGroupMember( - signal: AbortSignal | undefined, - req: GetDirectGroupMemberRequest, - options?: Options - ): Promise { + async getDirectGroupMember(signal: AbortSignal | undefined, req: GetDirectGroupMemberRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.groupId ?? '')}/direct-members/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -484,11 +372,7 @@ export class Client { let resp: DirectGroupMember | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDirectGroupMemberSchema); }; await execute(signal, call, options); @@ -499,20 +383,12 @@ export class Client { } /** Gets a provisioned direct member of a group. */ - async getDirectGroupMemberProxy( - signal: AbortSignal | undefined, - req: GetDirectGroupMemberProxyRequest, - options?: Options - ): Promise { + async getDirectGroupMemberProxy(signal: AbortSignal | undefined, req: GetDirectGroupMemberProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.groupId ?? '')}/direct-members/${String(req.principalId ?? '')}`; let resp: DirectGroupMember | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDirectGroupMemberSchema); }; await execute(signal, call, options); @@ -523,11 +399,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async getGroup( - signal: AbortSignal | undefined, - req: GetGroupRequest, - options?: Options - ): Promise { + async getGroup(signal: AbortSignal | undefined, req: GetGroupRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -538,11 +410,7 @@ export class Client { let resp: Group | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGroupSchema); }; await execute(signal, call, options); @@ -553,20 +421,12 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async getGroupProxy( - signal: AbortSignal | undefined, - req: GetGroupProxyRequest, - options?: Options - ): Promise { + async getGroupProxy(signal: AbortSignal | undefined, req: GetGroupProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.internalId ?? '')}`; let resp: Group | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGroupSchema); }; await execute(signal, call, options); @@ -577,11 +437,7 @@ export class Client { } /** Lists provisioned direct members of a group with their membership source (internal or from identity provider). */ - async listDirectGroupMembers( - signal: AbortSignal | undefined, - req: ListDirectGroupMembersRequest, - options?: Options - ): Promise { + async listDirectGroupMembers(signal: AbortSignal | undefined, req: ListDirectGroupMembersRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.groupId ?? '')}/direct-members`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -598,15 +454,8 @@ export class Client { let resp: ListDirectGroupMembersResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListDirectGroupMembersResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListDirectGroupMembersResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -616,11 +465,7 @@ export class Client { } /** Lists provisioned direct members of a group with their membership source (internal or from identity provider). */ - async listDirectGroupMembersProxy( - signal: AbortSignal | undefined, - req: ListDirectGroupMembersProxyRequest, - options?: Options - ): Promise { + async listDirectGroupMembersProxy(signal: AbortSignal | undefined, req: ListDirectGroupMembersProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.groupId ?? '')}/direct-members`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -634,15 +479,8 @@ export class Client { let resp: ListDirectGroupMembersResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListDirectGroupMembersResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListDirectGroupMembersResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -652,11 +490,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listGroups( - signal: AbortSignal | undefined, - req: ListGroupsRequest, - options?: Options - ): Promise { + async listGroups(signal: AbortSignal | undefined, req: ListGroupsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/groups`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -676,11 +510,7 @@ export class Client { let resp: ListGroupsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListGroupsResponseSchema); }; await execute(signal, call, options); @@ -691,11 +521,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listGroupsProxy( - signal: AbortSignal | undefined, - req: ListGroupsProxyRequest, - options?: Options - ): Promise { + async listGroupsProxy(signal: AbortSignal | undefined, req: ListGroupsProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -712,11 +538,7 @@ export class Client { let resp: ListGroupsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListGroupsResponseSchema); }; await execute(signal, call, options); @@ -727,11 +549,7 @@ export class Client { } /** Lists all transitive parent groups of a principal. */ - async listTransitiveParentGroups( - signal: AbortSignal | undefined, - req: ListTransitiveParentGroupsRequest, - options?: Options - ): Promise { + async listTransitiveParentGroups(signal: AbortSignal | undefined, req: ListTransitiveParentGroupsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//principals/${String(req.principalId ?? '')}/transitive-parent-groups`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -748,15 +566,8 @@ export class Client { let resp: ListTransitiveParentGroupsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListTransitiveParentGroupsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListTransitiveParentGroupsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -766,11 +577,7 @@ export class Client { } /** Lists all transitive parent groups of a principal. */ - async listTransitiveParentGroupsProxy( - signal: AbortSignal | undefined, - req: ListTransitiveParentGroupsProxyRequest, - options?: Options - ): Promise { + async listTransitiveParentGroupsProxy(signal: AbortSignal | undefined, req: ListTransitiveParentGroupsProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/principals/${String(req.principalId ?? '')}/transitive-parent-groups`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -784,15 +591,8 @@ export class Client { let resp: ListTransitiveParentGroupsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListTransitiveParentGroupsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListTransitiveParentGroupsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -805,21 +605,13 @@ export class Client { * Resolves a group with the given external ID from the customer's IdP. If the group does not exist, it will be created in the account. * If the customer is not onboarded onto Automatic Identity Management (AIM), this will return an error. */ - async resolveGroup( - signal: AbortSignal | undefined, - req: ResolveGroupRequest, - options?: Options - ): Promise { + async resolveGroup(signal: AbortSignal | undefined, req: ResolveGroupRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/groups/resolveByExternalId`; const body = marshalRequest(req, marshalResolveGroupRequestSchema); let resp: ResolveGroupResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalResolveGroupResponseSchema); }; await execute(signal, call, options); @@ -833,21 +625,13 @@ export class Client { * Resolves a group with the given external ID from the customer's IdP. If the group does not exist, it will be created in the account. * If the customer is not onboarded onto Automatic Identity Management (AIM), this will return an error. */ - async resolveGroupProxy( - signal: AbortSignal | undefined, - req: ResolveGroupProxyRequest, - options?: Options - ): Promise { + async resolveGroupProxy(signal: AbortSignal | undefined, req: ResolveGroupProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/resolveByExternalId`; const body = marshalRequest(req, marshalResolveGroupProxyRequestSchema); let resp: ResolveGroupResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalResolveGroupResponseSchema); }; await execute(signal, call, options); @@ -858,18 +642,14 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async updateGroup( - signal: AbortSignal | undefined, - req: UpdateGroupRequest, - options?: Options - ): Promise { + async updateGroup(signal: AbortSignal | undefined, req: UpdateGroupRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//groups/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { params.append('account_id', req.accountId); } if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -877,11 +657,7 @@ export class Client { let resp: Group | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGroupSchema); }; await execute(signal, call, options); @@ -892,15 +668,11 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async updateGroupProxy( - signal: AbortSignal | undefined, - req: UpdateGroupProxyRequest, - options?: Options - ): Promise { + async updateGroupProxy(signal: AbortSignal | undefined, req: UpdateGroupProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/groups/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -908,11 +680,7 @@ export class Client { let resp: Group | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGroupSchema); }; await execute(signal, call, options); @@ -923,11 +691,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async createServicePrincipal( - signal: AbortSignal | undefined, - req: CreateServicePrincipalRequest, - options?: Options - ): Promise { + async createServicePrincipal(signal: AbortSignal | undefined, req: CreateServicePrincipalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/servicePrincipals`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -935,18 +699,11 @@ export class Client { } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.servicePrincipal, - marshalServicePrincipalSchema - ); + const body = marshalRequest(req.servicePrincipal, marshalServicePrincipalSchema); let resp: ServicePrincipal | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalServicePrincipalSchema); }; await execute(signal, call, options); @@ -957,24 +714,13 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async createServicePrincipalProxy( - signal: AbortSignal | undefined, - req: CreateServicePrincipalProxyRequest, - options?: Options - ): Promise { + async createServicePrincipalProxy(signal: AbortSignal | undefined, req: CreateServicePrincipalProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/servicePrincipals`; - const body = marshalRequest( - req.servicePrincipal, - marshalServicePrincipalSchema - ); + const body = marshalRequest(req.servicePrincipal, marshalServicePrincipalSchema); let resp: ServicePrincipal | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalServicePrincipalSchema); }; await execute(signal, call, options); @@ -985,11 +731,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async deleteServicePrincipal( - signal: AbortSignal | undefined, - req: DeleteServicePrincipalRequest, - options?: Options - ): Promise { + async deleteServicePrincipal(signal: AbortSignal | undefined, req: DeleteServicePrincipalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//servicePrincipals/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -999,39 +741,23 @@ export class Client { const fullUrl = query !== '' ? `${url}?${query}` : url; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** TODO: Write description later when this method is implemented */ - async deleteServicePrincipalProxy( - signal: AbortSignal | undefined, - req: DeleteServicePrincipalProxyRequest, - options?: Options - ): Promise { + async deleteServicePrincipalProxy(signal: AbortSignal | undefined, req: DeleteServicePrincipalProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/servicePrincipals/${String(req.internalId ?? '')}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** TODO: Write description later when this method is implemented */ - async getServicePrincipal( - signal: AbortSignal | undefined, - req: GetServicePrincipalRequest, - options?: Options - ): Promise { + async getServicePrincipal(signal: AbortSignal | undefined, req: GetServicePrincipalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//servicePrincipals/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1042,11 +768,7 @@ export class Client { let resp: ServicePrincipal | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalServicePrincipalSchema); }; await execute(signal, call, options); @@ -1057,20 +779,12 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async getServicePrincipalProxy( - signal: AbortSignal | undefined, - req: GetServicePrincipalProxyRequest, - options?: Options - ): Promise { + async getServicePrincipalProxy(signal: AbortSignal | undefined, req: GetServicePrincipalProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/servicePrincipals/${String(req.internalId ?? '')}`; let resp: ServicePrincipal | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalServicePrincipalSchema); }; await execute(signal, call, options); @@ -1081,11 +795,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listServicePrincipals( - signal: AbortSignal | undefined, - req: ListServicePrincipalsRequest, - options?: Options - ): Promise { + async listServicePrincipals(signal: AbortSignal | undefined, req: ListServicePrincipalsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/servicePrincipals`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1105,15 +815,8 @@ export class Client { let resp: ListServicePrincipalsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListServicePrincipalsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListServicePrincipalsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1123,11 +826,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listServicePrincipalsProxy( - signal: AbortSignal | undefined, - req: ListServicePrincipalsProxyRequest, - options?: Options - ): Promise { + async listServicePrincipalsProxy(signal: AbortSignal | undefined, req: ListServicePrincipalsProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/servicePrincipals`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -1144,15 +843,8 @@ export class Client { let resp: ListServicePrincipalsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListServicePrincipalsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListServicePrincipalsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1165,28 +857,14 @@ export class Client { * Resolves an SP with the given external ID from the customer's IdP. If the SP does not exist, it will be created. * If the customer is not onboarded onto Automatic Identity Management (AIM), this will return an error. */ - async resolveServicePrincipal( - signal: AbortSignal | undefined, - req: ResolveServicePrincipalRequest, - options?: Options - ): Promise { + async resolveServicePrincipal(signal: AbortSignal | undefined, req: ResolveServicePrincipalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/servicePrincipals/resolveByExternalId`; - const body = marshalRequest( - req, - marshalResolveServicePrincipalRequestSchema - ); + const body = marshalRequest(req, marshalResolveServicePrincipalRequestSchema); let resp: ResolveServicePrincipalResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalResolveServicePrincipalResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalResolveServicePrincipalResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1199,28 +877,14 @@ export class Client { * Resolves an SP with the given external ID from the customer's IdP. If the SP does not exist, it will be created. * If the customer is not onboarded onto Automatic Identity Management (AIM), this will return an error. */ - async resolveServicePrincipalProxy( - signal: AbortSignal | undefined, - req: ResolveServicePrincipalProxyRequest, - options?: Options - ): Promise { + async resolveServicePrincipalProxy(signal: AbortSignal | undefined, req: ResolveServicePrincipalProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/servicePrincipals/resolveByExternalId`; - const body = marshalRequest( - req, - marshalResolveServicePrincipalProxyRequestSchema - ); + const body = marshalRequest(req, marshalResolveServicePrincipalProxyRequestSchema); let resp: ResolveServicePrincipalResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalResolveServicePrincipalResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalResolveServicePrincipalResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1230,33 +894,22 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async updateServicePrincipal( - signal: AbortSignal | undefined, - req: UpdateServicePrincipalRequest, - options?: Options - ): Promise { + async updateServicePrincipal(signal: AbortSignal | undefined, req: UpdateServicePrincipalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//servicePrincipals/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { params.append('account_id', req.accountId); } if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.servicePrincipal, - marshalServicePrincipalSchema - ); + const body = marshalRequest(req.servicePrincipal, marshalServicePrincipalSchema); let resp: ServicePrincipal | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalServicePrincipalSchema); }; await execute(signal, call, options); @@ -1267,30 +920,19 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async updateServicePrincipalProxy( - signal: AbortSignal | undefined, - req: UpdateServicePrincipalProxyRequest, - options?: Options - ): Promise { + async updateServicePrincipalProxy(signal: AbortSignal | undefined, req: UpdateServicePrincipalProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/servicePrincipals/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.servicePrincipal, - marshalServicePrincipalSchema - ); + const body = marshalRequest(req.servicePrincipal, marshalServicePrincipalSchema); let resp: ServicePrincipal | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalServicePrincipalSchema); }; await execute(signal, call, options); @@ -1301,11 +943,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async createUser( - signal: AbortSignal | undefined, - req: CreateUserRequest, - options?: Options - ): Promise { + async createUser(signal: AbortSignal | undefined, req: CreateUserRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/users`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1317,11 +955,7 @@ export class Client { let resp: User | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserSchema); }; await execute(signal, call, options); @@ -1332,21 +966,13 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async createUserProxy( - signal: AbortSignal | undefined, - req: CreateUserProxyRequest, - options?: Options - ): Promise { + async createUserProxy(signal: AbortSignal | undefined, req: CreateUserProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/users`; const body = marshalRequest(req.user, marshalUserSchema); let resp: User | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserSchema); }; await execute(signal, call, options); @@ -1357,11 +983,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async deleteUser( - signal: AbortSignal | undefined, - req: DeleteUserRequest, - options?: Options - ): Promise { + async deleteUser(signal: AbortSignal | undefined, req: DeleteUserRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//users/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1371,39 +993,23 @@ export class Client { const fullUrl = query !== '' ? `${url}?${query}` : url; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** TODO: Write description later when this method is implemented */ - async deleteUserProxy( - signal: AbortSignal | undefined, - req: DeleteUserProxyRequest, - options?: Options - ): Promise { + async deleteUserProxy(signal: AbortSignal | undefined, req: DeleteUserProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/users/${String(req.internalId ?? '')}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** TODO: Write description later when this method is implemented */ - async getUser( - signal: AbortSignal | undefined, - req: GetUserRequest, - options?: Options - ): Promise { + async getUser(signal: AbortSignal | undefined, req: GetUserRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//users/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1414,11 +1020,7 @@ export class Client { let resp: User | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserSchema); }; await execute(signal, call, options); @@ -1429,20 +1031,12 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async getUserProxy( - signal: AbortSignal | undefined, - req: GetUserProxyRequest, - options?: Options - ): Promise { + async getUserProxy(signal: AbortSignal | undefined, req: GetUserProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/users/${String(req.internalId ?? '')}`; let resp: User | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserSchema); }; await execute(signal, call, options); @@ -1453,11 +1047,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listUsers( - signal: AbortSignal | undefined, - req: ListUsersRequest, - options?: Options - ): Promise { + async listUsers(signal: AbortSignal | undefined, req: ListUsersRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/users`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1477,11 +1067,7 @@ export class Client { let resp: ListUsersResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListUsersResponseSchema); }; await execute(signal, call, options); @@ -1492,11 +1078,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listUsersProxy( - signal: AbortSignal | undefined, - req: ListUsersProxyRequest, - options?: Options - ): Promise { + async listUsersProxy(signal: AbortSignal | undefined, req: ListUsersProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/users`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -1513,11 +1095,7 @@ export class Client { let resp: ListUsersResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListUsersResponseSchema); }; await execute(signal, call, options); @@ -1531,21 +1109,13 @@ export class Client { * Resolves a user with the given external ID from the customer's IdP. If the user does not exist, it will be created. * If the customer is not onboarded onto Automatic Identity Management (AIM), this will return an error. */ - async resolveUser( - signal: AbortSignal | undefined, - req: ResolveUserRequest, - options?: Options - ): Promise { + async resolveUser(signal: AbortSignal | undefined, req: ResolveUserRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts/{account_id}/users/resolveByExternalId`; const body = marshalRequest(req, marshalResolveUserRequestSchema); let resp: ResolveUserResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalResolveUserResponseSchema); }; await execute(signal, call, options); @@ -1559,21 +1129,13 @@ export class Client { * Resolves a user with the given external ID from the customer's IdP. If the user does not exist, it will be created. * If the customer is not onboarded onto Automatic Identity Management (AIM), this will return an error. */ - async resolveUserProxy( - signal: AbortSignal | undefined, - req: ResolveUserProxyRequest, - options?: Options - ): Promise { + async resolveUserProxy(signal: AbortSignal | undefined, req: ResolveUserProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/users/resolveByExternalId`; const body = marshalRequest(req, marshalResolveUserProxyRequestSchema); let resp: ResolveUserResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalResolveUserResponseSchema); }; await execute(signal, call, options); @@ -1584,18 +1146,14 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async updateUser( - signal: AbortSignal | undefined, - req: UpdateUserRequest, - options?: Options - ): Promise { + async updateUser(signal: AbortSignal | undefined, req: UpdateUserRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//users/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { params.append('account_id', req.accountId); } if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1603,11 +1161,7 @@ export class Client { let resp: User | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserSchema); }; await execute(signal, call, options); @@ -1618,15 +1172,11 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async updateUserProxy( - signal: AbortSignal | undefined, - req: UpdateUserProxyRequest, - options?: Options - ): Promise { + async updateUserProxy(signal: AbortSignal | undefined, req: UpdateUserProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/users/${String(req.internalId ?? '')}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1634,11 +1184,7 @@ export class Client { let resp: User | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserSchema); }; await execute(signal, call, options); @@ -1655,11 +1201,7 @@ export class Client { * added explicitly to via SCIM/UI. * Allows for passing in a "view" parameter to control what fields are returned (BASIC by default or FULL). */ - async getWorkspaceAccessDetail( - signal: AbortSignal | undefined, - req: GetWorkspaceAccessDetailRequest, - options?: Options - ): Promise { + async getWorkspaceAccessDetail(signal: AbortSignal | undefined, req: GetWorkspaceAccessDetailRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAccessDetails/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1673,11 +1215,7 @@ export class Client { let resp: WorkspaceAccessDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAccessDetailSchema); }; await execute(signal, call, options); @@ -1694,11 +1232,7 @@ export class Client { * added explicitly to via SCIM/UI. * Allows for passing in a "view" parameter to control what fields are returned (BASIC by default or FULL). */ - async getWorkspaceAccessDetailLocal( - signal: AbortSignal | undefined, - req: GetWorkspaceAccessDetailLocalRequest, - options?: Options - ): Promise { + async getWorkspaceAccessDetailLocal(signal: AbortSignal | undefined, req: GetWorkspaceAccessDetailLocalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAccessDetails/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.view !== undefined) { @@ -1709,11 +1243,7 @@ export class Client { let resp: WorkspaceAccessDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAccessDetailSchema); }; await execute(signal, call, options); @@ -1724,11 +1254,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listWorkspaceAccessDetails( - signal: AbortSignal | undefined, - req: ListWorkspaceAccessDetailsRequest, - options?: Options - ): Promise { + async listWorkspaceAccessDetails(signal: AbortSignal | undefined, req: ListWorkspaceAccessDetailsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAccessDetails`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1745,15 +1271,8 @@ export class Client { let resp: ListWorkspaceAccessDetailsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWorkspaceAccessDetailsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspaceAccessDetailsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1763,11 +1282,7 @@ export class Client { } /** TODO: Write description later when this method is implemented */ - async listWorkspaceAccessDetailsLocal( - signal: AbortSignal | undefined, - req: ListWorkspaceAccessDetailsLocalRequest, - options?: Options - ): Promise { + async listWorkspaceAccessDetailsLocal(signal: AbortSignal | undefined, req: ListWorkspaceAccessDetailsLocalRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAccessDetails`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -1781,15 +1296,8 @@ export class Client { let resp: ListWorkspaceAccessDetailsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWorkspaceAccessDetailsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspaceAccessDetailsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1804,11 +1312,7 @@ export class Client { * assigned to the workspace but with only a subset of the requested entitlements. Use * GetWorkspaceAssignmentDetail to confirm which entitlements were successfully granted. */ - async createWorkspaceAssignmentDetail( - signal: AbortSignal | undefined, - req: CreateWorkspaceAssignmentDetailRequest, - options?: Options - ): Promise { + async createWorkspaceAssignmentDetail(signal: AbortSignal | undefined, req: CreateWorkspaceAssignmentDetailRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAssignmentDetails`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1816,18 +1320,11 @@ export class Client { } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.workspaceAssignmentDetail, - marshalWorkspaceAssignmentDetailSchema - ); + const body = marshalRequest(req.workspaceAssignmentDetail, marshalWorkspaceAssignmentDetailSchema); let resp: WorkspaceAssignmentDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAssignmentDetailSchema); }; await execute(signal, call, options); @@ -1844,24 +1341,13 @@ export class Client { * entitlements. Use GetWorkspaceAssignmentDetail to confirm which entitlements were successfully * granted. */ - async createWorkspaceAssignmentDetailProxy( - signal: AbortSignal | undefined, - req: CreateWorkspaceAssignmentDetailProxyRequest, - options?: Options - ): Promise { + async createWorkspaceAssignmentDetailProxy(signal: AbortSignal | undefined, req: CreateWorkspaceAssignmentDetailProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAssignmentDetails`; - const body = marshalRequest( - req.workspaceAssignmentDetail, - marshalWorkspaceAssignmentDetailSchema - ); + const body = marshalRequest(req.workspaceAssignmentDetail, marshalWorkspaceAssignmentDetailSchema); let resp: WorkspaceAssignmentDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAssignmentDetailSchema); }; await execute(signal, call, options); @@ -1877,11 +1363,7 @@ export class Client { * partway through, the principal remains assigned with a subset of its original entitlements, * and the operation is safe to retry. */ - async deleteWorkspaceAssignmentDetail( - signal: AbortSignal | undefined, - req: DeleteWorkspaceAssignmentDetailRequest, - options?: Options - ): Promise { + async deleteWorkspaceAssignmentDetail(signal: AbortSignal | undefined, req: DeleteWorkspaceAssignmentDetailRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAssignmentDetails/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1891,11 +1373,7 @@ export class Client { const fullUrl = query !== '' ? `${url}?${query}` : url; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } @@ -1906,29 +1384,17 @@ export class Client { * — if a failure occurs partway through, the principal remains assigned with a subset of its * original entitlements, and the operation is safe to retry. */ - async deleteWorkspaceAssignmentDetailProxy( - signal: AbortSignal | undefined, - req: DeleteWorkspaceAssignmentDetailProxyRequest, - options?: Options - ): Promise { + async deleteWorkspaceAssignmentDetailProxy(signal: AbortSignal | undefined, req: DeleteWorkspaceAssignmentDetailProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAssignmentDetails/${String(req.principalId ?? '')}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Returns the assignment details for a principal in a workspace. */ - async getWorkspaceAssignmentDetail( - signal: AbortSignal | undefined, - req: GetWorkspaceAssignmentDetailRequest, - options?: Options - ): Promise { + async getWorkspaceAssignmentDetail(signal: AbortSignal | undefined, req: GetWorkspaceAssignmentDetailRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAssignmentDetails/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1939,11 +1405,7 @@ export class Client { let resp: WorkspaceAssignmentDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAssignmentDetailSchema); }; await execute(signal, call, options); @@ -1954,20 +1416,12 @@ export class Client { } /** Returns the assignment details for a principal in a workspace (workspace-level proxy). */ - async getWorkspaceAssignmentDetailProxy( - signal: AbortSignal | undefined, - req: GetWorkspaceAssignmentDetailProxyRequest, - options?: Options - ): Promise { + async getWorkspaceAssignmentDetailProxy(signal: AbortSignal | undefined, req: GetWorkspaceAssignmentDetailProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAssignmentDetails/${String(req.principalId ?? '')}`; let resp: WorkspaceAssignmentDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAssignmentDetailSchema); }; await execute(signal, call, options); @@ -1978,11 +1432,7 @@ export class Client { } /** Lists workspace assignment details for a workspace. */ - async listWorkspaceAssignmentDetails( - signal: AbortSignal | undefined, - req: ListWorkspaceAssignmentDetailsRequest, - options?: Options - ): Promise { + async listWorkspaceAssignmentDetails(signal: AbortSignal | undefined, req: ListWorkspaceAssignmentDetailsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAssignmentDetails`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -1999,15 +1449,8 @@ export class Client { let resp: ListWorkspaceAssignmentDetailsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWorkspaceAssignmentDetailsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspaceAssignmentDetailsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -2017,11 +1460,7 @@ export class Client { } /** Lists workspace assignment details for a workspace (workspace-level proxy). */ - async listWorkspaceAssignmentDetailsProxy( - signal: AbortSignal | undefined, - req: ListWorkspaceAssignmentDetailsProxyRequest, - options?: Options - ): Promise { + async listWorkspaceAssignmentDetailsProxy(signal: AbortSignal | undefined, req: ListWorkspaceAssignmentDetailsProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAssignmentDetails`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -2035,15 +1474,8 @@ export class Client { let resp: ListWorkspaceAssignmentDetailsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWorkspaceAssignmentDetailsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspaceAssignmentDetailsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -2058,33 +1490,22 @@ export class Client { * subset of the requested changes may have been applied. Use GetWorkspaceAssignmentDetail to * confirm the final state. */ - async updateWorkspaceAssignmentDetail( - signal: AbortSignal | undefined, - req: UpdateWorkspaceAssignmentDetailRequest, - options?: Options - ): Promise { + async updateWorkspaceAssignmentDetail(signal: AbortSignal | undefined, req: UpdateWorkspaceAssignmentDetailRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/accounts//workspaces/${String(req.workspaceId ?? '')}/workspaceAssignmentDetails/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { params.append('account_id', req.accountId); } if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.workspaceAssignmentDetail, - marshalWorkspaceAssignmentDetailSchema - ); + const body = marshalRequest(req.workspaceAssignmentDetail, marshalWorkspaceAssignmentDetailSchema); let resp: WorkspaceAssignmentDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAssignmentDetailSchema); }; await execute(signal, call, options); @@ -2100,30 +1521,19 @@ export class Client { * partway through, only a subset of the requested changes may have been applied. Use * GetWorkspaceAssignmentDetail to confirm the final state. */ - async updateWorkspaceAssignmentDetailProxy( - signal: AbortSignal | undefined, - req: UpdateWorkspaceAssignmentDetailProxyRequest, - options?: Options - ): Promise { + async updateWorkspaceAssignmentDetailProxy(signal: AbortSignal | undefined, req: UpdateWorkspaceAssignmentDetailProxyRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/identity/workspaceAssignmentDetails/${String(req.principalId ?? '')}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.workspaceAssignmentDetail, - marshalWorkspaceAssignmentDetailSchema - ); + const body = marshalRequest(req.workspaceAssignmentDetail, marshalWorkspaceAssignmentDetailSchema); let resp: WorkspaceAssignmentDetail | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceAssignmentDetailSchema); }; await execute(signal, call, options); @@ -2132,4 +1542,43 @@ export class Client { } return resp; } + + /** Returns the identity details for a principal in a workspace. */ + async getWorkspaceIdentityDetail(signal: AbortSignal | undefined, req: GetWorkspaceIdentityDetailRequest, options?: Options): Promise { + const url = `${this.host}/api/2.0/identity/workspaceIdentityDetails/${String(req.principalId ?? '')}`; + let resp: WorkspaceIdentityDetail | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalWorkspaceIdentityDetailSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Updates a workspace identity detail for a principal. */ + async updateWorkspaceIdentityDetail(signal: AbortSignal | undefined, req: UpdateWorkspaceIdentityDetailRequest, options?: Options): Promise { + const url = `${this.host}/api/2.0/identity/workspaceIdentityDetails/${String(req.principalId ?? '')}`; + const params = new URLSearchParams(); + if (req.updateMask !== undefined) { + params.append('update_mask', req.updateMask.paths.join(',')); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + const body = marshalRequest(req.workspaceIdentityDetail, marshalWorkspaceIdentityDetailSchema); + let resp: WorkspaceIdentityDetail | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalWorkspaceIdentityDetailSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } } diff --git a/packages/iam/src/v2/index.ts b/packages/iam/src/v2/index.ts index b1601204..0b8d7648 100644 --- a/packages/iam/src/v2/index.ts +++ b/packages/iam/src/v2/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { @@ -11,6 +12,7 @@ export { WorkspaceAccessDetailView, WorkspacePermission, WorkspaceAccessDetail_AccessType, + WorkspaceIdentityDetail_AssignmentType, } from './model'; export type { @@ -51,6 +53,7 @@ export type { GetWorkspaceAccessDetailRequest, GetWorkspaceAssignmentDetailProxyRequest, GetWorkspaceAssignmentDetailRequest, + GetWorkspaceIdentityDetailRequest, Group, ListAccountAccessIdentityRulesRequest, ListAccountAccessIdentityRulesResponse, @@ -94,8 +97,10 @@ export type { UpdateUserRequest, UpdateWorkspaceAssignmentDetailProxyRequest, UpdateWorkspaceAssignmentDetailRequest, + UpdateWorkspaceIdentityDetailRequest, User, User_Name, WorkspaceAccessDetail, WorkspaceAssignmentDetail, + WorkspaceIdentityDetail, } from './model'; diff --git a/packages/iam/src/v2/model.ts b/packages/iam/src/v2/model.ts index 387341de..20e687e2 100644 --- a/packages/iam/src/v2/model.ts +++ b/packages/iam/src/v2/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** The action type for an account access identity rule (currently DENY only). */ @@ -71,6 +72,17 @@ export enum WorkspaceAccessDetail_AccessType { INDIRECT = 'INDIRECT', } +/** The type of assignment the principal has to the workspace. */ +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested enum name. +export enum WorkspaceIdentityDetail_AssignmentType { + /** Unknown assignment to the workspace. */ + ASSIGNMENT_TYPE_UNSPECIFIED = 'ASSIGNMENT_TYPE_UNSPECIFIED', + /** Direct assignment to the workspace, meaning the principal is provisioned and directly assigned to the workspace. */ + DIRECT = 'DIRECT', + /** Indirect assignment to the workspace, meaning the principal is provisioned and assigned to a group that has access to the workspace. */ + INDIRECT = 'INDIRECT', +} + /** An identity rule that controls which principals can access an account. */ export interface AccountAccessIdentityRule { /** Currently, only DENY action is supported. */ @@ -430,6 +442,12 @@ export interface GetWorkspaceAssignmentDetailRequest { principalId?: number | undefined; } +/** Request message for getting the workspace identity details for a principal in a workspace. */ +export interface GetWorkspaceIdentityDetailRequest { + /** Required. The internal ID of the principal (user/sp/group) for which the identity details are being requested. */ + principalId?: number | undefined; +} + /** The details of a Group resource. */ export interface Group { /** The parent account ID for group in . */ @@ -816,7 +834,7 @@ export interface UpdateGroupProxyRequest { /** Required. Group to be updated in */ group?: Group | undefined; /** Optional. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** TODO: Write description later when this method is implemented */ @@ -828,7 +846,7 @@ export interface UpdateGroupRequest { /** Required. Group to be updated in */ group?: Group | undefined; /** Optional. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** TODO: Write description later when this method is implemented */ @@ -838,7 +856,7 @@ export interface UpdateServicePrincipalProxyRequest { /** Required. Service principal to be updated in */ servicePrincipal?: ServicePrincipal | undefined; /** Optional. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** TODO: Write description later when this method is implemented */ @@ -850,7 +868,7 @@ export interface UpdateServicePrincipalRequest { /** Required. Service Principal to be updated in */ servicePrincipal?: ServicePrincipal | undefined; /** Optional. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** @@ -867,7 +885,7 @@ export interface UpdateUserProxyRequest { /** Required. User to be updated in */ user?: User | undefined; /** Optional. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** @@ -886,7 +904,7 @@ export interface UpdateUserRequest { /** Required. User to be updated in */ user?: User | undefined; /** Optional. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** Proxy request for updating a workspace assignment detail for a principal. */ @@ -896,7 +914,7 @@ export interface UpdateWorkspaceAssignmentDetailProxyRequest { /** Required. Workspace assignment detail to be updated in . */ workspaceAssignmentDetail?: WorkspaceAssignmentDetail | undefined; /** Required. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } /** TBD since the only updatable field is permissions */ @@ -910,7 +928,17 @@ export interface UpdateWorkspaceAssignmentDetailRequest { /** Required. Workspace assignment detail to be updated in . */ workspaceAssignmentDetail?: WorkspaceAssignmentDetail | undefined; /** Required. The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; +} + +/** Request message for updating the workspace identity details for a principal in a workspace. */ +export interface UpdateWorkspaceIdentityDetailRequest { + /** Required. ID of the principal in . */ + principalId?: number | undefined; + /** Required. Workspace identity detail to be updated in . */ + workspaceIdentityDetail?: WorkspaceIdentityDetail | undefined; + /** Required. The list of fields to update. */ + updateMask?: FieldMask> | undefined; } /** The details of a User resource. */ @@ -962,1148 +990,1085 @@ export interface WorkspaceAssignmentDetail { entitlements?: Entitlement[] | undefined; } -export const unmarshalAccountAccessIdentityRuleSchema: z.ZodType = - z - .object({ - action: z.enum(AccountAccessRuleAction).optional(), - external_principal_id: z.string().optional(), - display_name: z.string().optional(), - principal_type: z.enum(PrincipalType).optional(), - name: z.string().optional(), - }) - .transform(d => ({ - action: d.action, - externalPrincipalId: d.external_principal_id, - displayName: d.display_name, - principalType: d.principal_type, - name: d.name, - })); - -export const unmarshalCreateAccountAccessIdentityRuleRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - external_principal_id: z.string().optional(), - account_access_identity_rule: z - .lazy(() => unmarshalAccountAccessIdentityRuleSchema) - .optional(), - }) - .transform(d => ({ - parent: d.parent, - externalPrincipalId: d.external_principal_id, - accountAccessIdentityRule: d.account_access_identity_rule, - })); - -export const unmarshalCreateDirectGroupMemberProxyRequestSchema: z.ZodType = - z - .object({ - group_id: z.number().optional(), - direct_group_member: z - .lazy(() => unmarshalDirectGroupMemberSchema) - .optional(), - }) - .transform(d => ({ - groupId: d.group_id, - directGroupMember: d.direct_group_member, - })); - -export const unmarshalCreateDirectGroupMemberRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - group_id: z.number().optional(), - direct_group_member: z - .lazy(() => unmarshalDirectGroupMemberSchema) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - groupId: d.group_id, - directGroupMember: d.direct_group_member, - })); - -export const unmarshalCreateGroupProxyRequestSchema: z.ZodType = - z - .object({ - group: z.lazy(() => unmarshalGroupSchema).optional(), - }) - .transform(d => ({ - group: d.group, - })); - -export const unmarshalCreateGroupRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - group: z.lazy(() => unmarshalGroupSchema).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - group: d.group, - })); - -export const unmarshalCreateServicePrincipalProxyRequestSchema: z.ZodType = - z - .object({ - service_principal: z - .lazy(() => unmarshalServicePrincipalSchema) - .optional(), - }) - .transform(d => ({ - servicePrincipal: d.service_principal, - })); - -export const unmarshalCreateServicePrincipalRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z - .lazy(() => unmarshalServicePrincipalSchema) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - })); - -export const unmarshalCreateUserProxyRequestSchema: z.ZodType = - z - .object({ - user: z.lazy(() => unmarshalUserSchema).optional(), - }) - .transform(d => ({ - user: d.user, - })); +/** The details of a directly or indirectly assigned principal's details in a workspace. */ +export interface WorkspaceIdentityDetail { + /** The internal ID of the principal (user/sp/group) in . */ + principalId?: number | undefined; + /** The type of the principal (user/service principal/group). */ + principalType?: PrincipalType | undefined; + /** The activity status of an identity in a workspace. */ + workspaceIdentityStatus?: State | undefined; + /** The type of assignment the principal has to the workspace (direct or indirect). */ + assignmentType?: WorkspaceIdentityDetail_AssignmentType | undefined; +} -export const unmarshalCreateUserRequestSchema: z.ZodType = z +export const unmarshalAccountAccessIdentityRuleSchema: z.ZodType = z .object({ - account_id: z.string().optional(), - user: z.lazy(() => unmarshalUserSchema).optional(), + action: z.enum(AccountAccessRuleAction).optional(), + external_principal_id: z.string().optional(), + display_name: z.string().optional(), + principal_type: z.enum(PrincipalType).optional(), + name: z.string().optional(), }) .transform(d => ({ - accountId: d.account_id, - user: d.user, + action: d.action, + externalPrincipalId: d.external_principal_id, + displayName: d.display_name, + principalType: d.principal_type, + name: d.name, + })); + +export const unmarshalCreateAccountAccessIdentityRuleRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + external_principal_id: z.string().optional(), + account_access_identity_rule: z.lazy(() => unmarshalAccountAccessIdentityRuleSchema).optional(), + }) + .transform(d => ({ + parent: d.parent, + externalPrincipalId: d.external_principal_id, + accountAccessIdentityRule: d.account_access_identity_rule, })); -export const unmarshalCreateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - workspace_assignment_detail: z - .lazy(() => unmarshalWorkspaceAssignmentDetailSchema) - .optional(), - }) - .transform(d => ({ - workspaceAssignmentDetail: d.workspace_assignment_detail, - })); - -export const unmarshalCreateWorkspaceAssignmentDetailRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - workspace_assignment_detail: z - .lazy(() => unmarshalWorkspaceAssignmentDetailSchema) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - workspaceAssignmentDetail: d.workspace_assignment_detail, - })); - -export const unmarshalDeleteAccountAccessIdentityRuleRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - external_principal_id: z.string().optional(), - }) - .transform(d => ({ - parent: d.parent, - externalPrincipalId: d.external_principal_id, - })); - -export const unmarshalDeleteDirectGroupMemberProxyRequestSchema: z.ZodType = - z - .object({ - group_id: z.number().optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - groupId: d.group_id, - principalId: d.principal_id, - })); - -export const unmarshalDeleteDirectGroupMemberRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - group_id: z.number().optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - groupId: d.group_id, - principalId: d.principal_id, - })); - -export const unmarshalDeleteGroupProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - })); - -export const unmarshalDeleteGroupRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - internal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - internalId: d.internal_id, - })); - -export const unmarshalDeleteServicePrincipalProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - })); - -export const unmarshalDeleteServicePrincipalRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - internal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - internalId: d.internal_id, - })); - -export const unmarshalDeleteUserProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - })); +export const unmarshalCreateDirectGroupMemberProxyRequestSchema: z.ZodType = z + .object({ + group_id: z.number().optional(), + direct_group_member: z.lazy(() => unmarshalDirectGroupMemberSchema).optional(), + }) + .transform(d => ({ + groupId: d.group_id, + directGroupMember: d.direct_group_member, + })); -export const unmarshalDeleteUserRequestSchema: z.ZodType = z +export const unmarshalCreateDirectGroupMemberRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), - internal_id: z.number().optional(), + group_id: z.number().optional(), + direct_group_member: z.lazy(() => unmarshalDirectGroupMemberSchema).optional(), }) .transform(d => ({ accountId: d.account_id, - internalId: d.internal_id, + groupId: d.group_id, + directGroupMember: d.direct_group_member, })); -export const unmarshalDeleteWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - })); - -export const unmarshalDeleteWorkspaceAssignmentDetailRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - principalId: d.principal_id, - })); - -export const unmarshalDirectGroupMemberSchema: z.ZodType = z +export const unmarshalCreateGroupProxyRequestSchema: z.ZodType = z .object({ - principal_id: z.number().optional(), - principal_type: z.enum(PrincipalType).optional(), - membership_source: z.enum(GroupMembershipSource).optional(), - display_name: z.string().optional(), - external_id: z.string().optional(), + group: z.lazy(() => unmarshalGroupSchema).optional(), }) .transform(d => ({ - principalId: d.principal_id, - principalType: d.principal_type, - membershipSource: d.membership_source, - displayName: d.display_name, - externalId: d.external_id, + group: d.group, })); -export const unmarshalGetAccountAccessIdentityRuleRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - external_principal_id: z.string().optional(), - }) - .transform(d => ({ - parent: d.parent, - externalPrincipalId: d.external_principal_id, - })); - -export const unmarshalGetDirectGroupMemberProxyRequestSchema: z.ZodType = - z - .object({ - group_id: z.number().optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - groupId: d.group_id, - principalId: d.principal_id, - })); - -export const unmarshalGetDirectGroupMemberRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - group_id: z.number().optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - groupId: d.group_id, - principalId: d.principal_id, - })); - -export const unmarshalGetGroupProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - })); - -export const unmarshalGetGroupRequestSchema: z.ZodType = z +export const unmarshalCreateGroupRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), - internal_id: z.number().optional(), + group: z.lazy(() => unmarshalGroupSchema).optional(), }) .transform(d => ({ accountId: d.account_id, - internalId: d.internal_id, + group: d.group, })); -export const unmarshalGetServicePrincipalProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - })); - -export const unmarshalGetServicePrincipalRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - internal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - internalId: d.internal_id, - })); - -export const unmarshalGetUserProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - })); +export const unmarshalCreateServicePrincipalProxyRequestSchema: z.ZodType = z + .object({ + service_principal: z.lazy(() => unmarshalServicePrincipalSchema).optional(), + }) + .transform(d => ({ + servicePrincipal: d.service_principal, + })); -export const unmarshalGetUserRequestSchema: z.ZodType = z +export const unmarshalCreateServicePrincipalRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), - internal_id: z.number().optional(), + service_principal: z.lazy(() => unmarshalServicePrincipalSchema).optional(), }) .transform(d => ({ accountId: d.account_id, - internalId: d.internal_id, + servicePrincipal: d.service_principal, })); -export const unmarshalGetWorkspaceAccessDetailLocalRequestSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - view: z.enum(WorkspaceAccessDetailView).optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - view: d.view, - })); - -export const unmarshalGetWorkspaceAccessDetailRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - principal_id: z.number().optional(), - view: z.enum(WorkspaceAccessDetailView).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - principalId: d.principal_id, - view: d.view, - })); - -export const unmarshalGetWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - })); - -export const unmarshalGetWorkspaceAssignmentDetailRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - principalId: d.principal_id, - })); +export const unmarshalCreateUserProxyRequestSchema: z.ZodType = z + .object({ + user: z.lazy(() => unmarshalUserSchema).optional(), + }) + .transform(d => ({ + user: d.user, + })); -export const unmarshalGroupSchema: z.ZodType = z +export const unmarshalCreateUserRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), - internal_id: z.number().optional(), - external_id: z.string().optional(), - group_name: z.string().optional(), + user: z.lazy(() => unmarshalUserSchema).optional(), }) .transform(d => ({ accountId: d.account_id, - internalId: d.internal_id, - externalId: d.external_id, - groupName: d.group_name, + user: d.user, })); -export const unmarshalListAccountAccessIdentityRulesRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), - }) - .transform(d => ({ - parent: d.parent, - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, - })); - -export const unmarshalListAccountAccessIdentityRulesResponseSchema: z.ZodType = - z - .object({ - account_access_identity_rules: z - .array(z.lazy(() => unmarshalAccountAccessIdentityRuleSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - accountAccessIdentityRules: d.account_access_identity_rules, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListDirectGroupMembersProxyRequestSchema: z.ZodType = - z - .object({ - group_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - groupId: d.group_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListDirectGroupMembersRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - group_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - groupId: d.group_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListDirectGroupMembersResponseSchema: z.ZodType = - z - .object({ - direct_group_members: z - .array(z.lazy(() => unmarshalDirectGroupMemberSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - directGroupMembers: d.direct_group_members, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListGroupsProxyRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, - })); +export const unmarshalCreateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + workspace_assignment_detail: z.lazy(() => unmarshalWorkspaceAssignmentDetailSchema).optional(), + }) + .transform(d => ({ + workspaceAssignmentDetail: d.workspace_assignment_detail, + })); -export const unmarshalListGroupsRequestSchema: z.ZodType = z +export const unmarshalCreateWorkspaceAssignmentDetailRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), + workspace_id: z.number().optional(), + workspace_assignment_detail: z.lazy(() => unmarshalWorkspaceAssignmentDetailSchema).optional(), }) .transform(d => ({ accountId: d.account_id, - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, + workspaceId: d.workspace_id, + workspaceAssignmentDetail: d.workspace_assignment_detail, })); -export const unmarshalListGroupsResponseSchema: z.ZodType = - z - .object({ - groups: z.array(z.lazy(() => unmarshalGroupSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - groups: d.groups, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListServicePrincipalsProxyRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, - })); - -export const unmarshalListServicePrincipalsRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, - })); - -export const unmarshalListServicePrincipalsResponseSchema: z.ZodType = - z - .object({ - service_principals: z - .array(z.lazy(() => unmarshalServicePrincipalSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - servicePrincipals: d.service_principals, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListTransitiveParentGroupsProxyRequestSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListTransitiveParentGroupsRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - principal_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - principalId: d.principal_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListTransitiveParentGroupsResponseSchema: z.ZodType = - z - .object({ - transitive_parent_groups: z - .array(z.lazy(() => unmarshalTransitiveParentGroupSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - transitiveParentGroups: d.transitive_parent_groups, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListUsersProxyRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, - })); +export const unmarshalDeleteAccountAccessIdentityRuleRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + external_principal_id: z.string().optional(), + }) + .transform(d => ({ + parent: d.parent, + externalPrincipalId: d.external_principal_id, + })); -export const unmarshalListUsersRequestSchema: z.ZodType = z +export const unmarshalDeleteDirectGroupMemberProxyRequestSchema: z.ZodType = z + .object({ + group_id: z.number().optional(), + principal_id: z.number().optional(), + }) + .transform(d => ({ + groupId: d.group_id, + principalId: d.principal_id, + })); + +export const unmarshalDeleteDirectGroupMemberRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - filter: z.string().optional(), + group_id: z.number().optional(), + principal_id: z.number().optional(), }) .transform(d => ({ accountId: d.account_id, - pageSize: d.page_size, - pageToken: d.page_token, - filter: d.filter, + groupId: d.group_id, + principalId: d.principal_id, })); -export const unmarshalListUsersResponseSchema: z.ZodType = z +export const unmarshalDeleteGroupProxyRequestSchema: z.ZodType = z .object({ - users: z.array(z.lazy(() => unmarshalUserSchema)).optional(), - next_page_token: z.string().optional(), + internal_id: z.number().optional(), }) .transform(d => ({ - users: d.users, - nextPageToken: d.next_page_token, + internalId: d.internal_id, })); -export const unmarshalListWorkspaceAccessDetailsLocalRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListWorkspaceAccessDetailsRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListWorkspaceAccessDetailsResponseSchema: z.ZodType = - z - .object({ - workspace_access_details: z - .array(z.lazy(() => unmarshalWorkspaceAccessDetailSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - workspaceAccessDetails: d.workspace_access_details, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListWorkspaceAssignmentDetailsProxyRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListWorkspaceAssignmentDetailsRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListWorkspaceAssignmentDetailsResponseSchema: z.ZodType = - z - .object({ - workspace_assignment_details: z - .array(z.lazy(() => unmarshalWorkspaceAssignmentDetailSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - workspaceAssignmentDetails: d.workspace_assignment_details, - nextPageToken: d.next_page_token, - })); - -export const unmarshalResolveGroupProxyRequestSchema: z.ZodType = - z - .object({ - external_id: z.string().optional(), - }) - .transform(d => ({ - externalId: d.external_id, - })); - -export const unmarshalResolveGroupRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - external_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - externalId: d.external_id, - })); - -export const unmarshalResolveGroupResponseSchema: z.ZodType = - z - .object({ - group: z.lazy(() => unmarshalGroupSchema).optional(), - }) - .transform(d => ({ - group: d.group, - })); - -export const unmarshalResolveServicePrincipalProxyRequestSchema: z.ZodType = - z - .object({ - external_id: z.string().optional(), - }) - .transform(d => ({ - externalId: d.external_id, - })); - -export const unmarshalResolveServicePrincipalRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - external_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - externalId: d.external_id, - })); - -export const unmarshalResolveServicePrincipalResponseSchema: z.ZodType = - z - .object({ - service_principal: z - .lazy(() => unmarshalServicePrincipalSchema) - .optional(), - }) - .transform(d => ({ - servicePrincipal: d.service_principal, - })); - -export const unmarshalResolveUserProxyRequestSchema: z.ZodType = - z - .object({ - external_id: z.string().optional(), - }) - .transform(d => ({ - externalId: d.external_id, - })); - -export const unmarshalResolveUserRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - external_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - externalId: d.external_id, - })); - -export const unmarshalResolveUserResponseSchema: z.ZodType = - z - .object({ - user: z.lazy(() => unmarshalUserSchema).optional(), - }) - .transform(d => ({ - user: d.user, - })); - -export const unmarshalServicePrincipalSchema: z.ZodType = z +export const unmarshalDeleteGroupRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), internal_id: z.number().optional(), - external_id: z.string().optional(), - application_id: z.string().optional(), - display_name: z.string().optional(), - account_sp_status: z.enum(State).optional(), }) .transform(d => ({ accountId: d.account_id, internalId: d.internal_id, - externalId: d.external_id, - applicationId: d.application_id, - displayName: d.display_name, - accountSpStatus: d.account_sp_status, })); -export const unmarshalTransitiveParentGroupSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - internal_id: z.number().optional(), - external_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - internalId: d.internal_id, - externalId: d.external_id, - })); - -export const unmarshalUpdateGroupProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - group: z.lazy(() => unmarshalGroupSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - group: d.group, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateGroupRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - internal_id: z.number().optional(), - group: z.lazy(() => unmarshalGroupSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - internalId: d.internal_id, - group: d.group, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateServicePrincipalProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - service_principal: z - .lazy(() => unmarshalServicePrincipalSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - servicePrincipal: d.service_principal, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateServicePrincipalRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - internal_id: z.number().optional(), - service_principal: z - .lazy(() => unmarshalServicePrincipalSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - internalId: d.internal_id, - servicePrincipal: d.service_principal, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateUserProxyRequestSchema: z.ZodType = - z - .object({ - internal_id: z.number().optional(), - user: z.lazy(() => unmarshalUserSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - internalId: d.internal_id, - user: d.user, - updateMask: d.update_mask, - })); +export const unmarshalDeleteServicePrincipalProxyRequestSchema: z.ZodType = z + .object({ + internal_id: z.number().optional(), + }) + .transform(d => ({ + internalId: d.internal_id, + })); -export const unmarshalUpdateUserRequestSchema: z.ZodType = z +export const unmarshalDeleteServicePrincipalRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), internal_id: z.number().optional(), - user: z.lazy(() => unmarshalUserSchema).optional(), - update_mask: z.string().optional(), }) .transform(d => ({ accountId: d.account_id, internalId: d.internal_id, - user: d.user, - updateMask: d.update_mask, })); -export const unmarshalUpdateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - workspace_assignment_detail: z - .lazy(() => unmarshalWorkspaceAssignmentDetailSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - workspaceAssignmentDetail: d.workspace_assignment_detail, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateWorkspaceAssignmentDetailRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - workspace_id: z.number().optional(), - principal_id: z.number().optional(), - workspace_assignment_detail: z - .lazy(() => unmarshalWorkspaceAssignmentDetailSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - workspaceId: d.workspace_id, - principalId: d.principal_id, - workspaceAssignmentDetail: d.workspace_assignment_detail, - updateMask: d.update_mask, - })); +export const unmarshalDeleteUserProxyRequestSchema: z.ZodType = z + .object({ + internal_id: z.number().optional(), + }) + .transform(d => ({ + internalId: d.internal_id, + })); -export const unmarshalUserSchema: z.ZodType = z +export const unmarshalDeleteUserRequestSchema: z.ZodType = z .object({ account_id: z.string().optional(), internal_id: z.number().optional(), - external_id: z.string().optional(), - username: z.string().optional(), - name: z.lazy(() => unmarshalUser_NameSchema).optional(), - account_user_status: z.enum(State).optional(), }) .transform(d => ({ accountId: d.account_id, internalId: d.internal_id, - externalId: d.external_id, - username: d.username, - name: d.name, - accountUserStatus: d.account_user_status, })); -// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUser_NameSchema: z.ZodType = z +export const unmarshalDeleteWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z .object({ - given_name: z.string().optional(), - family_name: z.string().optional(), + principal_id: z.number().optional(), }) .transform(d => ({ - givenName: d.given_name, - familyName: d.family_name, + principalId: d.principal_id, })); -export const unmarshalWorkspaceAccessDetailSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - workspace_id: z.number().optional(), - account_id: z.string().optional(), - principal_type: z.enum(PrincipalType).optional(), - access_type: z.enum(WorkspaceAccessDetail_AccessType).optional(), - status: z.enum(State).optional(), - permissions: z.array(z.enum(WorkspacePermission)).optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - workspaceId: d.workspace_id, - accountId: d.account_id, - principalType: d.principal_type, - accessType: d.access_type, - status: d.status, - permissions: d.permissions, - })); - -export const unmarshalWorkspaceAssignmentDetailSchema: z.ZodType = - z - .object({ - principal_id: z.number().optional(), - workspace_id: z.number().optional(), - account_id: z.string().optional(), - principal_type: z.enum(PrincipalType).optional(), - entitlements: z.array(z.enum(Entitlement)).optional(), - }) - .transform(d => ({ - principalId: d.principal_id, - workspaceId: d.workspace_id, - accountId: d.account_id, - principalType: d.principal_type, - entitlements: d.entitlements, - })); +export const unmarshalDeleteWorkspaceAssignmentDetailRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + principal_id: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + principalId: d.principal_id, + })); -export const marshalAccountAccessIdentityRuleSchema: z.ZodType = z +export const unmarshalDirectGroupMemberSchema: z.ZodType = z .object({ - action: z.enum(AccountAccessRuleAction).optional(), - externalPrincipalId: z.string().optional(), - displayName: z.string().optional(), - principalType: z.enum(PrincipalType).optional(), - name: z.string().optional(), + principal_id: z.number().optional(), + principal_type: z.enum(PrincipalType).optional(), + membership_source: z.enum(GroupMembershipSource).optional(), + display_name: z.string().optional(), + external_id: z.string().optional(), }) .transform(d => ({ - action: d.action, - external_principal_id: d.externalPrincipalId, - display_name: d.displayName, - principal_type: d.principalType, - name: d.name, + principalId: d.principal_id, + principalType: d.principal_type, + membershipSource: d.membership_source, + displayName: d.display_name, + externalId: d.external_id, })); -export const marshalCreateAccountAccessIdentityRuleRequestSchema: z.ZodType = z +export const unmarshalGetAccountAccessIdentityRuleRequestSchema: z.ZodType = z .object({ parent: z.string().optional(), - externalPrincipalId: z.string().optional(), - accountAccessIdentityRule: z - .lazy(() => marshalAccountAccessIdentityRuleSchema) - .optional(), + external_principal_id: z.string().optional(), }) .transform(d => ({ parent: d.parent, - external_principal_id: d.externalPrincipalId, - account_access_identity_rule: d.accountAccessIdentityRule, + externalPrincipalId: d.external_principal_id, })); -export const marshalCreateDirectGroupMemberProxyRequestSchema: z.ZodType = z +export const unmarshalGetDirectGroupMemberProxyRequestSchema: z.ZodType = z .object({ - groupId: z.number().optional(), - directGroupMember: z.lazy(() => marshalDirectGroupMemberSchema).optional(), + group_id: z.number().optional(), + principal_id: z.number().optional(), }) .transform(d => ({ - group_id: d.groupId, - direct_group_member: d.directGroupMember, + groupId: d.group_id, + principalId: d.principal_id, })); -export const marshalCreateDirectGroupMemberRequestSchema: z.ZodType = z +export const unmarshalGetDirectGroupMemberRequestSchema: z.ZodType = z .object({ - accountId: z.string().optional(), - groupId: z.number().optional(), - directGroupMember: z.lazy(() => marshalDirectGroupMemberSchema).optional(), + account_id: z.string().optional(), + group_id: z.number().optional(), + principal_id: z.number().optional(), }) .transform(d => ({ - account_id: d.accountId, - group_id: d.groupId, - direct_group_member: d.directGroupMember, + accountId: d.account_id, + groupId: d.group_id, + principalId: d.principal_id, })); -export const marshalCreateGroupProxyRequestSchema: z.ZodType = z +export const unmarshalGetGroupProxyRequestSchema: z.ZodType = z .object({ - group: z.lazy(() => marshalGroupSchema).optional(), + internal_id: z.number().optional(), }) .transform(d => ({ - group: d.group, + internalId: d.internal_id, })); -export const marshalCreateGroupRequestSchema: z.ZodType = z +export const unmarshalGetGroupRequestSchema: z.ZodType = z .object({ - accountId: z.string().optional(), - group: z.lazy(() => marshalGroupSchema).optional(), + account_id: z.string().optional(), + internal_id: z.number().optional(), }) .transform(d => ({ - account_id: d.accountId, - group: d.group, + accountId: d.account_id, + internalId: d.internal_id, })); -export const marshalCreateServicePrincipalProxyRequestSchema: z.ZodType = z +export const unmarshalGetServicePrincipalProxyRequestSchema: z.ZodType = z .object({ - servicePrincipal: z.lazy(() => marshalServicePrincipalSchema).optional(), + internal_id: z.number().optional(), }) .transform(d => ({ - service_principal: d.servicePrincipal, + internalId: d.internal_id, })); -export const marshalCreateServicePrincipalRequestSchema: z.ZodType = z +export const unmarshalGetServicePrincipalRequestSchema: z.ZodType = z .object({ - accountId: z.string().optional(), - servicePrincipal: z.lazy(() => marshalServicePrincipalSchema).optional(), + account_id: z.string().optional(), + internal_id: z.number().optional(), }) .transform(d => ({ - account_id: d.accountId, - service_principal: d.servicePrincipal, + accountId: d.account_id, + internalId: d.internal_id, })); -export const marshalCreateUserProxyRequestSchema: z.ZodType = z +export const unmarshalGetUserProxyRequestSchema: z.ZodType = z .object({ - user: z.lazy(() => marshalUserSchema).optional(), + internal_id: z.number().optional(), }) .transform(d => ({ - user: d.user, + internalId: d.internal_id, + })); + +export const unmarshalGetUserRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + })); + +export const unmarshalGetWorkspaceAccessDetailLocalRequestSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + view: z.enum(WorkspaceAccessDetailView).optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + view: d.view, + })); + +export const unmarshalGetWorkspaceAccessDetailRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + principal_id: z.number().optional(), + view: z.enum(WorkspaceAccessDetailView).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + principalId: d.principal_id, + view: d.view, + })); + +export const unmarshalGetWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + })); + +export const unmarshalGetWorkspaceAssignmentDetailRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + principal_id: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + principalId: d.principal_id, + })); + +export const unmarshalGetWorkspaceIdentityDetailRequestSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + })); + +export const unmarshalGroupSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + external_id: z.string().optional(), + group_name: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + externalId: d.external_id, + groupName: d.group_name, + })); + +export const unmarshalListAccountAccessIdentityRulesRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + parent: d.parent, + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListAccountAccessIdentityRulesResponseSchema: z.ZodType = z + .object({ + account_access_identity_rules: z.array(z.lazy(() => unmarshalAccountAccessIdentityRuleSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + accountAccessIdentityRules: d.account_access_identity_rules, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListDirectGroupMembersProxyRequestSchema: z.ZodType = z + .object({ + group_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + groupId: d.group_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListDirectGroupMembersRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + group_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + groupId: d.group_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListDirectGroupMembersResponseSchema: z.ZodType = z + .object({ + direct_group_members: z.array(z.lazy(() => unmarshalDirectGroupMemberSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + directGroupMembers: d.direct_group_members, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListGroupsProxyRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListGroupsRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListGroupsResponseSchema: z.ZodType = z + .object({ + groups: z.array(z.lazy(() => unmarshalGroupSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + groups: d.groups, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListServicePrincipalsProxyRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListServicePrincipalsRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListServicePrincipalsResponseSchema: z.ZodType = z + .object({ + service_principals: z.array(z.lazy(() => unmarshalServicePrincipalSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + servicePrincipals: d.service_principals, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListTransitiveParentGroupsProxyRequestSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListTransitiveParentGroupsRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + principal_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + principalId: d.principal_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListTransitiveParentGroupsResponseSchema: z.ZodType = z + .object({ + transitive_parent_groups: z.array(z.lazy(() => unmarshalTransitiveParentGroupSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + transitiveParentGroups: d.transitive_parent_groups, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListUsersProxyRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListUsersRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageSize: d.page_size, + pageToken: d.page_token, + filter: d.filter, + })); + +export const unmarshalListUsersResponseSchema: z.ZodType = z + .object({ + users: z.array(z.lazy(() => unmarshalUserSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + users: d.users, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListWorkspaceAccessDetailsLocalRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListWorkspaceAccessDetailsRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListWorkspaceAccessDetailsResponseSchema: z.ZodType = z + .object({ + workspace_access_details: z.array(z.lazy(() => unmarshalWorkspaceAccessDetailSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + workspaceAccessDetails: d.workspace_access_details, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListWorkspaceAssignmentDetailsProxyRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListWorkspaceAssignmentDetailsRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListWorkspaceAssignmentDetailsResponseSchema: z.ZodType = z + .object({ + workspace_assignment_details: z.array(z.lazy(() => unmarshalWorkspaceAssignmentDetailSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + workspaceAssignmentDetails: d.workspace_assignment_details, + nextPageToken: d.next_page_token, + })); + +export const unmarshalResolveGroupProxyRequestSchema: z.ZodType = z + .object({ + external_id: z.string().optional(), + }) + .transform(d => ({ + externalId: d.external_id, + })); + +export const unmarshalResolveGroupRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + external_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + externalId: d.external_id, + })); + +export const unmarshalResolveGroupResponseSchema: z.ZodType = z + .object({ + group: z.lazy(() => unmarshalGroupSchema).optional(), + }) + .transform(d => ({ + group: d.group, + })); + +export const unmarshalResolveServicePrincipalProxyRequestSchema: z.ZodType = z + .object({ + external_id: z.string().optional(), + }) + .transform(d => ({ + externalId: d.external_id, + })); + +export const unmarshalResolveServicePrincipalRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + external_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + externalId: d.external_id, + })); + +export const unmarshalResolveServicePrincipalResponseSchema: z.ZodType = z + .object({ + service_principal: z.lazy(() => unmarshalServicePrincipalSchema).optional(), + }) + .transform(d => ({ + servicePrincipal: d.service_principal, + })); + +export const unmarshalResolveUserProxyRequestSchema: z.ZodType = z + .object({ + external_id: z.string().optional(), + }) + .transform(d => ({ + externalId: d.external_id, + })); + +export const unmarshalResolveUserRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + external_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + externalId: d.external_id, + })); + +export const unmarshalResolveUserResponseSchema: z.ZodType = z + .object({ + user: z.lazy(() => unmarshalUserSchema).optional(), + }) + .transform(d => ({ + user: d.user, + })); + +export const unmarshalServicePrincipalSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + external_id: z.string().optional(), + application_id: z.string().optional(), + display_name: z.string().optional(), + account_sp_status: z.enum(State).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + externalId: d.external_id, + applicationId: d.application_id, + displayName: d.display_name, + accountSpStatus: d.account_sp_status, + })); + +export const unmarshalTransitiveParentGroupSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + external_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + externalId: d.external_id, + })); + +export const unmarshalUpdateGroupProxyRequestSchema: z.ZodType = z + .object({ + internal_id: z.number().optional(), + group: z.lazy(() => unmarshalGroupSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + internalId: d.internal_id, + group: d.group, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateGroupRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + group: z.lazy(() => unmarshalGroupSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + group: d.group, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateServicePrincipalProxyRequestSchema: z.ZodType = z + .object({ + internal_id: z.number().optional(), + service_principal: z.lazy(() => unmarshalServicePrincipalSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + internalId: d.internal_id, + servicePrincipal: d.service_principal, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateServicePrincipalRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + service_principal: z.lazy(() => unmarshalServicePrincipalSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + servicePrincipal: d.service_principal, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateUserProxyRequestSchema: z.ZodType = z + .object({ + internal_id: z.number().optional(), + user: z.lazy(() => unmarshalUserSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + internalId: d.internal_id, + user: d.user, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateUserRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + user: z.lazy(() => unmarshalUserSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + user: d.user, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + workspace_assignment_detail: z.lazy(() => unmarshalWorkspaceAssignmentDetailSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + workspaceAssignmentDetail: d.workspace_assignment_detail, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateWorkspaceAssignmentDetailRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + principal_id: z.number().optional(), + workspace_assignment_detail: z.lazy(() => unmarshalWorkspaceAssignmentDetailSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + principalId: d.principal_id, + workspaceAssignmentDetail: d.workspace_assignment_detail, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateWorkspaceIdentityDetailRequestSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + workspace_identity_detail: z.lazy(() => unmarshalWorkspaceIdentityDetailSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + workspaceIdentityDetail: d.workspace_identity_detail, + updateMask: d.update_mask, + })); + +export const unmarshalUserSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + internal_id: z.number().optional(), + external_id: z.string().optional(), + username: z.string().optional(), + name: z.lazy(() => unmarshalUser_NameSchema).optional(), + account_user_status: z.enum(State).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + internalId: d.internal_id, + externalId: d.external_id, + username: d.username, + name: d.name, + accountUserStatus: d.account_user_status, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalUser_NameSchema: z.ZodType = z + .object({ + given_name: z.string().optional(), + family_name: z.string().optional(), + }) + .transform(d => ({ + givenName: d.given_name, + familyName: d.family_name, + })); + +export const unmarshalWorkspaceAccessDetailSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + workspace_id: z.number().optional(), + account_id: z.string().optional(), + principal_type: z.enum(PrincipalType).optional(), + access_type: z.enum(WorkspaceAccessDetail_AccessType).optional(), + status: z.enum(State).optional(), + permissions: z.array(z.enum(WorkspacePermission)).optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + workspaceId: d.workspace_id, + accountId: d.account_id, + principalType: d.principal_type, + accessType: d.access_type, + status: d.status, + permissions: d.permissions, + })); + +export const unmarshalWorkspaceAssignmentDetailSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + workspace_id: z.number().optional(), + account_id: z.string().optional(), + principal_type: z.enum(PrincipalType).optional(), + entitlements: z.array(z.enum(Entitlement)).optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + workspaceId: d.workspace_id, + accountId: d.account_id, + principalType: d.principal_type, + entitlements: d.entitlements, + })); + +export const unmarshalWorkspaceIdentityDetailSchema: z.ZodType = z + .object({ + principal_id: z.number().optional(), + principal_type: z.enum(PrincipalType).optional(), + workspace_identity_status: z.enum(State).optional(), + assignment_type: z.enum(WorkspaceIdentityDetail_AssignmentType).optional(), + }) + .transform(d => ({ + principalId: d.principal_id, + principalType: d.principal_type, + workspaceIdentityStatus: d.workspace_identity_status, + assignmentType: d.assignment_type, + })); + +export const marshalAccountAccessIdentityRuleSchema: z.ZodType = z + .object({ + action: z.enum(AccountAccessRuleAction).optional(), + externalPrincipalId: z.string().optional(), + displayName: z.string().optional(), + principalType: z.enum(PrincipalType).optional(), + name: z.string().optional(), + }) + .transform(d => ({ + action: d.action, + external_principal_id: d.externalPrincipalId, + display_name: d.displayName, + principal_type: d.principalType, + name: d.name, + })); + +export const marshalCreateAccountAccessIdentityRuleRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + externalPrincipalId: z.string().optional(), + accountAccessIdentityRule: z.lazy(() => marshalAccountAccessIdentityRuleSchema).optional(), + }) + .transform(d => ({ + parent: d.parent, + external_principal_id: d.externalPrincipalId, + account_access_identity_rule: d.accountAccessIdentityRule, + })); + +export const marshalCreateDirectGroupMemberProxyRequestSchema: z.ZodType = z + .object({ + groupId: z.number().optional(), + directGroupMember: z.lazy(() => marshalDirectGroupMemberSchema).optional(), + }) + .transform(d => ({ + group_id: d.groupId, + direct_group_member: d.directGroupMember, + })); + +export const marshalCreateDirectGroupMemberRequestSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + groupId: z.number().optional(), + directGroupMember: z.lazy(() => marshalDirectGroupMemberSchema).optional(), + }) + .transform(d => ({ + account_id: d.accountId, + group_id: d.groupId, + direct_group_member: d.directGroupMember, + })); + +export const marshalCreateGroupProxyRequestSchema: z.ZodType = z + .object({ + group: z.lazy(() => marshalGroupSchema).optional(), + }) + .transform(d => ({ + group: d.group, + })); + +export const marshalCreateGroupRequestSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + group: z.lazy(() => marshalGroupSchema).optional(), + }) + .transform(d => ({ + account_id: d.accountId, + group: d.group, + })); + +export const marshalCreateServicePrincipalProxyRequestSchema: z.ZodType = z + .object({ + servicePrincipal: z.lazy(() => marshalServicePrincipalSchema).optional(), + }) + .transform(d => ({ + service_principal: d.servicePrincipal, + })); + +export const marshalCreateServicePrincipalRequestSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + servicePrincipal: z.lazy(() => marshalServicePrincipalSchema).optional(), + }) + .transform(d => ({ + account_id: d.accountId, + service_principal: d.servicePrincipal, + })); + +export const marshalCreateUserProxyRequestSchema: z.ZodType = z + .object({ + user: z.lazy(() => marshalUserSchema).optional(), + }) + .transform(d => ({ + user: d.user, })); export const marshalCreateUserRequestSchema: z.ZodType = z @@ -2116,24 +2081,19 @@ export const marshalCreateUserRequestSchema: z.ZodType = z user: d.user, })); -export const marshalCreateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - workspaceAssignmentDetail: z - .lazy(() => marshalWorkspaceAssignmentDetailSchema) - .optional(), - }) - .transform(d => ({ - workspace_assignment_detail: d.workspaceAssignmentDetail, - })); +export const marshalCreateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + workspaceAssignmentDetail: z.lazy(() => marshalWorkspaceAssignmentDetailSchema).optional(), + }) + .transform(d => ({ + workspace_assignment_detail: d.workspaceAssignmentDetail, + })); export const marshalCreateWorkspaceAssignmentDetailRequestSchema: z.ZodType = z .object({ accountId: z.string().optional(), workspaceId: z.number().optional(), - workspaceAssignmentDetail: z - .lazy(() => marshalWorkspaceAssignmentDetailSchema) - .optional(), + workspaceAssignmentDetail: z.lazy(() => marshalWorkspaceAssignmentDetailSchema).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -2227,14 +2187,13 @@ export const marshalDeleteUserRequestSchema: z.ZodType = z internal_id: d.internalId, })); -export const marshalDeleteWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - principalId: z.number().optional(), - }) - .transform(d => ({ - principal_id: d.principalId, - })); +export const marshalDeleteWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + principalId: z.number().optional(), + }) + .transform(d => ({ + principal_id: d.principalId, + })); export const marshalDeleteWorkspaceAssignmentDetailRequestSchema: z.ZodType = z .object({ @@ -2374,14 +2333,13 @@ export const marshalGetWorkspaceAccessDetailRequestSchema: z.ZodType = z view: d.view, })); -export const marshalGetWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - principalId: z.number().optional(), - }) - .transform(d => ({ - principal_id: d.principalId, - })); +export const marshalGetWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + principalId: z.number().optional(), + }) + .transform(d => ({ + principal_id: d.principalId, + })); export const marshalGetWorkspaceAssignmentDetailRequestSchema: z.ZodType = z .object({ @@ -2395,6 +2353,14 @@ export const marshalGetWorkspaceAssignmentDetailRequestSchema: z.ZodType = z principal_id: d.principalId, })); +export const marshalGetWorkspaceIdentityDetailRequestSchema: z.ZodType = z + .object({ + principalId: z.number().optional(), + }) + .transform(d => ({ + principal_id: d.principalId, + })); + export const marshalGroupSchema: z.ZodType = z .object({ accountId: z.string().optional(), @@ -2425,9 +2391,7 @@ export const marshalListAccountAccessIdentityRulesRequestSchema: z.ZodType = z export const marshalListAccountAccessIdentityRulesResponseSchema: z.ZodType = z .object({ - accountAccessIdentityRules: z - .array(z.lazy(() => marshalAccountAccessIdentityRuleSchema)) - .optional(), + accountAccessIdentityRules: z.array(z.lazy(() => marshalAccountAccessIdentityRuleSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2463,9 +2427,7 @@ export const marshalListDirectGroupMembersRequestSchema: z.ZodType = z export const marshalListDirectGroupMembersResponseSchema: z.ZodType = z .object({ - directGroupMembers: z - .array(z.lazy(() => marshalDirectGroupMemberSchema)) - .optional(), + directGroupMembers: z.array(z.lazy(() => marshalDirectGroupMemberSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2537,9 +2499,7 @@ export const marshalListServicePrincipalsRequestSchema: z.ZodType = z export const marshalListServicePrincipalsResponseSchema: z.ZodType = z .object({ - servicePrincipals: z - .array(z.lazy(() => marshalServicePrincipalSchema)) - .optional(), + servicePrincipals: z.array(z.lazy(() => marshalServicePrincipalSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2575,9 +2535,7 @@ export const marshalListTransitiveParentGroupsRequestSchema: z.ZodType = z export const marshalListTransitiveParentGroupsResponseSchema: z.ZodType = z .object({ - transitiveParentGroups: z - .array(z.lazy(() => marshalTransitiveParentGroupSchema)) - .optional(), + transitiveParentGroups: z.array(z.lazy(() => marshalTransitiveParentGroupSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2647,9 +2605,7 @@ export const marshalListWorkspaceAccessDetailsRequestSchema: z.ZodType = z export const marshalListWorkspaceAccessDetailsResponseSchema: z.ZodType = z .object({ - workspaceAccessDetails: z - .array(z.lazy(() => marshalWorkspaceAccessDetailSchema)) - .optional(), + workspaceAccessDetails: z.array(z.lazy(() => marshalWorkspaceAccessDetailSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2657,16 +2613,15 @@ export const marshalListWorkspaceAccessDetailsResponseSchema: z.ZodType = z next_page_token: d.nextPageToken, })); -export const marshalListWorkspaceAssignmentDetailsProxyRequestSchema: z.ZodType = - z - .object({ - pageSize: z.number().optional(), - pageToken: z.string().optional(), - }) - .transform(d => ({ - page_size: d.pageSize, - page_token: d.pageToken, - })); +export const marshalListWorkspaceAssignmentDetailsProxyRequestSchema: z.ZodType = z + .object({ + pageSize: z.number().optional(), + pageToken: z.string().optional(), + }) + .transform(d => ({ + page_size: d.pageSize, + page_token: d.pageToken, + })); export const marshalListWorkspaceAssignmentDetailsRequestSchema: z.ZodType = z .object({ @@ -2684,9 +2639,7 @@ export const marshalListWorkspaceAssignmentDetailsRequestSchema: z.ZodType = z export const marshalListWorkspaceAssignmentDetailsResponseSchema: z.ZodType = z .object({ - workspaceAssignmentDetails: z - .array(z.lazy(() => marshalWorkspaceAssignmentDetailSchema)) - .optional(), + workspaceAssignmentDetails: z.array(z.lazy(() => marshalWorkspaceAssignmentDetailSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2806,7 +2759,7 @@ export const marshalUpdateGroupProxyRequestSchema: z.ZodType = z .object({ internalId: z.number().optional(), group: z.lazy(() => marshalGroupSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ internal_id: d.internalId, @@ -2819,7 +2772,7 @@ export const marshalUpdateGroupRequestSchema: z.ZodType = z accountId: z.string().optional(), internalId: z.number().optional(), group: z.lazy(() => marshalGroupSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -2832,7 +2785,7 @@ export const marshalUpdateServicePrincipalProxyRequestSchema: z.ZodType = z .object({ internalId: z.number().optional(), servicePrincipal: z.lazy(() => marshalServicePrincipalSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ internal_id: d.internalId, @@ -2845,7 +2798,7 @@ export const marshalUpdateServicePrincipalRequestSchema: z.ZodType = z accountId: z.string().optional(), internalId: z.number().optional(), servicePrincipal: z.lazy(() => marshalServicePrincipalSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -2858,7 +2811,7 @@ export const marshalUpdateUserProxyRequestSchema: z.ZodType = z .object({ internalId: z.number().optional(), user: z.lazy(() => marshalUserSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ internal_id: d.internalId, @@ -2871,7 +2824,7 @@ export const marshalUpdateUserRequestSchema: z.ZodType = z accountId: z.string().optional(), internalId: z.number().optional(), user: z.lazy(() => marshalUserSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -2880,30 +2833,25 @@ export const marshalUpdateUserRequestSchema: z.ZodType = z update_mask: d.updateMask, })); -export const marshalUpdateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = - z - .object({ - principalId: z.number().optional(), - workspaceAssignmentDetail: z - .lazy(() => marshalWorkspaceAssignmentDetailSchema) - .optional(), - updateMask: z.string().optional(), - }) - .transform(d => ({ - principal_id: d.principalId, - workspace_assignment_detail: d.workspaceAssignmentDetail, - update_mask: d.updateMask, - })); +export const marshalUpdateWorkspaceAssignmentDetailProxyRequestSchema: z.ZodType = z + .object({ + principalId: z.number().optional(), + workspaceAssignmentDetail: z.lazy(() => marshalWorkspaceAssignmentDetailSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), + }) + .transform(d => ({ + principal_id: d.principalId, + workspace_assignment_detail: d.workspaceAssignmentDetail, + update_mask: d.updateMask, + })); export const marshalUpdateWorkspaceAssignmentDetailRequestSchema: z.ZodType = z .object({ accountId: z.string().optional(), workspaceId: z.number().optional(), principalId: z.number().optional(), - workspaceAssignmentDetail: z - .lazy(() => marshalWorkspaceAssignmentDetailSchema) - .optional(), - updateMask: z.string().optional(), + workspaceAssignmentDetail: z.lazy(() => marshalWorkspaceAssignmentDetailSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -2913,6 +2861,18 @@ export const marshalUpdateWorkspaceAssignmentDetailRequestSchema: z.ZodType = z update_mask: d.updateMask, })); +export const marshalUpdateWorkspaceIdentityDetailRequestSchema: z.ZodType = z + .object({ + principalId: z.number().optional(), + workspaceIdentityDetail: z.lazy(() => marshalWorkspaceIdentityDetailSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), + }) + .transform(d => ({ + principal_id: d.principalId, + workspace_identity_detail: d.workspaceIdentityDetail, + update_mask: d.updateMask, + })); + export const marshalUserSchema: z.ZodType = z .object({ accountId: z.string().optional(), @@ -2977,3 +2937,17 @@ export const marshalWorkspaceAssignmentDetailSchema: z.ZodType = z principal_type: d.principalType, entitlements: d.entitlements, })); + +export const marshalWorkspaceIdentityDetailSchema: z.ZodType = z + .object({ + principalId: z.number().optional(), + principalType: z.enum(PrincipalType).optional(), + workspaceIdentityStatus: z.enum(State).optional(), + assignmentType: z.enum(WorkspaceIdentityDetail_AssignmentType).optional(), + }) + .transform(d => ({ + principal_id: d.principalId, + principal_type: d.principalType, + workspace_identity_status: d.workspaceIdentityStatus, + assignment_type: d.assignmentType, + })); diff --git a/packages/iam/src/v2/utils.ts b/packages/iam/src/v2/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/iam/src/v2/utils.ts +++ b/packages/iam/src/v2/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/iam/tsconfig.json b/packages/iam/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/iam/tsconfig.json +++ b/packages/iam/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/instancepools/package.json b/packages/instancepools/package.json new file mode 100644 index 00000000..92822baa --- /dev/null +++ b/packages/instancepools/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-instancepools", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v2": { + "types": "./dist/v2/index.d.ts", + "import": "./dist/v2/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/instancepools/src/v2/client.ts b/packages/instancepools/src/v2/client.ts new file mode 100644 index 00000000..1094a7f9 --- /dev/null +++ b/packages/instancepools/src/v2/client.ts @@ -0,0 +1,136 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + CreateInstancePool, + CreateInstancePool_Response, + DeleteInstancePool, + DeleteInstancePool_Response, + EditInstancePool, + EditInstancePool_Response, + GetInstancePool, + GetInstancePool_Response, + ListInstancePools, + ListInstancePools_Response, +} from './model'; +import { + marshalCreateInstancePoolSchema, + marshalDeleteInstancePoolSchema, + marshalEditInstancePoolSchema, + unmarshalCreateInstancePool_ResponseSchema, + unmarshalDeleteInstancePool_ResponseSchema, + unmarshalEditInstancePool_ResponseSchema, + unmarshalGetInstancePool_ResponseSchema, + unmarshalListInstancePools_ResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** Creates a new instance pool using idle and ready-to-use cloud instances. */ + async createInstancePool(signal: AbortSignal | undefined, req: CreateInstancePool, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-pools/create`; + const body = marshalRequest(req, marshalCreateInstancePoolSchema); + let resp: CreateInstancePool_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateInstancePool_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Deletes the instance pool permanently. The idle instances in the pool are terminated asynchronously. */ + async deleteInstancePool(signal: AbortSignal | undefined, req: DeleteInstancePool, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-pools/delete`; + const body = marshalRequest(req, marshalDeleteInstancePoolSchema); + let resp: DeleteInstancePool_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteInstancePool_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Modifies the configuration of an existing instance pool. */ + async editInstancePool(signal: AbortSignal | undefined, req: EditInstancePool, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-pools/edit`; + const body = marshalRequest(req, marshalEditInstancePoolSchema); + let resp: EditInstancePool_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalEditInstancePool_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Retrieve the information for an instance pool based on its identifier. */ + async getInstancePool(signal: AbortSignal | undefined, req: GetInstancePool, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-pools/get`; + const params = new URLSearchParams(); + if (req.instancePoolId !== undefined) { + params.append('instance_pool_id', req.instancePoolId); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: GetInstancePool_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetInstancePool_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Gets a list of instance pools with their statistics. */ + async listInstancePools(signal: AbortSignal | undefined, _req: ListInstancePools, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-pools/list`; + let resp: ListInstancePools_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListInstancePools_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/instancepools/src/v2/index.ts b/packages/instancepools/src/v2/index.ts new file mode 100644 index 00000000..a1bb3206 --- /dev/null +++ b/packages/instancepools/src/v2/index.ts @@ -0,0 +1,44 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { + AwsAvailability, + AzureAvailability, + AzureDiskVolumeType, + EbsVolumeType, + GcpAvailability, + InstancePoolState, +} from './model'; + +export type { + CreateInstancePool, + CreateInstancePool_CustomTagsEntry, + CreateInstancePool_Response, + DeleteInstancePool, + DeleteInstancePool_Response, + DiskSpec, + DiskType, + DockerBasicAuth, + DockerImage, + EditInstancePool, + EditInstancePool_CustomTagsEntry, + EditInstancePool_Response, + GetInstancePool, + GetInstancePool_Response, + GetInstancePool_Response_CustomTagsEntry, + GetInstancePool_Response_DefaultTagsEntry, + InstancePoolAndStats, + InstancePoolAndStats_CustomTagsEntry, + InstancePoolAndStats_DefaultTagsEntry, + InstancePoolAwsAttributes, + InstancePoolAzureAttributes, + InstancePoolGcpAttributes, + InstancePoolStats, + InstancePoolStatus, + ListInstancePools, + ListInstancePools_Response, + NodeTypeFlexibility, + PendingInstanceError, +} from './model'; diff --git a/packages/instancepools/src/v2/model.ts b/packages/instancepools/src/v2/model.ts new file mode 100644 index 00000000..1da0d29f --- /dev/null +++ b/packages/instancepools/src/v2/model.ts @@ -0,0 +1,1607 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +/** + * 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. + */ +export enum AwsAvailability { + /** Use spot instances. */ + SPOT = 'SPOT', + /** Use on-demand instances. */ + ON_DEMAND = 'ON_DEMAND', + /** + * Preferably use spot instances, but fall back to on-demand instances if spot instances cannot + * be acquired (e.g., if AWS spot prices are too high). + */ + SPOT_WITH_FALLBACK = 'SPOT_WITH_FALLBACK', +} + +/** + * 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. + */ +export enum AzureAvailability { + /** Use spot instances. */ + SPOT_AZURE = 'SPOT_AZURE', + /** Use on-demand instances. */ + ON_DEMAND_AZURE = 'ON_DEMAND_AZURE', + /** + * Preferably use spot instances, but fall back to on-demand instances if spot instances cannot + * be acquired (e.g., if Azure is out of Quota). + */ + SPOT_WITH_FALLBACK_AZURE = 'SPOT_WITH_FALLBACK_AZURE', +} + +/** + * All Azure Disk types that supports. + * See https://docs.microsoft.com/en-us/azure/storage/storage-about-disks-and-vhds-linux#types-of-disks + */ +export enum AzureDiskVolumeType { + /** Premium storage tier, backed by SSDs. */ + PREMIUM_LRS = 'PREMIUM_LRS', + /** Standard storage tier, backed by HDDs. */ + STANDARD_LRS = 'STANDARD_LRS', +} + +/** + * All EBS volume types that supports. + * See https://aws.amazon.com/ebs/details/ for details. + */ +export enum EbsVolumeType { + /** Provision extra storage using AWS gp2 EBS volumes. */ + GENERAL_PURPOSE_SSD = 'GENERAL_PURPOSE_SSD', + /** Provision extra storage using AWS st1 volumes. */ + THROUGHPUT_OPTIMIZED_HDD = 'THROUGHPUT_OPTIMIZED_HDD', +} + +/** + * This field determines whether the instance pool will contain preemptible + * VMs, on-demand VMs, or preemptible VMs with a fallback to on-demand VMs if the former is unavailable. + */ +export enum GcpAvailability { + PREEMPTIBLE_GCP = 'PREEMPTIBLE_GCP', + ON_DEMAND_GCP = 'ON_DEMAND_GCP', + PREEMPTIBLE_WITH_FALLBACK_GCP = 'PREEMPTIBLE_WITH_FALLBACK_GCP', +} + +/** + * The state of a Cluster. The current allowable state transitions are as follows: + * + * - ``ACTIVE`` -> ``STOPPED`` + * - ``ACTIVE`` -> ``DELETED`` + * - ``STOPPED`` -> ``ACTIVE`` + * - ``STOPPED`` -> ``DELETED`` + */ +export enum InstancePoolState { + /** Indicates an instance pool is active for use. */ + ACTIVE = 'ACTIVE', + /** + * Indicates an instance pool has been stopped so no more clusters should be able to get instances + * from the pool. + */ + STOPPED = 'STOPPED', + /** Indicates the instance pool has been deleted and should no longer exist. */ + DELETED = 'DELETED', +} + +export interface CreateInstancePool { + /** + * Pool name requested by the user. Pool name must be unique. Length must be between 1 and 100 + * characters. + */ + instancePoolName?: string | undefined; + /** Minimum number of idle instances to keep in the instance pool */ + minIdleInstances?: number | undefined; + /** + * 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?: number | undefined; + /** + * 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 | undefined; + /** + * 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 | undefined; + /** + * 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?: Record | undefined; + /** + * 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?: number | undefined; + /** + * 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?: boolean | undefined; + /** Defines the specification of the disks that will be attached to all spark containers. */ + diskSpec?: DiskSpec | undefined; + /** Custom Docker Image BYOC */ + preloadedDockerImages?: DockerImage[] | undefined; + /** + * 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 :method:clusters/sparkVersions API call. + */ + preloadedSparkVersions?: string[] | undefined; + /** + * Attributes related to instance pools running on Azure. + * If not specified at pool creation, a set of default values will be used. + */ + azureAttributes?: InstancePoolAzureAttributes | undefined; + /** + * 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 | undefined; + /** Flexible node type configuration for the pool. */ + nodeTypeFlexibility?: NodeTypeFlexibility | undefined; + /** + * For pools with node type flexibility (Fleet-V2), whether auto generated alternate node type ids + * are enabled. This field should not be true if node_type_flexibility is set. + * DEPRECATED: This field was deprecated before entering PuPr and should no longer be used. + * TODO(CJ-71514): Remove this field after sufficient time has passed for all clients to migrate. + */ + enableAutoAlternateNodeTypes?: boolean | undefined; + /** If set, what the configurable throughput (in Mb/s) for the remote disk is. Currently only supported for GCP HYPERDISK_BALANCED types. */ + remoteDiskThroughput?: number | undefined; + /** 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?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface CreateInstancePool_CustomTagsEntry { + /** + * The key of the tag. The key length must be between 1 and 127 UTF-8 characters, inclusive. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + key?: string | undefined; + /** + * The value of the tag. The value length must be less than or equal to 255 UTF-8 characters. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + value?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface CreateInstancePool_Response { + /** The ID of the created instance pool. */ + instancePoolId?: string | undefined; +} + +export interface DeleteInstancePool { + /** The instance pool to be terminated. */ + instancePoolId?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeleteInstancePool_Response {} + +/** + * 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. + */ +export interface DiskSpec { + /** The type of disks that will be launched with this cluster. */ + diskType?: DiskType | undefined; + /** + * 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?: number | undefined; + /** + * 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?: number | undefined; + diskIops?: number | undefined; + diskThroughput?: number | undefined; +} + +/** Describes the disk type. */ +export interface DiskType { + ebsVolumeType?: EbsVolumeType | undefined; + azureDiskVolumeType?: AzureDiskVolumeType | undefined; +} + +export interface DockerBasicAuth { + /** Name of the user */ + username?: string | undefined; + /** Password of the user */ + password?: string | undefined; +} + +export interface DockerImage { + /** URL of the docker image. */ + url?: string | undefined; + /** Basic auth with username and password */ + basicAuth?: DockerBasicAuth | undefined; +} + +export interface EditInstancePool { + /** Instance pool ID */ + instancePoolId?: string | undefined; + /** + * Pool name requested by the user. Pool name must be unique. Length must be between 1 and 100 + * characters. + */ + instancePoolName?: string | undefined; + /** Minimum number of idle instances to keep in the instance pool */ + minIdleInstances?: number | undefined; + /** + * 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?: number | undefined; + /** + * 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 | undefined; + /** + * 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 | undefined; + /** + * 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?: Record | undefined; + /** + * 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?: number | undefined; + /** + * 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?: boolean | undefined; + /** Defines the specification of the disks that will be attached to all spark containers. */ + diskSpec?: DiskSpec | undefined; + /** Custom Docker Image BYOC */ + preloadedDockerImages?: DockerImage[] | undefined; + /** + * 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 :method:clusters/sparkVersions API call. + */ + preloadedSparkVersions?: string[] | undefined; + /** + * Attributes related to instance pools running on Azure. + * If not specified at pool creation, a set of default values will be used. + */ + azureAttributes?: InstancePoolAzureAttributes | undefined; + /** + * 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 | undefined; + /** Flexible node type configuration for the pool. */ + nodeTypeFlexibility?: NodeTypeFlexibility | undefined; + /** + * For pools with node type flexibility (Fleet-V2), whether auto generated alternate node type ids + * are enabled. This field should not be true if node_type_flexibility is set. + * DEPRECATED: This field was deprecated before entering PuPr and should no longer be used. + * TODO(CJ-71514): Remove this field after sufficient time has passed for all clients to migrate. + */ + enableAutoAlternateNodeTypes?: boolean | undefined; + /** If set, what the configurable throughput (in Mb/s) for the remote disk is. Currently only supported for GCP HYPERDISK_BALANCED types. */ + remoteDiskThroughput?: number | undefined; + /** 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?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface EditInstancePool_CustomTagsEntry { + /** + * The key of the tag. The key length must be between 1 and 127 UTF-8 characters, inclusive. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + key?: string | undefined; + /** + * The value of the tag. The value length must be less than or equal to 255 UTF-8 characters. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + value?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface EditInstancePool_Response {} + +export interface GetInstancePool { + /** The canonical unique identifier for the instance pool. */ + instancePoolId?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetInstancePool_Response { + /** Usage statistics about the instance pool. */ + stats?: InstancePoolStats | undefined; + /** Status of failed pending instances in the pool. */ + status?: InstancePoolStatus | undefined; + /** Canonical unique identifier for the pool. */ + instancePoolId?: string | undefined; + /** + * Tags that are added by regardless of any ``custom_tags``, including: + * + * - Vendor: + * + * - InstancePoolCreator: + * + * - InstancePoolName: + * + * - InstancePoolId: + */ + defaultTags?: Record | undefined; + /** Current state of the instance pool. */ + state?: InstancePoolState | undefined; + /** + * Pool name requested by the user. Pool name must be unique. Length must be between 1 and 100 + * characters. + */ + instancePoolName?: string | undefined; + /** Minimum number of idle instances to keep in the instance pool */ + minIdleInstances?: number | undefined; + /** + * 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?: number | undefined; + /** + * 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 | undefined; + /** + * 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 | undefined; + /** + * 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?: Record | undefined; + /** + * 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?: number | undefined; + /** + * 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?: boolean | undefined; + /** Defines the specification of the disks that will be attached to all spark containers. */ + diskSpec?: DiskSpec | undefined; + /** Custom Docker Image BYOC */ + preloadedDockerImages?: DockerImage[] | undefined; + /** + * 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 :method:clusters/sparkVersions API call. + */ + preloadedSparkVersions?: string[] | undefined; + /** + * Attributes related to instance pools running on Azure. + * If not specified at pool creation, a set of default values will be used. + */ + azureAttributes?: InstancePoolAzureAttributes | undefined; + /** + * 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 | undefined; + /** Flexible node type configuration for the pool. */ + nodeTypeFlexibility?: NodeTypeFlexibility | undefined; + /** + * For pools with node type flexibility (Fleet-V2), whether auto generated alternate node type ids + * are enabled. This field should not be true if node_type_flexibility is set. + * DEPRECATED: This field was deprecated before entering PuPr and should no longer be used. + * TODO(CJ-71514): Remove this field after sufficient time has passed for all clients to migrate. + */ + enableAutoAlternateNodeTypes?: boolean | undefined; + /** If set, what the configurable throughput (in Mb/s) for the remote disk is. Currently only supported for GCP HYPERDISK_BALANCED types. */ + remoteDiskThroughput?: number | undefined; + /** 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?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetInstancePool_Response_CustomTagsEntry { + /** + * The key of the tag. The key length must be between 1 and 127 UTF-8 characters, inclusive. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + key?: string | undefined; + /** + * The value of the tag. The value length must be less than or equal to 255 UTF-8 characters. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + value?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetInstancePool_Response_DefaultTagsEntry { + /** + * The key of the tag. The key length must be between 1 and 127 UTF-8 characters, inclusive. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + key?: string | undefined; + /** + * The value of the tag. The value length must be less than or equal to 255 UTF-8 characters. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + value?: string | undefined; +} + +export interface InstancePoolAndStats { + /** Usage statistics about the instance pool. */ + stats?: InstancePoolStats | undefined; + /** Status of failed pending instances in the pool. */ + status?: InstancePoolStatus | undefined; + /** Canonical unique identifier for the pool. */ + instancePoolId?: string | undefined; + /** + * Tags that are added by regardless of any ``custom_tags``, including: + * + * - Vendor: + * + * - InstancePoolCreator: + * + * - InstancePoolName: + * + * - InstancePoolId: + */ + defaultTags?: Record | undefined; + /** Current state of the instance pool. */ + state?: InstancePoolState | undefined; + /** + * Pool name requested by the user. Pool name must be unique. Length must be between 1 and 100 + * characters. + */ + instancePoolName?: string | undefined; + /** Minimum number of idle instances to keep in the instance pool */ + minIdleInstances?: number | undefined; + /** + * 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?: number | undefined; + /** + * 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 | undefined; + /** + * 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 | undefined; + /** + * 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?: Record | undefined; + /** + * 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?: number | undefined; + /** + * 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?: boolean | undefined; + /** Defines the specification of the disks that will be attached to all spark containers. */ + diskSpec?: DiskSpec | undefined; + /** Custom Docker Image BYOC */ + preloadedDockerImages?: DockerImage[] | undefined; + /** + * 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 :method:clusters/sparkVersions API call. + */ + preloadedSparkVersions?: string[] | undefined; + /** + * Attributes related to instance pools running on Azure. + * If not specified at pool creation, a set of default values will be used. + */ + azureAttributes?: InstancePoolAzureAttributes | undefined; + /** + * 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 | undefined; + /** Flexible node type configuration for the pool. */ + nodeTypeFlexibility?: NodeTypeFlexibility | undefined; + /** + * For pools with node type flexibility (Fleet-V2), whether auto generated alternate node type ids + * are enabled. This field should not be true if node_type_flexibility is set. + * DEPRECATED: This field was deprecated before entering PuPr and should no longer be used. + * TODO(CJ-71514): Remove this field after sufficient time has passed for all clients to migrate. + */ + enableAutoAlternateNodeTypes?: boolean | undefined; + /** If set, what the configurable throughput (in Mb/s) for the remote disk is. Currently only supported for GCP HYPERDISK_BALANCED types. */ + remoteDiskThroughput?: number | undefined; + /** 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?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface InstancePoolAndStats_CustomTagsEntry { + /** + * The key of the tag. The key length must be between 1 and 127 UTF-8 characters, inclusive. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + key?: string | undefined; + /** + * The value of the tag. The value length must be less than or equal to 255 UTF-8 characters. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + value?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface InstancePoolAndStats_DefaultTagsEntry { + /** + * The key of the tag. The key length must be between 1 and 127 UTF-8 characters, inclusive. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + key?: string | undefined; + /** + * The value of the tag. The value length must be less than or equal to 255 UTF-8 characters. + * For a list of all restrictions, see the AWS docs here: + * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions + */ + value?: string | undefined; +} + +/** Attributes set during instance pool creation which are related to Amazon Web Services. */ +export interface InstancePoolAwsAttributes { + /** Availability type used for the spot nodes. */ + availability?: AwsAvailability | undefined; + /** + * 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. + */ + zoneId?: string | undefined; + /** + * 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. + */ + spotBidPricePercent?: number | undefined; + /** + * 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 | undefined; +} + +/** Attributes set during instance pool creation which are related to Azure. */ +export interface InstancePoolAzureAttributes { + /** Availability type used for the spot nodes. */ + availability?: AzureAvailability | undefined; + /** + * 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. + */ + spotBidMaxPrice?: number | undefined; +} + +/** Attributes set during instance pool creation which are related to GCP. */ +export interface InstancePoolGcpAttributes { + gcpAvailability?: GcpAvailability | undefined; + /** + * 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](https://cloud.google.com/compute/docs/disks/local-ssd#choose_number_local_ssds) + * for the supported number of local SSDs for each instance type. + */ + localSsdCount?: number | undefined; + /** + * 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 + * - 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. + */ + zoneId?: string | undefined; +} + +export interface InstancePoolStats { + /** Number of active instances in the pool that are part of a cluster. */ + usedCount?: number | undefined; + /** Number of active instances in the pool that are NOT part of a cluster. */ + idleCount?: number | undefined; + /** Number of pending instances in the pool that are part of a cluster. */ + pendingUsedCount?: number | undefined; + /** Number of pending instances in the pool that are NOT part of a cluster. */ + pendingIdleCount?: number | undefined; +} + +export interface InstancePoolStatus { + /** + * 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[] | undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ListInstancePools {} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListInstancePools_Response { + instancePools?: InstancePoolAndStats[] | undefined; +} + +/** Configuration for flexible node types, allowing fallback to alternate node types during cluster launch and upscale. */ +export interface NodeTypeFlexibility { + /** A list of node type IDs to use as fallbacks when the primary node type is unavailable. */ + alternateNodeTypeIds?: string[] | undefined; +} + +/** Error message of a failed pending instances */ +export interface PendingInstanceError { + instanceId?: string | undefined; + message?: string | undefined; +} + +export const unmarshalCreateInstancePoolSchema: z.ZodType = z + .object({ + instance_pool_name: z.string().optional(), + min_idle_instances: z.number().optional(), + max_capacity: z.number().optional(), + aws_attributes: z.lazy(() => unmarshalInstancePoolAwsAttributesSchema).optional(), + node_type_id: z.string().optional(), + custom_tags: z.record(z.string(), z.string()).optional(), + idle_instance_autotermination_minutes: z.number().optional(), + enable_elastic_disk: z.boolean().optional(), + disk_spec: z.lazy(() => unmarshalDiskSpecSchema).optional(), + preloaded_docker_images: z.array(z.lazy(() => unmarshalDockerImageSchema)).optional(), + preloaded_spark_versions: z.array(z.string()).optional(), + azure_attributes: z.lazy(() => unmarshalInstancePoolAzureAttributesSchema).optional(), + gcp_attributes: z.lazy(() => unmarshalInstancePoolGcpAttributesSchema).optional(), + node_type_flexibility: z.lazy(() => unmarshalNodeTypeFlexibilitySchema).optional(), + enable_auto_alternate_node_types: z.boolean().optional(), + remote_disk_throughput: z.number().optional(), + total_initial_remote_disk_size: z.number().optional(), + }) + .transform(d => ({ + instancePoolName: d.instance_pool_name, + minIdleInstances: d.min_idle_instances, + maxCapacity: d.max_capacity, + awsAttributes: d.aws_attributes, + nodeTypeId: d.node_type_id, + customTags: d.custom_tags, + idleInstanceAutoterminationMinutes: d.idle_instance_autotermination_minutes, + enableElasticDisk: d.enable_elastic_disk, + diskSpec: d.disk_spec, + preloadedDockerImages: d.preloaded_docker_images, + preloadedSparkVersions: d.preloaded_spark_versions, + azureAttributes: d.azure_attributes, + gcpAttributes: d.gcp_attributes, + nodeTypeFlexibility: d.node_type_flexibility, + enableAutoAlternateNodeTypes: d.enable_auto_alternate_node_types, + remoteDiskThroughput: d.remote_disk_throughput, + totalInitialRemoteDiskSize: d.total_initial_remote_disk_size, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateInstancePool_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateInstancePool_ResponseSchema: z.ZodType = z + .object({ + instance_pool_id: z.string().optional(), + }) + .transform(d => ({ + instancePoolId: d.instance_pool_id, + })); + +export const unmarshalDeleteInstancePoolSchema: z.ZodType = z + .object({ + instance_pool_id: z.string().optional(), + }) + .transform(d => ({ + instancePoolId: d.instance_pool_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeleteInstancePool_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDiskSpecSchema: z.ZodType = z + .object({ + disk_type: z.lazy(() => unmarshalDiskTypeSchema).optional(), + disk_count: z.number().optional(), + disk_size: z.number().optional(), + disk_iops: z.number().optional(), + disk_throughput: z.number().optional(), + }) + .transform(d => ({ + diskType: d.disk_type, + diskCount: d.disk_count, + diskSize: d.disk_size, + diskIops: d.disk_iops, + diskThroughput: d.disk_throughput, + })); + +export const unmarshalDiskTypeSchema: z.ZodType = z + .object({ + ebs_volume_type: z.enum(EbsVolumeType).optional(), + azure_disk_volume_type: z.enum(AzureDiskVolumeType).optional(), + }) + .transform(d => ({ + ebsVolumeType: d.ebs_volume_type, + azureDiskVolumeType: d.azure_disk_volume_type, + })); + +export const unmarshalDockerBasicAuthSchema: z.ZodType = z + .object({ + username: z.string().optional(), + password: z.string().optional(), + }) + .transform(d => ({ + username: d.username, + password: d.password, + })); + +export const unmarshalDockerImageSchema: z.ZodType = z + .object({ + url: z.string().optional(), + basic_auth: z.lazy(() => unmarshalDockerBasicAuthSchema).optional(), + }) + .transform(d => ({ + url: d.url, + basicAuth: d.basic_auth, + })); + +export const unmarshalEditInstancePoolSchema: z.ZodType = z + .object({ + instance_pool_id: z.string().optional(), + instance_pool_name: z.string().optional(), + min_idle_instances: z.number().optional(), + max_capacity: z.number().optional(), + aws_attributes: z.lazy(() => unmarshalInstancePoolAwsAttributesSchema).optional(), + node_type_id: z.string().optional(), + custom_tags: z.record(z.string(), z.string()).optional(), + idle_instance_autotermination_minutes: z.number().optional(), + enable_elastic_disk: z.boolean().optional(), + disk_spec: z.lazy(() => unmarshalDiskSpecSchema).optional(), + preloaded_docker_images: z.array(z.lazy(() => unmarshalDockerImageSchema)).optional(), + preloaded_spark_versions: z.array(z.string()).optional(), + azure_attributes: z.lazy(() => unmarshalInstancePoolAzureAttributesSchema).optional(), + gcp_attributes: z.lazy(() => unmarshalInstancePoolGcpAttributesSchema).optional(), + node_type_flexibility: z.lazy(() => unmarshalNodeTypeFlexibilitySchema).optional(), + enable_auto_alternate_node_types: z.boolean().optional(), + remote_disk_throughput: z.number().optional(), + total_initial_remote_disk_size: z.number().optional(), + }) + .transform(d => ({ + instancePoolId: d.instance_pool_id, + instancePoolName: d.instance_pool_name, + minIdleInstances: d.min_idle_instances, + maxCapacity: d.max_capacity, + awsAttributes: d.aws_attributes, + nodeTypeId: d.node_type_id, + customTags: d.custom_tags, + idleInstanceAutoterminationMinutes: d.idle_instance_autotermination_minutes, + enableElasticDisk: d.enable_elastic_disk, + diskSpec: d.disk_spec, + preloadedDockerImages: d.preloaded_docker_images, + preloadedSparkVersions: d.preloaded_spark_versions, + azureAttributes: d.azure_attributes, + gcpAttributes: d.gcp_attributes, + nodeTypeFlexibility: d.node_type_flexibility, + enableAutoAlternateNodeTypes: d.enable_auto_alternate_node_types, + remoteDiskThroughput: d.remote_disk_throughput, + totalInitialRemoteDiskSize: d.total_initial_remote_disk_size, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalEditInstancePool_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalEditInstancePool_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalGetInstancePoolSchema: z.ZodType = z + .object({ + instance_pool_id: z.string().optional(), + }) + .transform(d => ({ + instancePoolId: d.instance_pool_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetInstancePool_ResponseSchema: z.ZodType = z + .object({ + stats: z.lazy(() => unmarshalInstancePoolStatsSchema).optional(), + status: z.lazy(() => unmarshalInstancePoolStatusSchema).optional(), + instance_pool_id: z.string().optional(), + default_tags: z.record(z.string(), z.string()).optional(), + state: z.enum(InstancePoolState).optional(), + instance_pool_name: z.string().optional(), + min_idle_instances: z.number().optional(), + max_capacity: z.number().optional(), + aws_attributes: z.lazy(() => unmarshalInstancePoolAwsAttributesSchema).optional(), + node_type_id: z.string().optional(), + custom_tags: z.record(z.string(), z.string()).optional(), + idle_instance_autotermination_minutes: z.number().optional(), + enable_elastic_disk: z.boolean().optional(), + disk_spec: z.lazy(() => unmarshalDiskSpecSchema).optional(), + preloaded_docker_images: z.array(z.lazy(() => unmarshalDockerImageSchema)).optional(), + preloaded_spark_versions: z.array(z.string()).optional(), + azure_attributes: z.lazy(() => unmarshalInstancePoolAzureAttributesSchema).optional(), + gcp_attributes: z.lazy(() => unmarshalInstancePoolGcpAttributesSchema).optional(), + node_type_flexibility: z.lazy(() => unmarshalNodeTypeFlexibilitySchema).optional(), + enable_auto_alternate_node_types: z.boolean().optional(), + remote_disk_throughput: z.number().optional(), + total_initial_remote_disk_size: z.number().optional(), + }) + .transform(d => ({ + stats: d.stats, + status: d.status, + instancePoolId: d.instance_pool_id, + defaultTags: d.default_tags, + state: d.state, + instancePoolName: d.instance_pool_name, + minIdleInstances: d.min_idle_instances, + maxCapacity: d.max_capacity, + awsAttributes: d.aws_attributes, + nodeTypeId: d.node_type_id, + customTags: d.custom_tags, + idleInstanceAutoterminationMinutes: d.idle_instance_autotermination_minutes, + enableElasticDisk: d.enable_elastic_disk, + diskSpec: d.disk_spec, + preloadedDockerImages: d.preloaded_docker_images, + preloadedSparkVersions: d.preloaded_spark_versions, + azureAttributes: d.azure_attributes, + gcpAttributes: d.gcp_attributes, + nodeTypeFlexibility: d.node_type_flexibility, + enableAutoAlternateNodeTypes: d.enable_auto_alternate_node_types, + remoteDiskThroughput: d.remote_disk_throughput, + totalInitialRemoteDiskSize: d.total_initial_remote_disk_size, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetInstancePool_Response_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetInstancePool_Response_DefaultTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalInstancePoolAndStatsSchema: z.ZodType = z + .object({ + stats: z.lazy(() => unmarshalInstancePoolStatsSchema).optional(), + status: z.lazy(() => unmarshalInstancePoolStatusSchema).optional(), + instance_pool_id: z.string().optional(), + default_tags: z.record(z.string(), z.string()).optional(), + state: z.enum(InstancePoolState).optional(), + instance_pool_name: z.string().optional(), + min_idle_instances: z.number().optional(), + max_capacity: z.number().optional(), + aws_attributes: z.lazy(() => unmarshalInstancePoolAwsAttributesSchema).optional(), + node_type_id: z.string().optional(), + custom_tags: z.record(z.string(), z.string()).optional(), + idle_instance_autotermination_minutes: z.number().optional(), + enable_elastic_disk: z.boolean().optional(), + disk_spec: z.lazy(() => unmarshalDiskSpecSchema).optional(), + preloaded_docker_images: z.array(z.lazy(() => unmarshalDockerImageSchema)).optional(), + preloaded_spark_versions: z.array(z.string()).optional(), + azure_attributes: z.lazy(() => unmarshalInstancePoolAzureAttributesSchema).optional(), + gcp_attributes: z.lazy(() => unmarshalInstancePoolGcpAttributesSchema).optional(), + node_type_flexibility: z.lazy(() => unmarshalNodeTypeFlexibilitySchema).optional(), + enable_auto_alternate_node_types: z.boolean().optional(), + remote_disk_throughput: z.number().optional(), + total_initial_remote_disk_size: z.number().optional(), + }) + .transform(d => ({ + stats: d.stats, + status: d.status, + instancePoolId: d.instance_pool_id, + defaultTags: d.default_tags, + state: d.state, + instancePoolName: d.instance_pool_name, + minIdleInstances: d.min_idle_instances, + maxCapacity: d.max_capacity, + awsAttributes: d.aws_attributes, + nodeTypeId: d.node_type_id, + customTags: d.custom_tags, + idleInstanceAutoterminationMinutes: d.idle_instance_autotermination_minutes, + enableElasticDisk: d.enable_elastic_disk, + diskSpec: d.disk_spec, + preloadedDockerImages: d.preloaded_docker_images, + preloadedSparkVersions: d.preloaded_spark_versions, + azureAttributes: d.azure_attributes, + gcpAttributes: d.gcp_attributes, + nodeTypeFlexibility: d.node_type_flexibility, + enableAutoAlternateNodeTypes: d.enable_auto_alternate_node_types, + remoteDiskThroughput: d.remote_disk_throughput, + totalInitialRemoteDiskSize: d.total_initial_remote_disk_size, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalInstancePoolAndStats_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalInstancePoolAndStats_DefaultTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalInstancePoolAwsAttributesSchema: z.ZodType = z + .object({ + availability: z.enum(AwsAvailability).optional(), + zone_id: z.string().optional(), + spot_bid_price_percent: z.number().optional(), + instance_profile_arn: z.string().optional(), + }) + .transform(d => ({ + availability: d.availability, + zoneId: d.zone_id, + spotBidPricePercent: d.spot_bid_price_percent, + instanceProfileArn: d.instance_profile_arn, + })); + +export const unmarshalInstancePoolAzureAttributesSchema: z.ZodType = z + .object({ + availability: z.enum(AzureAvailability).optional(), + spot_bid_max_price: z.number().optional(), + }) + .transform(d => ({ + availability: d.availability, + spotBidMaxPrice: d.spot_bid_max_price, + })); + +export const unmarshalInstancePoolGcpAttributesSchema: z.ZodType = z + .object({ + gcp_availability: z.enum(GcpAvailability).optional(), + local_ssd_count: z.number().optional(), + zone_id: z.string().optional(), + }) + .transform(d => ({ + gcpAvailability: d.gcp_availability, + localSsdCount: d.local_ssd_count, + zoneId: d.zone_id, + })); + +export const unmarshalInstancePoolStatsSchema: z.ZodType = z + .object({ + used_count: z.number().optional(), + idle_count: z.number().optional(), + pending_used_count: z.number().optional(), + pending_idle_count: z.number().optional(), + }) + .transform(d => ({ + usedCount: d.used_count, + idleCount: d.idle_count, + pendingUsedCount: d.pending_used_count, + pendingIdleCount: d.pending_idle_count, + })); + +export const unmarshalInstancePoolStatusSchema: z.ZodType = z + .object({ + pending_instance_errors: z.array(z.lazy(() => unmarshalPendingInstanceErrorSchema)).optional(), + }) + .transform(d => ({ + pendingInstanceErrors: d.pending_instance_errors, + })); + +export const unmarshalListInstancePoolsSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListInstancePools_ResponseSchema: z.ZodType = z + .object({ + instance_pools: z.array(z.lazy(() => unmarshalInstancePoolAndStatsSchema)).optional(), + }) + .transform(d => ({ + instancePools: d.instance_pools, + })); + +export const unmarshalNodeTypeFlexibilitySchema: z.ZodType = z + .object({ + alternate_node_type_ids: z.array(z.string()).optional(), + }) + .transform(d => ({ + alternateNodeTypeIds: d.alternate_node_type_ids, + })); + +export const unmarshalPendingInstanceErrorSchema: z.ZodType = z + .object({ + instance_id: z.string().optional(), + message: z.string().optional(), + }) + .transform(d => ({ + instanceId: d.instance_id, + message: d.message, + })); + +export const marshalCreateInstancePoolSchema: z.ZodType = z + .object({ + instancePoolName: z.string().optional(), + minIdleInstances: z.number().optional(), + maxCapacity: z.number().optional(), + awsAttributes: z.lazy(() => marshalInstancePoolAwsAttributesSchema).optional(), + nodeTypeId: z.string().optional(), + customTags: z.record(z.string(), z.string()).optional(), + idleInstanceAutoterminationMinutes: z.number().optional(), + enableElasticDisk: z.boolean().optional(), + diskSpec: z.lazy(() => marshalDiskSpecSchema).optional(), + preloadedDockerImages: z.array(z.lazy(() => marshalDockerImageSchema)).optional(), + preloadedSparkVersions: z.array(z.string()).optional(), + azureAttributes: z.lazy(() => marshalInstancePoolAzureAttributesSchema).optional(), + gcpAttributes: z.lazy(() => marshalInstancePoolGcpAttributesSchema).optional(), + nodeTypeFlexibility: z.lazy(() => marshalNodeTypeFlexibilitySchema).optional(), + enableAutoAlternateNodeTypes: z.boolean().optional(), + remoteDiskThroughput: z.number().optional(), + totalInitialRemoteDiskSize: z.number().optional(), + }) + .transform(d => ({ + instance_pool_name: d.instancePoolName, + min_idle_instances: d.minIdleInstances, + max_capacity: d.maxCapacity, + aws_attributes: d.awsAttributes, + node_type_id: d.nodeTypeId, + custom_tags: d.customTags, + idle_instance_autotermination_minutes: d.idleInstanceAutoterminationMinutes, + enable_elastic_disk: d.enableElasticDisk, + disk_spec: d.diskSpec, + preloaded_docker_images: d.preloadedDockerImages, + preloaded_spark_versions: d.preloadedSparkVersions, + azure_attributes: d.azureAttributes, + gcp_attributes: d.gcpAttributes, + node_type_flexibility: d.nodeTypeFlexibility, + enable_auto_alternate_node_types: d.enableAutoAlternateNodeTypes, + remote_disk_throughput: d.remoteDiskThroughput, + total_initial_remote_disk_size: d.totalInitialRemoteDiskSize, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreateInstancePool_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreateInstancePool_ResponseSchema: z.ZodType = z + .object({ + instancePoolId: z.string().optional(), + }) + .transform(d => ({ + instance_pool_id: d.instancePoolId, + })); + +export const marshalDeleteInstancePoolSchema: z.ZodType = z + .object({ + instancePoolId: z.string().optional(), + }) + .transform(d => ({ + instance_pool_id: d.instancePoolId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeleteInstancePool_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalDiskSpecSchema: z.ZodType = z + .object({ + diskType: z.lazy(() => marshalDiskTypeSchema).optional(), + diskCount: z.number().optional(), + diskSize: z.number().optional(), + diskIops: z.number().optional(), + diskThroughput: z.number().optional(), + }) + .transform(d => ({ + disk_type: d.diskType, + disk_count: d.diskCount, + disk_size: d.diskSize, + disk_iops: d.diskIops, + disk_throughput: d.diskThroughput, + })); + +export const marshalDiskTypeSchema: z.ZodType = z + .object({ + ebsVolumeType: z.enum(EbsVolumeType).optional(), + azureDiskVolumeType: z.enum(AzureDiskVolumeType).optional(), + }) + .transform(d => ({ + ebs_volume_type: d.ebsVolumeType, + azure_disk_volume_type: d.azureDiskVolumeType, + })); + +export const marshalDockerBasicAuthSchema: z.ZodType = z + .object({ + username: z.string().optional(), + password: z.string().optional(), + }) + .transform(d => ({ + username: d.username, + password: d.password, + })); + +export const marshalDockerImageSchema: z.ZodType = z + .object({ + url: z.string().optional(), + basicAuth: z.lazy(() => marshalDockerBasicAuthSchema).optional(), + }) + .transform(d => ({ + url: d.url, + basic_auth: d.basicAuth, + })); + +export const marshalEditInstancePoolSchema: z.ZodType = z + .object({ + instancePoolId: z.string().optional(), + instancePoolName: z.string().optional(), + minIdleInstances: z.number().optional(), + maxCapacity: z.number().optional(), + awsAttributes: z.lazy(() => marshalInstancePoolAwsAttributesSchema).optional(), + nodeTypeId: z.string().optional(), + customTags: z.record(z.string(), z.string()).optional(), + idleInstanceAutoterminationMinutes: z.number().optional(), + enableElasticDisk: z.boolean().optional(), + diskSpec: z.lazy(() => marshalDiskSpecSchema).optional(), + preloadedDockerImages: z.array(z.lazy(() => marshalDockerImageSchema)).optional(), + preloadedSparkVersions: z.array(z.string()).optional(), + azureAttributes: z.lazy(() => marshalInstancePoolAzureAttributesSchema).optional(), + gcpAttributes: z.lazy(() => marshalInstancePoolGcpAttributesSchema).optional(), + nodeTypeFlexibility: z.lazy(() => marshalNodeTypeFlexibilitySchema).optional(), + enableAutoAlternateNodeTypes: z.boolean().optional(), + remoteDiskThroughput: z.number().optional(), + totalInitialRemoteDiskSize: z.number().optional(), + }) + .transform(d => ({ + instance_pool_id: d.instancePoolId, + instance_pool_name: d.instancePoolName, + min_idle_instances: d.minIdleInstances, + max_capacity: d.maxCapacity, + aws_attributes: d.awsAttributes, + node_type_id: d.nodeTypeId, + custom_tags: d.customTags, + idle_instance_autotermination_minutes: d.idleInstanceAutoterminationMinutes, + enable_elastic_disk: d.enableElasticDisk, + disk_spec: d.diskSpec, + preloaded_docker_images: d.preloadedDockerImages, + preloaded_spark_versions: d.preloadedSparkVersions, + azure_attributes: d.azureAttributes, + gcp_attributes: d.gcpAttributes, + node_type_flexibility: d.nodeTypeFlexibility, + enable_auto_alternate_node_types: d.enableAutoAlternateNodeTypes, + remote_disk_throughput: d.remoteDiskThroughput, + total_initial_remote_disk_size: d.totalInitialRemoteDiskSize, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalEditInstancePool_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalEditInstancePool_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalGetInstancePoolSchema: z.ZodType = z + .object({ + instancePoolId: z.string().optional(), + }) + .transform(d => ({ + instance_pool_id: d.instancePoolId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetInstancePool_ResponseSchema: z.ZodType = z + .object({ + stats: z.lazy(() => marshalInstancePoolStatsSchema).optional(), + status: z.lazy(() => marshalInstancePoolStatusSchema).optional(), + instancePoolId: z.string().optional(), + defaultTags: z.record(z.string(), z.string()).optional(), + state: z.enum(InstancePoolState).optional(), + instancePoolName: z.string().optional(), + minIdleInstances: z.number().optional(), + maxCapacity: z.number().optional(), + awsAttributes: z.lazy(() => marshalInstancePoolAwsAttributesSchema).optional(), + nodeTypeId: z.string().optional(), + customTags: z.record(z.string(), z.string()).optional(), + idleInstanceAutoterminationMinutes: z.number().optional(), + enableElasticDisk: z.boolean().optional(), + diskSpec: z.lazy(() => marshalDiskSpecSchema).optional(), + preloadedDockerImages: z.array(z.lazy(() => marshalDockerImageSchema)).optional(), + preloadedSparkVersions: z.array(z.string()).optional(), + azureAttributes: z.lazy(() => marshalInstancePoolAzureAttributesSchema).optional(), + gcpAttributes: z.lazy(() => marshalInstancePoolGcpAttributesSchema).optional(), + nodeTypeFlexibility: z.lazy(() => marshalNodeTypeFlexibilitySchema).optional(), + enableAutoAlternateNodeTypes: z.boolean().optional(), + remoteDiskThroughput: z.number().optional(), + totalInitialRemoteDiskSize: z.number().optional(), + }) + .transform(d => ({ + stats: d.stats, + status: d.status, + instance_pool_id: d.instancePoolId, + default_tags: d.defaultTags, + state: d.state, + instance_pool_name: d.instancePoolName, + min_idle_instances: d.minIdleInstances, + max_capacity: d.maxCapacity, + aws_attributes: d.awsAttributes, + node_type_id: d.nodeTypeId, + custom_tags: d.customTags, + idle_instance_autotermination_minutes: d.idleInstanceAutoterminationMinutes, + enable_elastic_disk: d.enableElasticDisk, + disk_spec: d.diskSpec, + preloaded_docker_images: d.preloadedDockerImages, + preloaded_spark_versions: d.preloadedSparkVersions, + azure_attributes: d.azureAttributes, + gcp_attributes: d.gcpAttributes, + node_type_flexibility: d.nodeTypeFlexibility, + enable_auto_alternate_node_types: d.enableAutoAlternateNodeTypes, + remote_disk_throughput: d.remoteDiskThroughput, + total_initial_remote_disk_size: d.totalInitialRemoteDiskSize, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetInstancePool_Response_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetInstancePool_Response_DefaultTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const marshalInstancePoolAndStatsSchema: z.ZodType = z + .object({ + stats: z.lazy(() => marshalInstancePoolStatsSchema).optional(), + status: z.lazy(() => marshalInstancePoolStatusSchema).optional(), + instancePoolId: z.string().optional(), + defaultTags: z.record(z.string(), z.string()).optional(), + state: z.enum(InstancePoolState).optional(), + instancePoolName: z.string().optional(), + minIdleInstances: z.number().optional(), + maxCapacity: z.number().optional(), + awsAttributes: z.lazy(() => marshalInstancePoolAwsAttributesSchema).optional(), + nodeTypeId: z.string().optional(), + customTags: z.record(z.string(), z.string()).optional(), + idleInstanceAutoterminationMinutes: z.number().optional(), + enableElasticDisk: z.boolean().optional(), + diskSpec: z.lazy(() => marshalDiskSpecSchema).optional(), + preloadedDockerImages: z.array(z.lazy(() => marshalDockerImageSchema)).optional(), + preloadedSparkVersions: z.array(z.string()).optional(), + azureAttributes: z.lazy(() => marshalInstancePoolAzureAttributesSchema).optional(), + gcpAttributes: z.lazy(() => marshalInstancePoolGcpAttributesSchema).optional(), + nodeTypeFlexibility: z.lazy(() => marshalNodeTypeFlexibilitySchema).optional(), + enableAutoAlternateNodeTypes: z.boolean().optional(), + remoteDiskThroughput: z.number().optional(), + totalInitialRemoteDiskSize: z.number().optional(), + }) + .transform(d => ({ + stats: d.stats, + status: d.status, + instance_pool_id: d.instancePoolId, + default_tags: d.defaultTags, + state: d.state, + instance_pool_name: d.instancePoolName, + min_idle_instances: d.minIdleInstances, + max_capacity: d.maxCapacity, + aws_attributes: d.awsAttributes, + node_type_id: d.nodeTypeId, + custom_tags: d.customTags, + idle_instance_autotermination_minutes: d.idleInstanceAutoterminationMinutes, + enable_elastic_disk: d.enableElasticDisk, + disk_spec: d.diskSpec, + preloaded_docker_images: d.preloadedDockerImages, + preloaded_spark_versions: d.preloadedSparkVersions, + azure_attributes: d.azureAttributes, + gcp_attributes: d.gcpAttributes, + node_type_flexibility: d.nodeTypeFlexibility, + enable_auto_alternate_node_types: d.enableAutoAlternateNodeTypes, + remote_disk_throughput: d.remoteDiskThroughput, + total_initial_remote_disk_size: d.totalInitialRemoteDiskSize, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalInstancePoolAndStats_CustomTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalInstancePoolAndStats_DefaultTagsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const marshalInstancePoolAwsAttributesSchema: z.ZodType = z + .object({ + availability: z.enum(AwsAvailability).optional(), + zoneId: z.string().optional(), + spotBidPricePercent: z.number().optional(), + instanceProfileArn: z.string().optional(), + }) + .transform(d => ({ + availability: d.availability, + zone_id: d.zoneId, + spot_bid_price_percent: d.spotBidPricePercent, + instance_profile_arn: d.instanceProfileArn, + })); + +export const marshalInstancePoolAzureAttributesSchema: z.ZodType = z + .object({ + availability: z.enum(AzureAvailability).optional(), + spotBidMaxPrice: z.number().optional(), + }) + .transform(d => ({ + availability: d.availability, + spot_bid_max_price: d.spotBidMaxPrice, + })); + +export const marshalInstancePoolGcpAttributesSchema: z.ZodType = z + .object({ + gcpAvailability: z.enum(GcpAvailability).optional(), + localSsdCount: z.number().optional(), + zoneId: z.string().optional(), + }) + .transform(d => ({ + gcp_availability: d.gcpAvailability, + local_ssd_count: d.localSsdCount, + zone_id: d.zoneId, + })); + +export const marshalInstancePoolStatsSchema: z.ZodType = z + .object({ + usedCount: z.number().optional(), + idleCount: z.number().optional(), + pendingUsedCount: z.number().optional(), + pendingIdleCount: z.number().optional(), + }) + .transform(d => ({ + used_count: d.usedCount, + idle_count: d.idleCount, + pending_used_count: d.pendingUsedCount, + pending_idle_count: d.pendingIdleCount, + })); + +export const marshalInstancePoolStatusSchema: z.ZodType = z + .object({ + pendingInstanceErrors: z.array(z.lazy(() => marshalPendingInstanceErrorSchema)).optional(), + }) + .transform(d => ({ + pending_instance_errors: d.pendingInstanceErrors, + })); + +export const marshalListInstancePoolsSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListInstancePools_ResponseSchema: z.ZodType = z + .object({ + instancePools: z.array(z.lazy(() => marshalInstancePoolAndStatsSchema)).optional(), + }) + .transform(d => ({ + instance_pools: d.instancePools, + })); + +export const marshalNodeTypeFlexibilitySchema: z.ZodType = z + .object({ + alternateNodeTypeIds: z.array(z.string()).optional(), + }) + .transform(d => ({ + alternate_node_type_ids: d.alternateNodeTypeIds, + })); + +export const marshalPendingInstanceErrorSchema: z.ZodType = z + .object({ + instanceId: z.string().optional(), + message: z.string().optional(), + }) + .transform(d => ({ + instance_id: d.instanceId, + message: d.message, + })); diff --git a/packages/instancepools/src/v2/utils.ts b/packages/instancepools/src/v2/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/instancepools/src/v2/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/instancepools/tsconfig.json b/packages/instancepools/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/instancepools/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/instanceprofiles/package.json b/packages/instanceprofiles/package.json new file mode 100644 index 00000000..e37f9c9a --- /dev/null +++ b/packages/instanceprofiles/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-instanceprofiles", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v2": { + "types": "./dist/v2/index.d.ts", + "import": "./dist/v2/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/instanceprofiles/src/v2/client.ts b/packages/instanceprofiles/src/v2/client.ts new file mode 100644 index 00000000..4a28c3fa --- /dev/null +++ b/packages/instanceprofiles/src/v2/client.ts @@ -0,0 +1,138 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + AddInstanceProfile, + AddInstanceProfile_Response, + EditInstanceProfile, + EditInstanceProfile_Response, + ListInstanceProfiles, + ListInstanceProfiles_Response, + RemoveInstanceProfile, + RemoveInstanceProfile_Response, +} from './model'; +import { + marshalAddInstanceProfileSchema, + marshalEditInstanceProfileSchema, + marshalRemoveInstanceProfileSchema, + unmarshalAddInstanceProfile_ResponseSchema, + unmarshalEditInstanceProfile_ResponseSchema, + unmarshalListInstanceProfiles_ResponseSchema, + unmarshalRemoveInstanceProfile_ResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** + * Registers an instance profile in . In the UI, you can then give users the permission + * to use this instance profile when launching clusters. + * + * This API is only available to admin users. + */ + async addInstanceProfile(signal: AbortSignal | undefined, req: AddInstanceProfile, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-profiles/add`; + const body = marshalRequest(req, marshalAddInstanceProfileSchema); + let resp: AddInstanceProfile_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalAddInstanceProfile_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * The only supported field to change is the optional IAM role ARN associated with + * the instance profile. It is required to specify the IAM role ARN if both of + * the following are true: + * + * * Your role name and instance profile name do not match. The name is the part + * after the last slash in each ARN. + * * You want to use the instance profile with [Databricks SQL Serverless](/sql/admin/serverless.html). + * + * To understand where these fields are in the AWS console, see + * [Enable serverless SQL warehouses](/sql/admin/serverless.html). + * + * This API is only available to admin users. + */ + async editInstanceProfile(signal: AbortSignal | undefined, req: EditInstanceProfile, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-profiles/edit`; + const body = marshalRequest(req, marshalEditInstanceProfileSchema); + let resp: EditInstanceProfile_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalEditInstanceProfile_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * List the instance profiles that the calling user can use to launch a cluster. + * + * This API is available to all users. + */ + async listInstanceProfiles(signal: AbortSignal | undefined, _req: ListInstanceProfiles, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-profiles/list`; + let resp: ListInstanceProfiles_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListInstanceProfiles_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Remove the instance profile with the provided ARN. + * Existing clusters with this instance profile will continue to function. + * + * This API is only accessible to admin users. + */ + async removeInstanceProfile(signal: AbortSignal | undefined, req: RemoveInstanceProfile, options?: Options): Promise { + const url = `${this.host}/api/2.0/instance-profiles/remove`; + const body = marshalRequest(req, marshalRemoveInstanceProfileSchema); + let resp: RemoveInstanceProfile_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalRemoveInstanceProfile_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/instanceprofiles/src/v2/index.ts b/packages/instanceprofiles/src/v2/index.ts new file mode 100644 index 00000000..31e0a756 --- /dev/null +++ b/packages/instanceprofiles/src/v2/index.ts @@ -0,0 +1,19 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { +} from './model'; + +export type { + AddInstanceProfile, + AddInstanceProfile_Response, + EditInstanceProfile, + EditInstanceProfile_Response, + InstanceProfile, + ListInstanceProfiles, + ListInstanceProfiles_Response, + RemoveInstanceProfile, + RemoveInstanceProfile_Response, +} from './model'; diff --git a/packages/instanceprofiles/src/v2/model.ts b/packages/instanceprofiles/src/v2/model.ts new file mode 100644 index 00000000..ee28d2af --- /dev/null +++ b/packages/instanceprofiles/src/v2/model.ts @@ -0,0 +1,249 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +export interface AddInstanceProfile { + /** + * 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?: boolean | undefined; + /** The AWS ARN of the instance profile to register with . This field is required. */ + instanceProfileArn?: string | undefined; + /** + * 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?: boolean | undefined; + /** + * 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 | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface AddInstanceProfile_Response {} + +export interface EditInstanceProfile { + /** The AWS ARN of the instance profile to register with . This field is required. */ + instanceProfileArn?: string | undefined; + /** + * 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?: boolean | undefined; + /** + * 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 | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface EditInstanceProfile_Response {} + +export interface InstanceProfile { + /** The AWS ARN of the instance profile to register with . This field is required. */ + instanceProfileArn?: string | undefined; + /** + * 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?: boolean | undefined; + /** + * 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 | undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ListInstanceProfiles {} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListInstanceProfiles_Response { + /** A list of instance profiles that the user can access. */ + instanceProfiles?: InstanceProfile[] | undefined; +} + +export interface RemoveInstanceProfile { + /** The ARN of the instance profile to remove. This field is required. */ + instanceProfileArn?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface RemoveInstanceProfile_Response {} + +export const unmarshalAddInstanceProfileSchema: z.ZodType = z + .object({ + skip_validation: z.boolean().optional(), + instance_profile_arn: z.string().optional(), + is_meta_instance_profile: z.boolean().optional(), + iam_role_arn: z.string().optional(), + }) + .transform(d => ({ + skipValidation: d.skip_validation, + instanceProfileArn: d.instance_profile_arn, + isMetaInstanceProfile: d.is_meta_instance_profile, + iamRoleArn: d.iam_role_arn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalAddInstanceProfile_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalEditInstanceProfileSchema: z.ZodType = z + .object({ + instance_profile_arn: z.string().optional(), + is_meta_instance_profile: z.boolean().optional(), + iam_role_arn: z.string().optional(), + }) + .transform(d => ({ + instanceProfileArn: d.instance_profile_arn, + isMetaInstanceProfile: d.is_meta_instance_profile, + iamRoleArn: d.iam_role_arn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalEditInstanceProfile_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalInstanceProfileSchema: z.ZodType = z + .object({ + instance_profile_arn: z.string().optional(), + is_meta_instance_profile: z.boolean().optional(), + iam_role_arn: z.string().optional(), + }) + .transform(d => ({ + instanceProfileArn: d.instance_profile_arn, + isMetaInstanceProfile: d.is_meta_instance_profile, + iamRoleArn: d.iam_role_arn, + })); + +export const unmarshalListInstanceProfilesSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListInstanceProfiles_ResponseSchema: z.ZodType = z + .object({ + instance_profiles: z.array(z.lazy(() => unmarshalInstanceProfileSchema)).optional(), + }) + .transform(d => ({ + instanceProfiles: d.instance_profiles, + })); + +export const unmarshalRemoveInstanceProfileSchema: z.ZodType = z + .object({ + instance_profile_arn: z.string().optional(), + }) + .transform(d => ({ + instanceProfileArn: d.instance_profile_arn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalRemoveInstanceProfile_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalAddInstanceProfileSchema: z.ZodType = z + .object({ + skipValidation: z.boolean().optional(), + instanceProfileArn: z.string().optional(), + isMetaInstanceProfile: z.boolean().optional(), + iamRoleArn: z.string().optional(), + }) + .transform(d => ({ + skip_validation: d.skipValidation, + instance_profile_arn: d.instanceProfileArn, + is_meta_instance_profile: d.isMetaInstanceProfile, + iam_role_arn: d.iamRoleArn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalAddInstanceProfile_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalEditInstanceProfileSchema: z.ZodType = z + .object({ + instanceProfileArn: z.string().optional(), + isMetaInstanceProfile: z.boolean().optional(), + iamRoleArn: z.string().optional(), + }) + .transform(d => ({ + instance_profile_arn: d.instanceProfileArn, + is_meta_instance_profile: d.isMetaInstanceProfile, + iam_role_arn: d.iamRoleArn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalEditInstanceProfile_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalInstanceProfileSchema: z.ZodType = z + .object({ + instanceProfileArn: z.string().optional(), + isMetaInstanceProfile: z.boolean().optional(), + iamRoleArn: z.string().optional(), + }) + .transform(d => ({ + instance_profile_arn: d.instanceProfileArn, + is_meta_instance_profile: d.isMetaInstanceProfile, + iam_role_arn: d.iamRoleArn, + })); + +export const marshalListInstanceProfilesSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListInstanceProfiles_ResponseSchema: z.ZodType = z + .object({ + instanceProfiles: z.array(z.lazy(() => marshalInstanceProfileSchema)).optional(), + }) + .transform(d => ({ + instance_profiles: d.instanceProfiles, + })); + +export const marshalRemoveInstanceProfileSchema: z.ZodType = z + .object({ + instanceProfileArn: z.string().optional(), + }) + .transform(d => ({ + instance_profile_arn: d.instanceProfileArn, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalRemoveInstanceProfile_ResponseSchema: z.ZodType = z + .object({ + }); diff --git a/packages/instanceprofiles/src/v2/utils.ts b/packages/instanceprofiles/src/v2/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/instanceprofiles/src/v2/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/instanceprofiles/tsconfig.json b/packages/instanceprofiles/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/instanceprofiles/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/materializedfeatures/package.json b/packages/materializedfeatures/package.json index 850532aa..388f2aba 100644 --- a/packages/materializedfeatures/package.json +++ b/packages/materializedfeatures/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/materializedfeatures/src/v1/client.ts b/packages/materializedfeatures/src/v1/client.ts index fac8a34b..636e5d69 100644 --- a/packages/materializedfeatures/src/v1/client.ts +++ b/packages/materializedfeatures/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateFeatureTagRequest, DeleteFeatureTagRequest, @@ -46,21 +41,13 @@ export class Client { } /** Creates a FeatureTag. */ - async createFeatureTag( - signal: AbortSignal | undefined, - req: CreateFeatureTagRequest, - options?: Options - ): Promise { + async createFeatureTag(signal: AbortSignal | undefined, req: CreateFeatureTagRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/feature-tables/${req.tableName ?? ''}/features/${req.featureName ?? ''}/tags`; const body = marshalRequest(req.featureTag, marshalFeatureTagSchema); let resp: FeatureTag | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureTagSchema); }; await execute(signal, call, options); @@ -71,38 +58,22 @@ export class Client { } /** Deletes a FeatureTag. */ - async deleteFeatureTag( - signal: AbortSignal | undefined, - req: DeleteFeatureTagRequest, - options?: Options - ): Promise { + async deleteFeatureTag(signal: AbortSignal | undefined, req: DeleteFeatureTagRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/feature-tables/${req.tableName ?? ''}/features/${req.featureName ?? ''}/tags/${req.key ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Get Feature Lineage. */ - async getFeatureLineage( - signal: AbortSignal | undefined, - req: GetFeatureLineageRequest, - options?: Options - ): Promise { + async getFeatureLineage(signal: AbortSignal | undefined, req: GetFeatureLineageRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/feature-tables/${req.tableName ?? ''}/features/${req.featureName ?? ''}/lineage`; let resp: FeatureLineage | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureLineageSchema); }; await execute(signal, call, options); @@ -113,20 +84,12 @@ export class Client { } /** Gets a FeatureTag. */ - async getFeatureTag( - signal: AbortSignal | undefined, - req: GetFeatureTagRequest, - options?: Options - ): Promise { + async getFeatureTag(signal: AbortSignal | undefined, req: GetFeatureTagRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/feature-tables/${req.tableName ?? ''}/features/${req.featureName ?? ''}/tags/${req.key ?? ''}`; let resp: FeatureTag | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureTagSchema); }; await execute(signal, call, options); @@ -137,11 +100,7 @@ export class Client { } /** Lists FeatureTags. */ - async listFeatureTags( - signal: AbortSignal | undefined, - req: ListFeatureTagsRequest, - options?: Options - ): Promise { + async listFeatureTags(signal: AbortSignal | undefined, req: ListFeatureTagsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/feature-tables/${req.tableName ?? ''}/features/${req.featureName ?? ''}/tags`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -155,11 +114,7 @@ export class Client { let resp: ListFeatureTagsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListFeatureTagsResponseSchema); }; await execute(signal, call, options); @@ -169,11 +124,8 @@ export class Client { return resp; } - async *listFeatureTagsIter( - signal: AbortSignal | undefined, - req: ListFeatureTagsRequest, - options?: Options - ): AsyncGenerator { + + async *listFeatureTagsIter(signal: AbortSignal | undefined, req: ListFeatureTagsRequest, options?: Options): AsyncGenerator { const pageReq: ListFeatureTagsRequest = {...req}; for (;;) { const resp = await this.listFeatureTags(signal, pageReq, options); @@ -187,16 +139,13 @@ export class Client { } } + /** Updates a FeatureTag. */ - async updateFeatureTag( - signal: AbortSignal | undefined, - req: UpdateFeatureTagRequest, - options?: Options - ): Promise { + async updateFeatureTag(signal: AbortSignal | undefined, req: UpdateFeatureTagRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/feature-store/feature-tables/${req.tableName ?? ''}/features/${req.featureName ?? ''}/tags/${req.featureTag?.key ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -204,11 +153,7 @@ export class Client { let resp: FeatureTag | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalFeatureTagSchema); }; await execute(signal, call, options); diff --git a/packages/materializedfeatures/src/v1/index.ts b/packages/materializedfeatures/src/v1/index.ts index 12ce40bc..69dd1c6d 100644 --- a/packages/materializedfeatures/src/v1/index.ts +++ b/packages/materializedfeatures/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { CreateFeatureTagRequest, diff --git a/packages/materializedfeatures/src/v1/model.ts b/packages/materializedfeatures/src/v1/model.ts index 7c00c82e..b58b09c5 100644 --- a/packages/materializedfeatures/src/v1/model.ts +++ b/packages/materializedfeatures/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** Request message for CreateFeatureTag. */ @@ -93,46 +94,38 @@ export interface UpdateFeatureTagRequest { featureName?: string | undefined; featureTag?: FeatureTag | undefined; /** The list of fields to update. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } -export const unmarshalCreateFeatureTagRequestSchema: z.ZodType = - z - .object({ - table_name: z.string().optional(), - feature_name: z.string().optional(), - feature_tag: z.lazy(() => unmarshalFeatureTagSchema).optional(), - }) - .transform(d => ({ - tableName: d.table_name, - featureName: d.feature_name, - featureTag: d.feature_tag, - })); - -export const unmarshalDeleteFeatureTagRequestSchema: z.ZodType = - z - .object({ - table_name: z.string().optional(), - feature_name: z.string().optional(), - key: z.string().optional(), - }) - .transform(d => ({ - tableName: d.table_name, - featureName: d.feature_name, - key: d.key, - })); +export const unmarshalCreateFeatureTagRequestSchema: z.ZodType = z + .object({ + table_name: z.string().optional(), + feature_name: z.string().optional(), + feature_tag: z.lazy(() => unmarshalFeatureTagSchema).optional(), + }) + .transform(d => ({ + tableName: d.table_name, + featureName: d.feature_name, + featureTag: d.feature_tag, + })); + +export const unmarshalDeleteFeatureTagRequestSchema: z.ZodType = z + .object({ + table_name: z.string().optional(), + feature_name: z.string().optional(), + key: z.string().optional(), + }) + .transform(d => ({ + tableName: d.table_name, + featureName: d.feature_name, + key: d.key, + })); export const unmarshalFeatureLineageSchema: z.ZodType = z .object({ - models: z - .array(z.lazy(() => unmarshalFeatureLineage_ModelSchema)) - .optional(), - feature_specs: z - .array(z.lazy(() => unmarshalFeatureLineage_FeatureSpecSchema)) - .optional(), - online_features: z - .array(z.lazy(() => unmarshalFeatureLineage_OnlineFeatureSchema)) - .optional(), + models: z.array(z.lazy(() => unmarshalFeatureLineage_ModelSchema)).optional(), + feature_specs: z.array(z.lazy(() => unmarshalFeatureLineage_FeatureSpecSchema)).optional(), + online_features: z.array(z.lazy(() => unmarshalFeatureLineage_OnlineFeatureSchema)).optional(), }) .transform(d => ({ models: d.models, @@ -141,38 +134,35 @@ export const unmarshalFeatureLineageSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalFeatureLineage_FeatureSpecSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalFeatureLineage_FeatureSpecSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalFeatureLineage_ModelSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - version: z.number().optional(), - }) - .transform(d => ({ - name: d.name, - version: d.version, - })); +export const unmarshalFeatureLineage_ModelSchema: z.ZodType = z + .object({ + name: z.string().optional(), + version: z.number().optional(), + }) + .transform(d => ({ + name: d.name, + version: d.version, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalFeatureLineage_OnlineFeatureSchema: z.ZodType = - z - .object({ - feature_name: z.string().optional(), - table_name: z.string().optional(), - }) - .transform(d => ({ - featureName: d.feature_name, - tableName: d.table_name, - })); +export const unmarshalFeatureLineage_OnlineFeatureSchema: z.ZodType = z + .object({ + feature_name: z.string().optional(), + table_name: z.string().optional(), + }) + .transform(d => ({ + featureName: d.feature_name, + tableName: d.table_name, + })); export const unmarshalFeatureTagSchema: z.ZodType = z .object({ @@ -184,70 +174,65 @@ export const unmarshalFeatureTagSchema: z.ZodType = z value: d.value, })); -export const unmarshalGetFeatureLineageRequestSchema: z.ZodType = - z - .object({ - feature_name: z.string().optional(), - table_name: z.string().optional(), - }) - .transform(d => ({ - featureName: d.feature_name, - tableName: d.table_name, - })); - -export const unmarshalGetFeatureTagRequestSchema: z.ZodType = - z - .object({ - table_name: z.string().optional(), - feature_name: z.string().optional(), - key: z.string().optional(), - }) - .transform(d => ({ - tableName: d.table_name, - featureName: d.feature_name, - key: d.key, - })); - -export const unmarshalListFeatureTagsRequestSchema: z.ZodType = - z - .object({ - table_name: z.string().optional(), - feature_name: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - tableName: d.table_name, - featureName: d.feature_name, - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListFeatureTagsResponseSchema: z.ZodType = - z - .object({ - feature_tags: z.array(z.lazy(() => unmarshalFeatureTagSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - featureTags: d.feature_tags, - nextPageToken: d.next_page_token, - })); - -export const unmarshalUpdateFeatureTagRequestSchema: z.ZodType = - z - .object({ - table_name: z.string().optional(), - feature_name: z.string().optional(), - feature_tag: z.lazy(() => unmarshalFeatureTagSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - tableName: d.table_name, - featureName: d.feature_name, - featureTag: d.feature_tag, - updateMask: d.update_mask, - })); +export const unmarshalGetFeatureLineageRequestSchema: z.ZodType = z + .object({ + feature_name: z.string().optional(), + table_name: z.string().optional(), + }) + .transform(d => ({ + featureName: d.feature_name, + tableName: d.table_name, + })); + +export const unmarshalGetFeatureTagRequestSchema: z.ZodType = z + .object({ + table_name: z.string().optional(), + feature_name: z.string().optional(), + key: z.string().optional(), + }) + .transform(d => ({ + tableName: d.table_name, + featureName: d.feature_name, + key: d.key, + })); + +export const unmarshalListFeatureTagsRequestSchema: z.ZodType = z + .object({ + table_name: z.string().optional(), + feature_name: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + tableName: d.table_name, + featureName: d.feature_name, + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListFeatureTagsResponseSchema: z.ZodType = z + .object({ + feature_tags: z.array(z.lazy(() => unmarshalFeatureTagSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + featureTags: d.feature_tags, + nextPageToken: d.next_page_token, + })); + +export const unmarshalUpdateFeatureTagRequestSchema: z.ZodType = z + .object({ + table_name: z.string().optional(), + feature_name: z.string().optional(), + feature_tag: z.lazy(() => unmarshalFeatureTagSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + tableName: d.table_name, + featureName: d.feature_name, + featureTag: d.feature_tag, + updateMask: d.update_mask, + })); export const marshalCreateFeatureTagRequestSchema: z.ZodType = z .object({ @@ -276,12 +261,8 @@ export const marshalDeleteFeatureTagRequestSchema: z.ZodType = z export const marshalFeatureLineageSchema: z.ZodType = z .object({ models: z.array(z.lazy(() => marshalFeatureLineage_ModelSchema)).optional(), - featureSpecs: z - .array(z.lazy(() => marshalFeatureLineage_FeatureSpecSchema)) - .optional(), - onlineFeatures: z - .array(z.lazy(() => marshalFeatureLineage_OnlineFeatureSchema)) - .optional(), + featureSpecs: z.array(z.lazy(() => marshalFeatureLineage_FeatureSpecSchema)).optional(), + onlineFeatures: z.array(z.lazy(() => marshalFeatureLineage_OnlineFeatureSchema)).optional(), }) .transform(d => ({ models: d.models, @@ -381,7 +362,7 @@ export const marshalUpdateFeatureTagRequestSchema: z.ZodType = z tableName: z.string().optional(), featureName: z.string().optional(), featureTag: z.lazy(() => marshalFeatureTagSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ table_name: d.tableName, diff --git a/packages/materializedfeatures/src/v1/utils.ts b/packages/materializedfeatures/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/materializedfeatures/src/v1/utils.ts +++ b/packages/materializedfeatures/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/materializedfeatures/tsconfig.json b/packages/materializedfeatures/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/materializedfeatures/tsconfig.json +++ b/packages/materializedfeatures/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/metastores/package.json b/packages/metastores/package.json index f5c1f7e7..2a4ae64c 100644 --- a/packages/metastores/package.json +++ b/packages/metastores/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/metastores/src/v1/client.ts b/packages/metastores/src/v1/client.ts index f0054369..30578989 100644 --- a/packages/metastores/src/v1/client.ts +++ b/packages/metastores/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateMetastore, CreateMetastoreAssignment, @@ -68,21 +63,13 @@ export class Client { * the __createMetastore__ API. If the __owner__ field is set to the empty string (**""**), the ownership is * assigned to the System User instead. */ - async createMetastore( - signal: AbortSignal | undefined, - req: CreateMetastore, - options?: Options - ): Promise { + async createMetastore(signal: AbortSignal | undefined, req: CreateMetastore, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores`; const body = marshalRequest(req, marshalCreateMetastoreSchema); let resp: MetastoreInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMetastoreInfoSchema); }; await execute(signal, call, options); @@ -97,25 +84,14 @@ export class Client { * If an assignment for the same __workspace_id__ exists, it will be overwritten by the new __metastore_id__ and * __default_catalog_name__. The caller must be an account admin. */ - async createMetastoreAssignment( - signal: AbortSignal | undefined, - req: CreateMetastoreAssignment, - options?: Options - ): Promise { + async createMetastoreAssignment(signal: AbortSignal | undefined, req: CreateMetastoreAssignment, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? '')}/metastore`; const body = marshalRequest(req, marshalCreateMetastoreAssignmentSchema); let resp: CreateMetastoreAssignment_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalCreateMetastoreAssignment_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateMetastoreAssignment_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -125,11 +101,7 @@ export class Client { } /** Deletes a metastore. The caller must be a metastore admin. */ - async deleteMetastore( - signal: AbortSignal | undefined, - req: DeleteMetastore, - options?: Options - ): Promise { + async deleteMetastore(signal: AbortSignal | undefined, req: DeleteMetastore, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.id ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -140,11 +112,7 @@ export class Client { let resp: DeleteMetastore_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteMetastore_ResponseSchema); }; await execute(signal, call, options); @@ -155,11 +123,7 @@ export class Client { } /** Deletes a metastore assignment. The caller must be an account administrator. */ - async deleteMetastoreAssignment( - signal: AbortSignal | undefined, - req: DeleteMetastoreAssignment, - options?: Options - ): Promise { + async deleteMetastoreAssignment(signal: AbortSignal | undefined, req: DeleteMetastoreAssignment, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? '')}/metastore`; const params = new URLSearchParams(); if (req.metastoreId !== undefined) { @@ -170,15 +134,8 @@ export class Client { let resp: DeleteMetastoreAssignment_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteMetastoreAssignment_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteMetastoreAssignment_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -188,20 +145,12 @@ export class Client { } /** Gets the metastore assignment for the workspace being accessed. */ - async getCurrentMetastoreAssignment( - signal: AbortSignal | undefined, - _req: GetCurrentMetastoreAssignment, - options?: Options - ): Promise { + async getCurrentMetastoreAssignment(signal: AbortSignal | undefined, _req: GetCurrentMetastoreAssignment, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/current-metastore-assignment`; let resp: MetastoreAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMetastoreAssignmentSchema); }; await execute(signal, call, options); @@ -212,20 +161,12 @@ export class Client { } /** Gets a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this info. */ - async getMetastore( - signal: AbortSignal | undefined, - req: GetMetastore, - options?: Options - ): Promise { + async getMetastore(signal: AbortSignal | undefined, req: GetMetastore, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.id ?? ''}`; let resp: MetastoreInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMetastoreInfoSchema); }; await execute(signal, call, options); @@ -239,24 +180,13 @@ export class Client { * Gets information about a metastore. * This summary includes the storage credential, the cloud vendor, the cloud region, and the global metastore ID. */ - async getMetastoreSummary( - signal: AbortSignal | undefined, - _req: GetMetastoreSummary, - options?: Options - ): Promise { + async getMetastoreSummary(signal: AbortSignal | undefined, _req: GetMetastoreSummary, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastore_summary`; let resp: GetMetastoreSummary_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetMetastoreSummary_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetMetastoreSummary_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -268,17 +198,13 @@ export class Client { /** * Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin to retrieve this info. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listMetastores( - signal: AbortSignal | undefined, - req: ListMetastores, - options?: Options - ): Promise { + async listMetastores(signal: AbortSignal | undefined, req: ListMetastores, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -292,11 +218,7 @@ export class Client { let resp: ListMetastores_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListMetastores_ResponseSchema); }; await execute(signal, call, options); @@ -306,11 +228,8 @@ export class Client { return resp; } - async *listMetastoresIter( - signal: AbortSignal | undefined, - req: ListMetastores, - options?: Options - ): AsyncGenerator { + + async *listMetastoresIter(signal: AbortSignal | undefined, req: ListMetastores, options?: Options): AsyncGenerator { const pageReq: ListMetastores = {...req}; for (;;) { const resp = await this.listMetastores(signal, pageReq, options); @@ -324,26 +243,19 @@ export class Client { } } + /** * Updates information for a specific metastore. The caller must be a metastore admin. * If the __owner__ field is set to the empty string (**""**), the ownership is updated * to the System User. */ - async updateMetastore( - signal: AbortSignal | undefined, - req: UpdateMetastore, - options?: Options - ): Promise { + async updateMetastore(signal: AbortSignal | undefined, req: UpdateMetastore, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.id ?? ''}`; const body = marshalRequest(req, marshalUpdateMetastoreSchema); let resp: MetastoreInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalMetastoreInfoSchema); }; await execute(signal, call, options); @@ -358,25 +270,14 @@ export class Client { * for a specified Workspace, if the Workspace is already assigned a metastore. * The caller must be an account admin to update __metastore_id__; otherwise, the caller can be a Workspace admin. */ - async updateMetastoreAssignment( - signal: AbortSignal | undefined, - req: UpdateMetastoreAssignment, - options?: Options - ): Promise { + async updateMetastoreAssignment(signal: AbortSignal | undefined, req: UpdateMetastoreAssignment, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/workspaces/${String(req.workspaceId ?? '')}/metastore`; const body = marshalRequest(req, marshalUpdateMetastoreAssignmentSchema); let resp: UpdateMetastoreAssignment_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalUpdateMetastoreAssignment_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdateMetastoreAssignment_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { diff --git a/packages/metastores/src/v1/index.ts b/packages/metastores/src/v1/index.ts index e99e0055..0a079544 100644 --- a/packages/metastores/src/v1/index.ts +++ b/packages/metastores/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {DeltaSharingScope_Enum} from './model'; +export { + DeltaSharingScope_Enum, +} from './model'; export type { CreateMetastore, diff --git a/packages/metastores/src/v1/model.ts b/packages/metastores/src/v1/model.ts index e44ac628..bd30046b 100644 --- a/packages/metastores/src/v1/model.ts +++ b/packages/metastores/src/v1/model.ts @@ -318,8 +318,7 @@ export const unmarshalCreateMetastoreSchema: z.ZodType = z defaultDataAccessConfigId: d.default_data_access_config_id, storageRootCredentialId: d.storage_root_credential_id, deltaSharingScope: d.delta_sharing_scope, - deltaSharingRecipientTokenLifetimeInSeconds: - d.delta_sharing_recipient_token_lifetime_in_seconds, + deltaSharingRecipientTokenLifetimeInSeconds: d.delta_sharing_recipient_token_lifetime_in_seconds, deltaSharingOrganizationName: d.delta_sharing_organization_name, owner: d.owner, privilegeModelVersion: d.privilege_model_version, @@ -335,22 +334,22 @@ export const unmarshalCreateMetastoreSchema: z.ZodType = z externalAccessEnabled: d.external_access_enabled, })); -export const unmarshalCreateMetastoreAssignmentSchema: z.ZodType = - z - .object({ - workspace_id: z.number().optional(), - metastore_id: z.string().optional(), - default_catalog_name: z.string().optional(), - }) - .transform(d => ({ - workspaceId: d.workspace_id, - metastoreId: d.metastore_id, - defaultCatalogName: d.default_catalog_name, - })); +export const unmarshalCreateMetastoreAssignmentSchema: z.ZodType = z + .object({ + workspace_id: z.number().optional(), + metastore_id: z.string().optional(), + default_catalog_name: z.string().optional(), + }) + .transform(d => ({ + workspaceId: d.workspace_id, + metastoreId: d.metastore_id, + defaultCatalogName: d.default_catalog_name, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateMetastoreAssignment_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalCreateMetastoreAssignment_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalDeleteMetastoreSchema: z.ZodType = z .object({ @@ -363,29 +362,32 @@ export const unmarshalDeleteMetastoreSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteMetastore_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeleteMetastoreAssignmentSchema: z.ZodType = - z - .object({ - workspace_id: z.number().optional(), - metastore_id: z.string().optional(), - }) - .transform(d => ({ - workspaceId: d.workspace_id, - metastoreId: d.metastore_id, - })); +export const unmarshalDeleteMetastore_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteMetastoreAssignmentSchema: z.ZodType = z + .object({ + workspace_id: z.number().optional(), + metastore_id: z.string().optional(), + }) + .transform(d => ({ + workspaceId: d.workspace_id, + metastoreId: d.metastore_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteMetastoreAssignment_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteMetastoreAssignment_ResponseSchema: z.ZodType = z + .object({ + }); -export const unmarshalDeltaSharingScopeSchema: z.ZodType = - z.object({}); +export const unmarshalDeltaSharingScopeSchema: z.ZodType = z + .object({ + }); -export const unmarshalGetCurrentMetastoreAssignmentSchema: z.ZodType = - z.object({}); +export const unmarshalGetCurrentMetastoreAssignmentSchema: z.ZodType = z + .object({ + }); export const unmarshalGetMetastoreSchema: z.ZodType = z .object({ @@ -395,55 +397,54 @@ export const unmarshalGetMetastoreSchema: z.ZodType = z id: d.id, })); -export const unmarshalGetMetastoreSummarySchema: z.ZodType = - z.object({}); +export const unmarshalGetMetastoreSummarySchema: z.ZodType = z + .object({ + }); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetMetastoreSummary_ResponseSchema: z.ZodType = - z - .object({ - metastore_id: z.string().optional(), - name: z.string().optional(), - default_data_access_config_id: z.string().optional(), - storage_root_credential_id: z.string().optional(), - cloud: z.string().optional(), - region: z.string().optional(), - global_metastore_id: z.string().optional(), - storage_root_credential_name: z.string().optional(), - privilege_model_version: z.string().optional(), - delta_sharing_scope: z.enum(DeltaSharingScope_Enum).optional(), - delta_sharing_recipient_token_lifetime_in_seconds: z.number().optional(), - delta_sharing_organization_name: z.string().optional(), - storage_root: z.string().optional(), - owner: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - external_access_enabled: z.boolean().optional(), - }) - .transform(d => ({ - metastoreId: d.metastore_id, - name: d.name, - defaultDataAccessConfigId: d.default_data_access_config_id, - storageRootCredentialId: d.storage_root_credential_id, - cloud: d.cloud, - region: d.region, - globalMetastoreId: d.global_metastore_id, - storageRootCredentialName: d.storage_root_credential_name, - privilegeModelVersion: d.privilege_model_version, - deltaSharingScope: d.delta_sharing_scope, - deltaSharingRecipientTokenLifetimeInSeconds: - d.delta_sharing_recipient_token_lifetime_in_seconds, - deltaSharingOrganizationName: d.delta_sharing_organization_name, - storageRoot: d.storage_root, - owner: d.owner, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - externalAccessEnabled: d.external_access_enabled, - })); +export const unmarshalGetMetastoreSummary_ResponseSchema: z.ZodType = z + .object({ + metastore_id: z.string().optional(), + name: z.string().optional(), + default_data_access_config_id: z.string().optional(), + storage_root_credential_id: z.string().optional(), + cloud: z.string().optional(), + region: z.string().optional(), + global_metastore_id: z.string().optional(), + storage_root_credential_name: z.string().optional(), + privilege_model_version: z.string().optional(), + delta_sharing_scope: z.enum(DeltaSharingScope_Enum).optional(), + delta_sharing_recipient_token_lifetime_in_seconds: z.number().optional(), + delta_sharing_organization_name: z.string().optional(), + storage_root: z.string().optional(), + owner: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + external_access_enabled: z.boolean().optional(), + }) + .transform(d => ({ + metastoreId: d.metastore_id, + name: d.name, + defaultDataAccessConfigId: d.default_data_access_config_id, + storageRootCredentialId: d.storage_root_credential_id, + cloud: d.cloud, + region: d.region, + globalMetastoreId: d.global_metastore_id, + storageRootCredentialName: d.storage_root_credential_name, + privilegeModelVersion: d.privilege_model_version, + deltaSharingScope: d.delta_sharing_scope, + deltaSharingRecipientTokenLifetimeInSeconds: d.delta_sharing_recipient_token_lifetime_in_seconds, + deltaSharingOrganizationName: d.delta_sharing_organization_name, + storageRoot: d.storage_root, + owner: d.owner, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + externalAccessEnabled: d.external_access_enabled, + })); export const unmarshalListMetastoresSchema: z.ZodType = z .object({ @@ -456,31 +457,27 @@ export const unmarshalListMetastoresSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListMetastores_ResponseSchema: z.ZodType = - z - .object({ - metastores: z - .array(z.lazy(() => unmarshalMetastoreInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - metastores: d.metastores, - nextPageToken: d.next_page_token, - })); - -export const unmarshalMetastoreAssignmentSchema: z.ZodType = - z - .object({ - workspace_id: z.number().optional(), - metastore_id: z.string().optional(), - default_catalog_name: z.string().optional(), - }) - .transform(d => ({ - workspaceId: d.workspace_id, - metastoreId: d.metastore_id, - defaultCatalogName: d.default_catalog_name, - })); +export const unmarshalListMetastores_ResponseSchema: z.ZodType = z + .object({ + metastores: z.array(z.lazy(() => unmarshalMetastoreInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + metastores: d.metastores, + nextPageToken: d.next_page_token, + })); + +export const unmarshalMetastoreAssignmentSchema: z.ZodType = z + .object({ + workspace_id: z.number().optional(), + metastore_id: z.string().optional(), + default_catalog_name: z.string().optional(), + }) + .transform(d => ({ + workspaceId: d.workspace_id, + metastoreId: d.metastore_id, + defaultCatalogName: d.default_catalog_name, + })); export const unmarshalMetastoreInfoSchema: z.ZodType = z .object({ @@ -510,8 +507,7 @@ export const unmarshalMetastoreInfoSchema: z.ZodType = z defaultDataAccessConfigId: d.default_data_access_config_id, storageRootCredentialId: d.storage_root_credential_id, deltaSharingScope: d.delta_sharing_scope, - deltaSharingRecipientTokenLifetimeInSeconds: - d.delta_sharing_recipient_token_lifetime_in_seconds, + deltaSharingRecipientTokenLifetimeInSeconds: d.delta_sharing_recipient_token_lifetime_in_seconds, deltaSharingOrganizationName: d.delta_sharing_organization_name, owner: d.owner, privilegeModelVersion: d.privilege_model_version, @@ -559,8 +555,7 @@ export const unmarshalUpdateMetastoreSchema: z.ZodType = z defaultDataAccessConfigId: d.default_data_access_config_id, storageRootCredentialId: d.storage_root_credential_id, deltaSharingScope: d.delta_sharing_scope, - deltaSharingRecipientTokenLifetimeInSeconds: - d.delta_sharing_recipient_token_lifetime_in_seconds, + deltaSharingRecipientTokenLifetimeInSeconds: d.delta_sharing_recipient_token_lifetime_in_seconds, deltaSharingOrganizationName: d.delta_sharing_organization_name, owner: d.owner, privilegeModelVersion: d.privilege_model_version, @@ -576,22 +571,22 @@ export const unmarshalUpdateMetastoreSchema: z.ZodType = z externalAccessEnabled: d.external_access_enabled, })); -export const unmarshalUpdateMetastoreAssignmentSchema: z.ZodType = - z - .object({ - workspace_id: z.number().optional(), - metastore_id: z.string().optional(), - default_catalog_name: z.string().optional(), - }) - .transform(d => ({ - workspaceId: d.workspace_id, - metastoreId: d.metastore_id, - defaultCatalogName: d.default_catalog_name, - })); +export const unmarshalUpdateMetastoreAssignmentSchema: z.ZodType = z + .object({ + workspace_id: z.number().optional(), + metastore_id: z.string().optional(), + default_catalog_name: z.string().optional(), + }) + .transform(d => ({ + workspaceId: d.workspace_id, + metastoreId: d.metastore_id, + defaultCatalogName: d.default_catalog_name, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateMetastoreAssignment_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalUpdateMetastoreAssignment_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalCreateMetastoreSchema: z.ZodType = z .object({ @@ -621,8 +616,7 @@ export const marshalCreateMetastoreSchema: z.ZodType = z default_data_access_config_id: d.defaultDataAccessConfigId, storage_root_credential_id: d.storageRootCredentialId, delta_sharing_scope: d.deltaSharingScope, - delta_sharing_recipient_token_lifetime_in_seconds: - d.deltaSharingRecipientTokenLifetimeInSeconds, + delta_sharing_recipient_token_lifetime_in_seconds: d.deltaSharingRecipientTokenLifetimeInSeconds, delta_sharing_organization_name: d.deltaSharingOrganizationName, owner: d.owner, privilege_model_version: d.privilegeModelVersion, @@ -651,8 +645,9 @@ export const marshalCreateMetastoreAssignmentSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalCreateMetastoreAssignment_ResponseSchema: z.ZodType = - z.object({}); +export const marshalCreateMetastoreAssignment_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeleteMetastoreSchema: z.ZodType = z .object({ @@ -665,7 +660,9 @@ export const marshalDeleteMetastoreSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteMetastore_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteMetastore_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeleteMetastoreAssignmentSchema: z.ZodType = z .object({ @@ -678,14 +675,17 @@ export const marshalDeleteMetastoreAssignmentSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteMetastoreAssignment_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeleteMetastoreAssignment_ResponseSchema: z.ZodType = z + .object({ + }); -export const marshalDeltaSharingScopeSchema: z.ZodType = z.object({}); +export const marshalDeltaSharingScopeSchema: z.ZodType = z + .object({ + }); -export const marshalGetCurrentMetastoreAssignmentSchema: z.ZodType = z.object( - {} -); +export const marshalGetCurrentMetastoreAssignmentSchema: z.ZodType = z + .object({ + }); export const marshalGetMetastoreSchema: z.ZodType = z .object({ @@ -695,7 +695,9 @@ export const marshalGetMetastoreSchema: z.ZodType = z id: d.id, })); -export const marshalGetMetastoreSummarySchema: z.ZodType = z.object({}); +export const marshalGetMetastoreSummarySchema: z.ZodType = z + .object({ + }); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalGetMetastoreSummary_ResponseSchema: z.ZodType = z @@ -731,8 +733,7 @@ export const marshalGetMetastoreSummary_ResponseSchema: z.ZodType = z storage_root_credential_name: d.storageRootCredentialName, privilege_model_version: d.privilegeModelVersion, delta_sharing_scope: d.deltaSharingScope, - delta_sharing_recipient_token_lifetime_in_seconds: - d.deltaSharingRecipientTokenLifetimeInSeconds, + delta_sharing_recipient_token_lifetime_in_seconds: d.deltaSharingRecipientTokenLifetimeInSeconds, delta_sharing_organization_name: d.deltaSharingOrganizationName, storage_root: d.storageRoot, owner: d.owner, @@ -804,8 +805,7 @@ export const marshalMetastoreInfoSchema: z.ZodType = z default_data_access_config_id: d.defaultDataAccessConfigId, storage_root_credential_id: d.storageRootCredentialId, delta_sharing_scope: d.deltaSharingScope, - delta_sharing_recipient_token_lifetime_in_seconds: - d.deltaSharingRecipientTokenLifetimeInSeconds, + delta_sharing_recipient_token_lifetime_in_seconds: d.deltaSharingRecipientTokenLifetimeInSeconds, delta_sharing_organization_name: d.deltaSharingOrganizationName, owner: d.owner, privilege_model_version: d.privilegeModelVersion, @@ -853,8 +853,7 @@ export const marshalUpdateMetastoreSchema: z.ZodType = z default_data_access_config_id: d.defaultDataAccessConfigId, storage_root_credential_id: d.storageRootCredentialId, delta_sharing_scope: d.deltaSharingScope, - delta_sharing_recipient_token_lifetime_in_seconds: - d.deltaSharingRecipientTokenLifetimeInSeconds, + delta_sharing_recipient_token_lifetime_in_seconds: d.deltaSharingRecipientTokenLifetimeInSeconds, delta_sharing_organization_name: d.deltaSharingOrganizationName, owner: d.owner, privilege_model_version: d.privilegeModelVersion, @@ -883,5 +882,6 @@ export const marshalUpdateMetastoreAssignmentSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalUpdateMetastoreAssignment_ResponseSchema: z.ZodType = - z.object({}); +export const marshalUpdateMetastoreAssignment_ResponseSchema: z.ZodType = z + .object({ + }); diff --git a/packages/metastores/src/v1/utils.ts b/packages/metastores/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/metastores/src/v1/utils.ts +++ b/packages/metastores/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/metastores/tsconfig.json b/packages/metastores/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/metastores/tsconfig.json +++ b/packages/metastores/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/notificationdestinations/package.json b/packages/notificationdestinations/package.json index 1c4ce831..9dbcdfd1 100644 --- a/packages/notificationdestinations/package.json +++ b/packages/notificationdestinations/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/notificationdestinations/src/v1/client.ts b/packages/notificationdestinations/src/v1/client.ts index ce43f1a9..4204e0e9 100644 --- a/packages/notificationdestinations/src/v1/client.ts +++ b/packages/notificationdestinations/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateNotificationDestinationRequest, DeleteNotificationDestinationRequest, @@ -47,24 +42,13 @@ export class Client { } /** Creates a notification destination. Requires workspace admin permissions. */ - async createNotificationDestination( - signal: AbortSignal | undefined, - req: CreateNotificationDestinationRequest, - options?: Options - ): Promise { + async createNotificationDestination(signal: AbortSignal | undefined, req: CreateNotificationDestinationRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/notification-destinations`; - const body = marshalRequest( - req, - marshalCreateNotificationDestinationRequestSchema - ); + const body = marshalRequest(req, marshalCreateNotificationDestinationRequestSchema); let resp: NotificationDestination | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalNotificationDestinationSchema); }; await execute(signal, call, options); @@ -75,20 +59,12 @@ export class Client { } /** Deletes a notification destination. Requires workspace admin permissions. */ - async deleteNotificationDestination( - signal: AbortSignal | undefined, - req: DeleteNotificationDestinationRequest, - options?: Options - ): Promise { + async deleteNotificationDestination(signal: AbortSignal | undefined, req: DeleteNotificationDestinationRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/notification-destinations/${req.id ?? ''}`; let resp: Empty | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEmptySchema); }; await execute(signal, call, options); @@ -99,20 +75,12 @@ export class Client { } /** Gets a notification destination. */ - async getNotificationDestination( - signal: AbortSignal | undefined, - req: GetNotificationDestinationRequest, - options?: Options - ): Promise { + async getNotificationDestination(signal: AbortSignal | undefined, req: GetNotificationDestinationRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/notification-destinations/${req.id ?? ''}`; let resp: NotificationDestination | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalNotificationDestinationSchema); }; await execute(signal, call, options); @@ -123,11 +91,7 @@ export class Client { } /** Lists notification destinations. */ - async listNotificationDestinations( - signal: AbortSignal | undefined, - req: ListNotificationDestinationsRequest, - options?: Options - ): Promise { + async listNotificationDestinations(signal: AbortSignal | undefined, req: ListNotificationDestinationsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/notification-destinations`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -141,15 +105,8 @@ export class Client { let resp: ListNotificationDestinationsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListNotificationDestinationsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListNotificationDestinationsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -158,18 +115,11 @@ export class Client { return resp; } - async *listNotificationDestinationsIter( - signal: AbortSignal | undefined, - req: ListNotificationDestinationsRequest, - options?: Options - ): AsyncGenerator { + + async *listNotificationDestinationsIter(signal: AbortSignal | undefined, req: ListNotificationDestinationsRequest, options?: Options): AsyncGenerator { const pageReq: ListNotificationDestinationsRequest = {...req}; for (;;) { - const resp = await this.listNotificationDestinations( - signal, - pageReq, - options - ); + const resp = await this.listNotificationDestinations(signal, pageReq, options); for (const item of resp.results ?? []) { yield item; } @@ -180,25 +130,15 @@ export class Client { } } + /** Updates a notification destination. Requires workspace admin permissions. At least one field is required in the request body. */ - async updateNotificationDestination( - signal: AbortSignal | undefined, - req: UpdateNotificationDestinationRequest, - options?: Options - ): Promise { + async updateNotificationDestination(signal: AbortSignal | undefined, req: UpdateNotificationDestinationRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/notification-destinations/${req.id ?? ''}`; - const body = marshalRequest( - req, - marshalUpdateNotificationDestinationRequestSchema - ); + const body = marshalRequest(req, marshalUpdateNotificationDestinationRequestSchema); let resp: NotificationDestination | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalNotificationDestinationSchema); }; await execute(signal, call, options); diff --git a/packages/notificationdestinations/src/v1/index.ts b/packages/notificationdestinations/src/v1/index.ts index 14a5cb14..479eb5bc 100644 --- a/packages/notificationdestinations/src/v1/index.ts +++ b/packages/notificationdestinations/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {DestinationType} from './model'; +export { + DestinationType, +} from './model'; export type { Config, diff --git a/packages/notificationdestinations/src/v1/model.ts b/packages/notificationdestinations/src/v1/model.ts index d69f5ce8..9a319e31 100644 --- a/packages/notificationdestinations/src/v1/model.ts +++ b/packages/notificationdestinations/src/v1/model.ts @@ -147,13 +147,9 @@ export const unmarshalConfigSchema: z.ZodType = z .object({ slack: z.lazy(() => unmarshalSlackConfigSchema).optional(), email: z.lazy(() => unmarshalEmailConfigSchema).optional(), - generic_webhook: z - .lazy(() => unmarshalGenericWebhookConfigSchema) - .optional(), + generic_webhook: z.lazy(() => unmarshalGenericWebhookConfigSchema).optional(), pagerduty: z.lazy(() => unmarshalPagerdutyConfigSchema).optional(), - microsoft_teams: z - .lazy(() => unmarshalMicrosoftTeamsConfigSchema) - .optional(), + microsoft_teams: z.lazy(() => unmarshalMicrosoftTeamsConfigSchema).optional(), }) .transform(d => ({ slack: d.slack, @@ -163,25 +159,23 @@ export const unmarshalConfigSchema: z.ZodType = z microsoftTeams: d.microsoft_teams, })); -export const unmarshalCreateNotificationDestinationRequestSchema: z.ZodType = - z - .object({ - display_name: z.string().optional(), - config: z.lazy(() => unmarshalConfigSchema).optional(), - }) - .transform(d => ({ - displayName: d.display_name, - config: d.config, - })); - -export const unmarshalDeleteNotificationDestinationRequestSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - })); +export const unmarshalCreateNotificationDestinationRequestSchema: z.ZodType = z + .object({ + display_name: z.string().optional(), + config: z.lazy(() => unmarshalConfigSchema).optional(), + }) + .transform(d => ({ + displayName: d.display_name, + config: d.config, + })); + +export const unmarshalDeleteNotificationDestinationRequestSchema: z.ZodType = z + .object({ + id: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + })); export const unmarshalEmailConfigSchema: z.ZodType = z .object({ @@ -191,116 +185,109 @@ export const unmarshalEmailConfigSchema: z.ZodType = z addresses: d.addresses, })); -export const unmarshalEmptySchema: z.ZodType = z.object({}); - -export const unmarshalGenericWebhookConfigSchema: z.ZodType = - z - .object({ - url: z.string().optional(), - url_set: z.boolean().optional(), - username: z.string().optional(), - username_set: z.boolean().optional(), - password: z.string().optional(), - password_set: z.boolean().optional(), - }) - .transform(d => ({ - url: d.url, - urlSet: d.url_set, - username: d.username, - usernameSet: d.username_set, - password: d.password, - passwordSet: d.password_set, - })); - -export const unmarshalGetNotificationDestinationRequestSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - })); - -export const unmarshalListNotificationDestinationsRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListNotificationDestinationsResponseSchema: z.ZodType = - z - .object({ - results: z - .array(z.lazy(() => unmarshalListNotificationDestinationsResultSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - results: d.results, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListNotificationDestinationsResultSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - destination_type: z.enum(DestinationType).optional(), - config: z.lazy(() => unmarshalConfigSchema).optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - destinationType: d.destination_type, - config: d.config, - })); - -export const unmarshalMicrosoftTeamsConfigSchema: z.ZodType = - z - .object({ - url: z.string().optional(), - url_set: z.boolean().optional(), - app_id: z.string().optional(), - app_id_set: z.boolean().optional(), - auth_secret: z.string().optional(), - auth_secret_set: z.boolean().optional(), - channel_url: z.string().optional(), - channel_url_set: z.boolean().optional(), - tenant_id: z.string().optional(), - tenant_id_set: z.boolean().optional(), - }) - .transform(d => ({ - url: d.url, - urlSet: d.url_set, - appId: d.app_id, - appIdSet: d.app_id_set, - authSecret: d.auth_secret, - authSecretSet: d.auth_secret_set, - channelUrl: d.channel_url, - channelUrlSet: d.channel_url_set, - tenantId: d.tenant_id, - tenantIdSet: d.tenant_id_set, - })); - -export const unmarshalNotificationDestinationSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - destination_type: z.enum(DestinationType).optional(), - config: z.lazy(() => unmarshalConfigSchema).optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - destinationType: d.destination_type, - config: d.config, - })); +export const unmarshalEmptySchema: z.ZodType = z + .object({ + }); + +export const unmarshalGenericWebhookConfigSchema: z.ZodType = z + .object({ + url: z.string().optional(), + url_set: z.boolean().optional(), + username: z.string().optional(), + username_set: z.boolean().optional(), + password: z.string().optional(), + password_set: z.boolean().optional(), + }) + .transform(d => ({ + url: d.url, + urlSet: d.url_set, + username: d.username, + usernameSet: d.username_set, + password: d.password, + passwordSet: d.password_set, + })); + +export const unmarshalGetNotificationDestinationRequestSchema: z.ZodType = z + .object({ + id: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + })); + +export const unmarshalListNotificationDestinationsRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListNotificationDestinationsResponseSchema: z.ZodType = z + .object({ + results: z.array(z.lazy(() => unmarshalListNotificationDestinationsResultSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + results: d.results, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListNotificationDestinationsResultSchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + destination_type: z.enum(DestinationType).optional(), + config: z.lazy(() => unmarshalConfigSchema).optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + destinationType: d.destination_type, + config: d.config, + })); + +export const unmarshalMicrosoftTeamsConfigSchema: z.ZodType = z + .object({ + url: z.string().optional(), + url_set: z.boolean().optional(), + app_id: z.string().optional(), + app_id_set: z.boolean().optional(), + auth_secret: z.string().optional(), + auth_secret_set: z.boolean().optional(), + channel_url: z.string().optional(), + channel_url_set: z.boolean().optional(), + tenant_id: z.string().optional(), + tenant_id_set: z.boolean().optional(), + }) + .transform(d => ({ + url: d.url, + urlSet: d.url_set, + appId: d.app_id, + appIdSet: d.app_id_set, + authSecret: d.auth_secret, + authSecretSet: d.auth_secret_set, + channelUrl: d.channel_url, + channelUrlSet: d.channel_url_set, + tenantId: d.tenant_id, + tenantIdSet: d.tenant_id_set, + })); + +export const unmarshalNotificationDestinationSchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + destination_type: z.enum(DestinationType).optional(), + config: z.lazy(() => unmarshalConfigSchema).optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + destinationType: d.destination_type, + config: d.config, + })); export const unmarshalPagerdutyConfigSchema: z.ZodType = z .object({ @@ -330,18 +317,17 @@ export const unmarshalSlackConfigSchema: z.ZodType = z channelIdSet: d.channel_id_set, })); -export const unmarshalUpdateNotificationDestinationRequestSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - config: z.lazy(() => unmarshalConfigSchema).optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - config: d.config, - })); +export const unmarshalUpdateNotificationDestinationRequestSchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + config: z.lazy(() => unmarshalConfigSchema).optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + config: d.config, + })); export const marshalConfigSchema: z.ZodType = z .object({ @@ -385,7 +371,9 @@ export const marshalEmailConfigSchema: z.ZodType = z addresses: d.addresses, })); -export const marshalEmptySchema: z.ZodType = z.object({}); +export const marshalEmptySchema: z.ZodType = z + .object({ + }); export const marshalGenericWebhookConfigSchema: z.ZodType = z .object({ @@ -425,9 +413,7 @@ export const marshalListNotificationDestinationsRequestSchema: z.ZodType = z export const marshalListNotificationDestinationsResponseSchema: z.ZodType = z .object({ - results: z - .array(z.lazy(() => marshalListNotificationDestinationsResultSchema)) - .optional(), + results: z.array(z.lazy(() => marshalListNotificationDestinationsResultSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ diff --git a/packages/notificationdestinations/src/v1/utils.ts b/packages/notificationdestinations/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/notificationdestinations/src/v1/utils.ts +++ b/packages/notificationdestinations/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/notificationdestinations/tsconfig.json b/packages/notificationdestinations/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/notificationdestinations/tsconfig.json +++ b/packages/notificationdestinations/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/oauthcustomappintegration/package.json b/packages/oauthcustomappintegration/package.json index a6112e2b..6759cf12 100644 --- a/packages/oauthcustomappintegration/package.json +++ b/packages/oauthcustomappintegration/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/oauthcustomappintegration/src/v1/client.ts b/packages/oauthcustomappintegration/src/v1/client.ts index 8ec1ac9a..ded71948 100644 --- a/packages/oauthcustomappintegration/src/v1/client.ts +++ b/packages/oauthcustomappintegration/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateCustomOAuthAppIntegration, CreatePublishedOAuthAppIntegration, @@ -68,31 +63,17 @@ export class Client { /** * Create Custom OAuth App Integration. - * + * * You can retrieve the custom OAuth app integration via :method:CustomAppIntegration/get. */ - async createCustomOAuthAppIntegration( - signal: AbortSignal | undefined, - req: CreateCustomOAuthAppIntegration, - options?: Options - ): Promise { + async createCustomOAuthAppIntegration(signal: AbortSignal | undefined, req: CreateCustomOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts/{account_id}/oauth2/custom-app-integrations`; - const body = marshalRequest( - req, - marshalCreateCustomOAuthAppIntegrationSchema - ); + const body = marshalRequest(req, marshalCreateCustomOAuthAppIntegrationSchema); let resp: CustomOAuthAppIntegrationSecret | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalCustomOAuthAppIntegrationSecretSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCustomOAuthAppIntegrationSecretSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -103,31 +84,17 @@ export class Client { /** * Create Published OAuth App Integration. - * + * * You can retrieve the published OAuth app integration via :method:PublishedAppIntegration/get. */ - async createPublishedOAuthAppIntegration( - signal: AbortSignal | undefined, - req: CreatePublishedOAuthAppIntegration, - options?: Options - ): Promise { + async createPublishedOAuthAppIntegration(signal: AbortSignal | undefined, req: CreatePublishedOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts/{account_id}/oauth2/published-app-integrations`; - const body = marshalRequest( - req, - marshalCreatePublishedOAuthAppIntegrationSchema - ); + const body = marshalRequest(req, marshalCreatePublishedOAuthAppIntegrationSchema); let resp: CreatePublishedOAuthAppIntegration_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalCreatePublishedOAuthAppIntegration_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreatePublishedOAuthAppIntegration_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -140,11 +107,7 @@ export class Client { * Delete an existing Custom OAuth App Integration. * You can retrieve the custom OAuth app integration via :method:CustomAppIntegration/get. */ - async deleteCustomOAuthAppIntegration( - signal: AbortSignal | undefined, - req: DeleteCustomOAuthAppIntegration, - options?: Options - ): Promise { + async deleteCustomOAuthAppIntegration(signal: AbortSignal | undefined, req: DeleteCustomOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//oauth2/custom-app-integrations/${req.integrationId ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -155,15 +118,8 @@ export class Client { let resp: DeleteCustomOAuthAppIntegration_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteCustomOAuthAppIntegration_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteCustomOAuthAppIntegration_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -176,11 +132,7 @@ export class Client { * Delete an existing Published OAuth App Integration. * You can retrieve the published OAuth app integration via :method:PublishedAppIntegration/get. */ - async deletePublishedOAuthAppIntegration( - signal: AbortSignal | undefined, - req: DeletePublishedOAuthAppIntegration, - options?: Options - ): Promise { + async deletePublishedOAuthAppIntegration(signal: AbortSignal | undefined, req: DeletePublishedOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//oauth2/published-app-integrations/${req.integrationId ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -191,15 +143,8 @@ export class Client { let resp: DeletePublishedOAuthAppIntegration_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeletePublishedOAuthAppIntegration_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeletePublishedOAuthAppIntegration_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -209,11 +154,7 @@ export class Client { } /** Gets the Custom OAuth App Integration for the given integration id. */ - async getCustomOAuthAppIntegration( - signal: AbortSignal | undefined, - req: GetCustomOAuthAppIntegration, - options?: Options - ): Promise { + async getCustomOAuthAppIntegration(signal: AbortSignal | undefined, req: GetCustomOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//oauth2/custom-app-integrations/${req.integrationId ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -224,11 +165,7 @@ export class Client { let resp: CustomOAuthAppIntegration | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCustomOAuthAppIntegrationSchema); }; await execute(signal, call, options); @@ -239,11 +176,7 @@ export class Client { } /** Gets the Published OAuth App Integration for the given integration id. */ - async getPublishedOAuthAppIntegration( - signal: AbortSignal | undefined, - req: GetPublishedOAuthAppIntegration, - options?: Options - ): Promise { + async getPublishedOAuthAppIntegration(signal: AbortSignal | undefined, req: GetPublishedOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//oauth2/published-app-integrations/${req.integrationId ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -254,15 +187,8 @@ export class Client { let resp: PublishedOAuthAppIntegration | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalPublishedOAuthAppIntegrationSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalPublishedOAuthAppIntegrationSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -272,11 +198,7 @@ export class Client { } /** Get the list of custom OAuth app integrations for the specified */ - async listCustomOAuthAppIntegrations( - signal: AbortSignal | undefined, - req: ListCustomOAuthAppIntegrations, - options?: Options - ): Promise { + async listCustomOAuthAppIntegrations(signal: AbortSignal | undefined, req: ListCustomOAuthAppIntegrations, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts/{account_id}/oauth2/custom-app-integrations`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -289,25 +211,15 @@ export class Client { params.append('page_size', String(req.pageSize)); } if (req.includeCreatorUsername !== undefined) { - params.append( - 'include_creator_username', - String(req.includeCreatorUsername) - ); + params.append('include_creator_username', String(req.includeCreatorUsername)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: ListCustomOAuthAppIntegrations_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListCustomOAuthAppIntegrations_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListCustomOAuthAppIntegrations_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -316,18 +228,11 @@ export class Client { return resp; } - async *listCustomOAuthAppIntegrationsIter( - signal: AbortSignal | undefined, - req: ListCustomOAuthAppIntegrations, - options?: Options - ): AsyncGenerator { + + async *listCustomOAuthAppIntegrationsIter(signal: AbortSignal | undefined, req: ListCustomOAuthAppIntegrations, options?: Options): AsyncGenerator { const pageReq: ListCustomOAuthAppIntegrations = {...req}; for (;;) { - const resp = await this.listCustomOAuthAppIntegrations( - signal, - pageReq, - options - ); + const resp = await this.listCustomOAuthAppIntegrations(signal, pageReq, options); for (const item of resp.apps ?? []) { yield item; } @@ -338,12 +243,9 @@ export class Client { } } + /** Get the list of published OAuth app integrations for the specified */ - async listPublishedOAuthAppIntegrations( - signal: AbortSignal | undefined, - req: ListPublishedOAuthAppIntegrations, - options?: Options - ): Promise { + async listPublishedOAuthAppIntegrations(signal: AbortSignal | undefined, req: ListPublishedOAuthAppIntegrations, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts/{account_id}/oauth2/published-app-integrations`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -360,15 +262,8 @@ export class Client { let resp: ListPublishedOAuthAppIntegrations_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListPublishedOAuthAppIntegrations_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListPublishedOAuthAppIntegrations_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -377,18 +272,11 @@ export class Client { return resp; } - async *listPublishedOAuthAppIntegrationsIter( - signal: AbortSignal | undefined, - req: ListPublishedOAuthAppIntegrations, - options?: Options - ): AsyncGenerator { + + async *listPublishedOAuthAppIntegrationsIter(signal: AbortSignal | undefined, req: ListPublishedOAuthAppIntegrations, options?: Options): AsyncGenerator { const pageReq: ListPublishedOAuthAppIntegrations = {...req}; for (;;) { - const resp = await this.listPublishedOAuthAppIntegrations( - signal, - pageReq, - options - ); + const resp = await this.listPublishedOAuthAppIntegrations(signal, pageReq, options); for (const item of resp.apps ?? []) { yield item; } @@ -399,32 +287,19 @@ export class Client { } } + /** * Updates an existing custom OAuth App Integration. * You can retrieve the custom OAuth app integration via :method:CustomAppIntegration/get. */ - async updateCustomOAuthAppIntegration( - signal: AbortSignal | undefined, - req: UpdateCustomOAuthAppIntegration, - options?: Options - ): Promise { + async updateCustomOAuthAppIntegration(signal: AbortSignal | undefined, req: UpdateCustomOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//oauth2/custom-app-integrations/${req.integrationId ?? ''}`; - const body = marshalRequest( - req, - marshalUpdateCustomOAuthAppIntegrationSchema - ); + const body = marshalRequest(req, marshalUpdateCustomOAuthAppIntegrationSchema); let resp: UpdateCustomOAuthAppIntegration_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalUpdateCustomOAuthAppIntegration_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdateCustomOAuthAppIntegration_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -437,28 +312,14 @@ export class Client { * Updates an existing published OAuth App Integration. * You can retrieve the published OAuth app integration via :method:PublishedAppIntegration/get. */ - async updatePublishedOAuthAppIntegration( - signal: AbortSignal | undefined, - req: UpdatePublishedOAuthAppIntegration, - options?: Options - ): Promise { + async updatePublishedOAuthAppIntegration(signal: AbortSignal | undefined, req: UpdatePublishedOAuthAppIntegration, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//oauth2/published-app-integrations/${req.integrationId ?? ''}`; - const body = marshalRequest( - req, - marshalUpdatePublishedOAuthAppIntegrationSchema - ); + const body = marshalRequest(req, marshalUpdatePublishedOAuthAppIntegrationSchema); let resp: UpdatePublishedOAuthAppIntegration_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalUpdatePublishedOAuthAppIntegration_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdatePublishedOAuthAppIntegration_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { diff --git a/packages/oauthcustomappintegration/src/v1/index.ts b/packages/oauthcustomappintegration/src/v1/index.ts index 33a2012f..29d73c1f 100644 --- a/packages/oauthcustomappintegration/src/v1/index.ts +++ b/packages/oauthcustomappintegration/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { CreateCustomOAuthAppIntegration, diff --git a/packages/oauthcustomappintegration/src/v1/model.ts b/packages/oauthcustomappintegration/src/v1/model.ts index 8896912a..26bfb6b7 100644 --- a/packages/oauthcustomappintegration/src/v1/model.ts +++ b/packages/oauthcustomappintegration/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; import {z} from 'zod'; @@ -215,235 +216,208 @@ export interface UpdatePublishedOAuthAppIntegration { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. export interface UpdatePublishedOAuthAppIntegration_Response {} -export const unmarshalCreateCustomOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - redirect_urls: z.array(z.string()).optional(), - name: z.string().optional(), - confidential: z.boolean().optional(), - token_access_policy: z - .lazy(() => unmarshalTokenAccessPolicySchema) - .optional(), - scopes: z.array(z.string()).optional(), - user_authorized_scopes: z.array(z.string()).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - redirectUrls: d.redirect_urls, - name: d.name, - confidential: d.confidential, - tokenAccessPolicy: d.token_access_policy, - scopes: d.scopes, - userAuthorizedScopes: d.user_authorized_scopes, - })); - -export const unmarshalCreatePublishedOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - app_id: z.string().optional(), - token_access_policy: z - .lazy(() => unmarshalTokenAccessPolicySchema) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - appId: d.app_id, - tokenAccessPolicy: d.token_access_policy, - })); +export const unmarshalCreateCustomOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + redirect_urls: z.array(z.string()).optional(), + name: z.string().optional(), + confidential: z.boolean().optional(), + token_access_policy: z.lazy(() => unmarshalTokenAccessPolicySchema).optional(), + scopes: z.array(z.string()).optional(), + user_authorized_scopes: z.array(z.string()).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + redirectUrls: d.redirect_urls, + name: d.name, + confidential: d.confidential, + tokenAccessPolicy: d.token_access_policy, + scopes: d.scopes, + userAuthorizedScopes: d.user_authorized_scopes, + })); + +export const unmarshalCreatePublishedOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + app_id: z.string().optional(), + token_access_policy: z.lazy(() => unmarshalTokenAccessPolicySchema).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + appId: d.app_id, + tokenAccessPolicy: d.token_access_policy, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = - z - .object({ - integration_id: z.string().optional(), - }) - .transform(d => ({ - integrationId: d.integration_id, - })); - -export const unmarshalCustomOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - integration_id: z.string().optional(), - client_id: z.string().optional(), - redirect_urls: z.array(z.string()).optional(), - name: z.string().optional(), - confidential: z.boolean().optional(), - token_access_policy: z - .lazy(() => unmarshalTokenAccessPolicySchema) - .optional(), - scopes: z.array(z.string()).optional(), - created_by: z.number().optional(), - create_time: z.string().optional(), - creator_username: z.string().optional(), - user_authorized_scopes: z.array(z.string()).optional(), - principal_id: z.number().optional(), - }) - .transform(d => ({ - integrationId: d.integration_id, - clientId: d.client_id, - redirectUrls: d.redirect_urls, - name: d.name, - confidential: d.confidential, - tokenAccessPolicy: d.token_access_policy, - scopes: d.scopes, - createdBy: d.created_by, - createTime: d.create_time, - creatorUsername: d.creator_username, - userAuthorizedScopes: d.user_authorized_scopes, - principalId: d.principal_id, - })); - -export const unmarshalCustomOAuthAppIntegrationSecretSchema: z.ZodType = - z - .object({ - integration_id: z.string().optional(), - client_id: z.string().optional(), - client_secret: z.string().optional(), - principal_id: z.number().optional(), - client_secret_expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - integrationId: d.integration_id, - clientId: d.client_id, - clientSecret: d.client_secret, - principalId: d.principal_id, - clientSecretExpireTime: d.client_secret_expire_time, - })); - -export const unmarshalDeleteCustomOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - integration_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - integrationId: d.integration_id, - })); +export const unmarshalCreatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + integration_id: z.string().optional(), + }) + .transform(d => ({ + integrationId: d.integration_id, + })); + +export const unmarshalCustomOAuthAppIntegrationSchema: z.ZodType = z + .object({ + integration_id: z.string().optional(), + client_id: z.string().optional(), + redirect_urls: z.array(z.string()).optional(), + name: z.string().optional(), + confidential: z.boolean().optional(), + token_access_policy: z.lazy(() => unmarshalTokenAccessPolicySchema).optional(), + scopes: z.array(z.string()).optional(), + created_by: z.number().optional(), + create_time: z.string().optional(), + creator_username: z.string().optional(), + user_authorized_scopes: z.array(z.string()).optional(), + principal_id: z.number().optional(), + }) + .transform(d => ({ + integrationId: d.integration_id, + clientId: d.client_id, + redirectUrls: d.redirect_urls, + name: d.name, + confidential: d.confidential, + tokenAccessPolicy: d.token_access_policy, + scopes: d.scopes, + createdBy: d.created_by, + createTime: d.create_time, + creatorUsername: d.creator_username, + userAuthorizedScopes: d.user_authorized_scopes, + principalId: d.principal_id, + })); + +export const unmarshalCustomOAuthAppIntegrationSecretSchema: z.ZodType = z + .object({ + integration_id: z.string().optional(), + client_id: z.string().optional(), + client_secret: z.string().optional(), + principal_id: z.number().optional(), + client_secret_expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + integrationId: d.integration_id, + clientId: d.client_id, + clientSecret: d.client_secret, + principalId: d.principal_id, + clientSecretExpireTime: d.client_secret_expire_time, + })); + +export const unmarshalDeleteCustomOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + integration_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + integrationId: d.integration_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteCustomOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeletePublishedOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - integration_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - integrationId: d.integration_id, - })); +export const unmarshalDeleteCustomOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeletePublishedOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + integration_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + integrationId: d.integration_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeletePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalGetCustomOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - integration_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - integrationId: d.integration_id, - })); - -export const unmarshalGetPublishedOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - integration_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - integrationId: d.integration_id, - })); - -export const unmarshalListCustomOAuthAppIntegrationsSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - include_creator_username: z.boolean().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - pageToken: d.page_token, - pageSize: d.page_size, - includeCreatorUsername: d.include_creator_username, - })); +export const unmarshalDeletePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalGetCustomOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + integration_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + integrationId: d.integration_id, + })); + +export const unmarshalGetPublishedOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + integration_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + integrationId: d.integration_id, + })); + +export const unmarshalListCustomOAuthAppIntegrationsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + include_creator_username: z.boolean().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageToken: d.page_token, + pageSize: d.page_size, + includeCreatorUsername: d.include_creator_username, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListCustomOAuthAppIntegrations_ResponseSchema: z.ZodType = - z - .object({ - apps: z - .array(z.lazy(() => unmarshalCustomOAuthAppIntegrationSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - apps: d.apps, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListPublishedOAuthAppIntegrationsSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - pageToken: d.page_token, - pageSize: d.page_size, - })); +export const unmarshalListCustomOAuthAppIntegrations_ResponseSchema: z.ZodType = z + .object({ + apps: z.array(z.lazy(() => unmarshalCustomOAuthAppIntegrationSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + apps: d.apps, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListPublishedOAuthAppIntegrationsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageToken: d.page_token, + pageSize: d.page_size, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListPublishedOAuthAppIntegrations_ResponseSchema: z.ZodType = - z - .object({ - apps: z - .array(z.lazy(() => unmarshalPublishedOAuthAppIntegrationSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - apps: d.apps, - nextPageToken: d.next_page_token, - })); - -export const unmarshalPublishedOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - app_id: z.string().optional(), - integration_id: z.string().optional(), - name: z.string().optional(), - token_access_policy: z - .lazy(() => unmarshalTokenAccessPolicySchema) - .optional(), - created_by: z.number().optional(), - create_time: z.string().optional(), - }) - .transform(d => ({ - appId: d.app_id, - integrationId: d.integration_id, - name: d.name, - tokenAccessPolicy: d.token_access_policy, - createdBy: d.created_by, - createTime: d.create_time, - })); +export const unmarshalListPublishedOAuthAppIntegrations_ResponseSchema: z.ZodType = z + .object({ + apps: z.array(z.lazy(() => unmarshalPublishedOAuthAppIntegrationSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + apps: d.apps, + nextPageToken: d.next_page_token, + })); + +export const unmarshalPublishedOAuthAppIntegrationSchema: z.ZodType = z + .object({ + app_id: z.string().optional(), + integration_id: z.string().optional(), + name: z.string().optional(), + token_access_policy: z.lazy(() => unmarshalTokenAccessPolicySchema).optional(), + created_by: z.number().optional(), + create_time: z.string().optional(), + }) + .transform(d => ({ + appId: d.app_id, + integrationId: d.integration_id, + name: d.name, + tokenAccessPolicy: d.token_access_policy, + createdBy: d.created_by, + createTime: d.create_time, + })); export const unmarshalTokenAccessPolicySchema: z.ZodType = z .object({ @@ -459,49 +433,45 @@ export const unmarshalTokenAccessPolicySchema: z.ZodType = z absoluteSessionLifetimeInMinutes: d.absolute_session_lifetime_in_minutes, })); -export const unmarshalUpdateCustomOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - integration_id: z.string().optional(), - redirect_urls: z.array(z.string()).optional(), - token_access_policy: z - .lazy(() => unmarshalTokenAccessPolicySchema) - .optional(), - scopes: z.array(z.string()).optional(), - user_authorized_scopes: z.array(z.string()).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - integrationId: d.integration_id, - redirectUrls: d.redirect_urls, - tokenAccessPolicy: d.token_access_policy, - scopes: d.scopes, - userAuthorizedScopes: d.user_authorized_scopes, - })); +export const unmarshalUpdateCustomOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + integration_id: z.string().optional(), + redirect_urls: z.array(z.string()).optional(), + token_access_policy: z.lazy(() => unmarshalTokenAccessPolicySchema).optional(), + scopes: z.array(z.string()).optional(), + user_authorized_scopes: z.array(z.string()).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + integrationId: d.integration_id, + redirectUrls: d.redirect_urls, + tokenAccessPolicy: d.token_access_policy, + scopes: d.scopes, + userAuthorizedScopes: d.user_authorized_scopes, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateCustomOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalUpdatePublishedOAuthAppIntegrationSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - integration_id: z.string().optional(), - token_access_policy: z - .lazy(() => unmarshalTokenAccessPolicySchema) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - integrationId: d.integration_id, - tokenAccessPolicy: d.token_access_policy, - })); +export const unmarshalUpdateCustomOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalUpdatePublishedOAuthAppIntegrationSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + integration_id: z.string().optional(), + token_access_policy: z.lazy(() => unmarshalTokenAccessPolicySchema).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + integrationId: d.integration_id, + tokenAccessPolicy: d.token_access_policy, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalUpdatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalCreateCustomOAuthAppIntegrationSchema: z.ZodType = z .object({ @@ -536,14 +506,13 @@ export const marshalCreatePublishedOAuthAppIntegrationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalCreatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = - z - .object({ - integrationId: z.string().optional(), - }) - .transform(d => ({ - integration_id: d.integrationId, - })); +export const marshalCreatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + integrationId: z.string().optional(), + }) + .transform(d => ({ + integration_id: d.integrationId, + })); export const marshalCustomOAuthAppIntegrationSchema: z.ZodType = z .object({ @@ -581,10 +550,7 @@ export const marshalCustomOAuthAppIntegrationSecretSchema: z.ZodType = z clientId: z.string().optional(), clientSecret: z.string().optional(), principalId: z.number().optional(), - clientSecretExpireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + clientSecretExpireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ integration_id: d.integrationId, @@ -605,8 +571,9 @@ export const marshalDeleteCustomOAuthAppIntegrationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteCustomOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeleteCustomOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeletePublishedOAuthAppIntegrationSchema: z.ZodType = z .object({ @@ -619,8 +586,9 @@ export const marshalDeletePublishedOAuthAppIntegrationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeletePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeletePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalGetCustomOAuthAppIntegrationSchema: z.ZodType = z .object({ @@ -659,9 +627,7 @@ export const marshalListCustomOAuthAppIntegrationsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListCustomOAuthAppIntegrations_ResponseSchema: z.ZodType = z .object({ - apps: z - .array(z.lazy(() => marshalCustomOAuthAppIntegrationSchema)) - .optional(), + apps: z.array(z.lazy(() => marshalCustomOAuthAppIntegrationSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -682,18 +648,15 @@ export const marshalListPublishedOAuthAppIntegrationsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalListPublishedOAuthAppIntegrations_ResponseSchema: z.ZodType = - z - .object({ - apps: z - .array(z.lazy(() => marshalPublishedOAuthAppIntegrationSchema)) - .optional(), - nextPageToken: z.string().optional(), - }) - .transform(d => ({ - apps: d.apps, - next_page_token: d.nextPageToken, - })); +export const marshalListPublishedOAuthAppIntegrations_ResponseSchema: z.ZodType = z + .object({ + apps: z.array(z.lazy(() => marshalPublishedOAuthAppIntegrationSchema)).optional(), + nextPageToken: z.string().optional(), + }) + .transform(d => ({ + apps: d.apps, + next_page_token: d.nextPageToken, + })); export const marshalPublishedOAuthAppIntegrationSchema: z.ZodType = z .object({ @@ -746,8 +709,9 @@ export const marshalUpdateCustomOAuthAppIntegrationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalUpdateCustomOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); +export const marshalUpdateCustomOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalUpdatePublishedOAuthAppIntegrationSchema: z.ZodType = z .object({ @@ -762,5 +726,6 @@ export const marshalUpdatePublishedOAuthAppIntegrationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalUpdatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = - z.object({}); +export const marshalUpdatePublishedOAuthAppIntegration_ResponseSchema: z.ZodType = z + .object({ + }); diff --git a/packages/oauthcustomappintegration/src/v1/utils.ts b/packages/oauthcustomappintegration/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/oauthcustomappintegration/src/v1/utils.ts +++ b/packages/oauthcustomappintegration/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/oauthcustomappintegration/tsconfig.json b/packages/oauthcustomappintegration/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/oauthcustomappintegration/tsconfig.json +++ b/packages/oauthcustomappintegration/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/oauthpublishedapp/package.json b/packages/oauthpublishedapp/package.json index b765aedf..3e08b8c6 100644 --- a/packages/oauthpublishedapp/package.json +++ b/packages/oauthpublishedapp/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/oauthpublishedapp/src/v1/client.ts b/packages/oauthpublishedapp/src/v1/client.ts index 6ee2d277..b96c602b 100644 --- a/packages/oauthpublishedapp/src/v1/client.ts +++ b/packages/oauthpublishedapp/src/v1/client.ts @@ -13,7 +13,9 @@ import type { ListPublishedOAuthApps_Response, PublishedOAuthApp, } from './model'; -import {unmarshalListPublishedOAuthApps_ResponseSchema} from './model'; +import { + unmarshalListPublishedOAuthApps_ResponseSchema, +} from './model'; export class Client { private readonly host: string; @@ -30,11 +32,7 @@ export class Client { } /** Get all the available published OAuth apps in . */ - async listPublishedOAuthApps( - signal: AbortSignal | undefined, - req: ListPublishedOAuthApps, - options?: Options - ): Promise { + async listPublishedOAuthApps(signal: AbortSignal | undefined, req: ListPublishedOAuthApps, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts/{account_id}/oauth2/published-apps`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -51,15 +49,8 @@ export class Client { let resp: ListPublishedOAuthApps_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListPublishedOAuthApps_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListPublishedOAuthApps_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -68,11 +59,8 @@ export class Client { return resp; } - async *listPublishedOAuthAppsIter( - signal: AbortSignal | undefined, - req: ListPublishedOAuthApps, - options?: Options - ): AsyncGenerator { + + async *listPublishedOAuthAppsIter(signal: AbortSignal | undefined, req: ListPublishedOAuthApps, options?: Options): AsyncGenerator { const pageReq: ListPublishedOAuthApps = {...req}; for (;;) { const resp = await this.listPublishedOAuthApps(signal, pageReq, options); @@ -85,4 +73,5 @@ export class Client { pageReq.pageToken = resp.nextPageToken; } } + } diff --git a/packages/oauthpublishedapp/src/v1/index.ts b/packages/oauthpublishedapp/src/v1/index.ts index fe9b2c65..7ca847f3 100644 --- a/packages/oauthpublishedapp/src/v1/index.ts +++ b/packages/oauthpublishedapp/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { ListPublishedOAuthApps, diff --git a/packages/oauthpublishedapp/src/v1/model.ts b/packages/oauthpublishedapp/src/v1/model.ts index 48509e6c..1efb46e5 100644 --- a/packages/oauthpublishedapp/src/v1/model.ts +++ b/packages/oauthpublishedapp/src/v1/model.ts @@ -36,30 +36,28 @@ export interface PublishedOAuthApp { scopes?: string[] | undefined; } -export const unmarshalListPublishedOAuthAppsSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - pageToken: d.page_token, - pageSize: d.page_size, - })); +export const unmarshalListPublishedOAuthAppsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageToken: d.page_token, + pageSize: d.page_size, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListPublishedOAuthApps_ResponseSchema: z.ZodType = - z - .object({ - apps: z.array(z.lazy(() => unmarshalPublishedOAuthAppSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - apps: d.apps, - nextPageToken: d.next_page_token, - })); +export const unmarshalListPublishedOAuthApps_ResponseSchema: z.ZodType = z + .object({ + apps: z.array(z.lazy(() => unmarshalPublishedOAuthAppSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + apps: d.apps, + nextPageToken: d.next_page_token, + })); export const unmarshalPublishedOAuthAppSchema: z.ZodType = z .object({ diff --git a/packages/oauthpublishedapp/src/v1/utils.ts b/packages/oauthpublishedapp/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/oauthpublishedapp/src/v1/utils.ts +++ b/packages/oauthpublishedapp/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/oauthpublishedapp/tsconfig.json b/packages/oauthpublishedapp/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/oauthpublishedapp/tsconfig.json +++ b/packages/oauthpublishedapp/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/permissions/package.json b/packages/permissions/package.json index f8b91f6a..d30078bc 100644 --- a/packages/permissions/package.json +++ b/packages/permissions/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/permissions/src/v1/client.ts b/packages/permissions/src/v1/client.ts index 2b065711..f2675597 100644 --- a/packages/permissions/src/v1/client.ts +++ b/packages/permissions/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { GetObjectPermissions, GetPermissionLevels, @@ -43,20 +38,12 @@ export class Client { } /** Gets the permissions of an object. Objects can inherit permissions from their parent objects or root object. */ - async getObjectPermissions( - signal: AbortSignal | undefined, - req: GetObjectPermissions, - options?: Options - ): Promise { + async getObjectPermissions(signal: AbortSignal | undefined, req: GetObjectPermissions, options?: Options): Promise { const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`; let resp: PermissionsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPermissionsResponseSchema); }; await execute(signal, call, options); @@ -67,24 +54,13 @@ export class Client { } /** Gets the permission levels that a user can have on an object. */ - async getPermissionLevels( - signal: AbortSignal | undefined, - req: GetPermissionLevels, - options?: Options - ): Promise { + async getPermissionLevels(signal: AbortSignal | undefined, req: GetPermissionLevels, options?: Options): Promise { const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}/permissionLevels`; let resp: GetPermissionLevels_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetPermissionLevels_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetPermissionLevels_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -94,21 +70,13 @@ export class Client { } /** 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 parent objects or root object. */ - async setObjectPermissions( - signal: AbortSignal | undefined, - req: SetObjectPermissions, - options?: Options - ): Promise { + async setObjectPermissions(signal: AbortSignal | undefined, req: SetObjectPermissions, options?: Options): Promise { const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`; const body = marshalRequest(req, marshalSetObjectPermissionsSchema); let resp: PermissionsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPermissionsResponseSchema); }; await execute(signal, call, options); @@ -119,21 +87,13 @@ export class Client { } /** Updates the permissions on an object. Objects can inherit permissions from their parent objects or root object. */ - async updateObjectPermissions( - signal: AbortSignal | undefined, - req: UpdateObjectPermissions, - options?: Options - ): Promise { + async updateObjectPermissions(signal: AbortSignal | undefined, req: UpdateObjectPermissions, options?: Options): Promise { const url = `${this.host}/api/2.0/permissions/${req.requestObjectType ?? ''}/${req.requestObjectId ?? ''}`; const body = marshalRequest(req, marshalUpdateObjectPermissionsSchema); let resp: PermissionsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalPermissionsResponseSchema); }; await execute(signal, call, options); diff --git a/packages/permissions/src/v1/index.ts b/packages/permissions/src/v1/index.ts index 4361f0e8..1662a544 100644 --- a/packages/permissions/src/v1/index.ts +++ b/packages/permissions/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {PermissionLevel} from './model'; +export { + PermissionLevel, +} from './model'; export type { AccessControlRequest, diff --git a/packages/permissions/src/v1/model.ts b/packages/permissions/src/v1/model.ts index 9f34eab0..4fa2c8a0 100644 --- a/packages/permissions/src/v1/model.ts +++ b/packages/permissions/src/v1/model.ts @@ -106,73 +106,64 @@ export interface UpdateObjectPermissions { accessControlList?: AccessControlRequest[] | undefined; } -export const unmarshalAccessControlRequestSchema: z.ZodType = - z - .object({ - user_name: z.string().optional(), - group_name: z.string().optional(), - service_principal_name: z.string().optional(), - permission_level: z.enum(PermissionLevel).optional(), - }) - .transform(d => ({ - userName: d.user_name, - groupName: d.group_name, - servicePrincipalName: d.service_principal_name, - permissionLevel: d.permission_level, - })); - -export const unmarshalAccessControlResponseSchema: z.ZodType = - z - .object({ - user_name: z.string().optional(), - group_name: z.string().optional(), - service_principal_name: z.string().optional(), - display_name: z.string().optional(), - all_permissions: z - .array(z.lazy(() => unmarshalPermissionSchema)) - .optional(), - }) - .transform(d => ({ - userName: d.user_name, - groupName: d.group_name, - servicePrincipalName: d.service_principal_name, - displayName: d.display_name, - allPermissions: d.all_permissions, - })); - -export const unmarshalGetObjectPermissionsSchema: z.ZodType = - z - .object({ - request_object_type: z.string().optional(), - request_object_id: z.string().optional(), - }) - .transform(d => ({ - requestObjectType: d.request_object_type, - requestObjectId: d.request_object_id, - })); - -export const unmarshalGetPermissionLevelsSchema: z.ZodType = - z - .object({ - request_object_type: z.string().optional(), - request_object_id: z.string().optional(), - }) - .transform(d => ({ - requestObjectType: d.request_object_type, - requestObjectId: d.request_object_id, - })); +export const unmarshalAccessControlRequestSchema: z.ZodType = z + .object({ + user_name: z.string().optional(), + group_name: z.string().optional(), + service_principal_name: z.string().optional(), + permission_level: z.enum(PermissionLevel).optional(), + }) + .transform(d => ({ + userName: d.user_name, + groupName: d.group_name, + servicePrincipalName: d.service_principal_name, + permissionLevel: d.permission_level, + })); + +export const unmarshalAccessControlResponseSchema: z.ZodType = z + .object({ + user_name: z.string().optional(), + group_name: z.string().optional(), + service_principal_name: z.string().optional(), + display_name: z.string().optional(), + all_permissions: z.array(z.lazy(() => unmarshalPermissionSchema)).optional(), + }) + .transform(d => ({ + userName: d.user_name, + groupName: d.group_name, + servicePrincipalName: d.service_principal_name, + displayName: d.display_name, + allPermissions: d.all_permissions, + })); + +export const unmarshalGetObjectPermissionsSchema: z.ZodType = z + .object({ + request_object_type: z.string().optional(), + request_object_id: z.string().optional(), + }) + .transform(d => ({ + requestObjectType: d.request_object_type, + requestObjectId: d.request_object_id, + })); + +export const unmarshalGetPermissionLevelsSchema: z.ZodType = z + .object({ + request_object_type: z.string().optional(), + request_object_id: z.string().optional(), + }) + .transform(d => ({ + requestObjectType: d.request_object_type, + requestObjectId: d.request_object_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetPermissionLevels_ResponseSchema: z.ZodType = - z - .object({ - permission_levels: z - .array(z.lazy(() => unmarshalPermissionsDescriptionSchema)) - .optional(), - }) - .transform(d => ({ - permissionLevels: d.permission_levels, - })); +export const unmarshalGetPermissionLevels_ResponseSchema: z.ZodType = z + .object({ + permission_levels: z.array(z.lazy(() => unmarshalPermissionsDescriptionSchema)).optional(), + }) + .transform(d => ({ + permissionLevels: d.permission_levels, + })); export const unmarshalPermissionSchema: z.ZodType = z .object({ @@ -186,61 +177,51 @@ export const unmarshalPermissionSchema: z.ZodType = z inheritedFromObject: d.inherited_from_object, })); -export const unmarshalPermissionsDescriptionSchema: z.ZodType = - z - .object({ - permission_level: z.enum(PermissionLevel).optional(), - description: z.string().optional(), - }) - .transform(d => ({ - permissionLevel: d.permission_level, - description: d.description, - })); - -export const unmarshalPermissionsResponseSchema: z.ZodType = - z - .object({ - object_id: z.string().optional(), - object_type: z.string().optional(), - access_control_list: z - .array(z.lazy(() => unmarshalAccessControlResponseSchema)) - .optional(), - }) - .transform(d => ({ - objectId: d.object_id, - objectType: d.object_type, - accessControlList: d.access_control_list, - })); - -export const unmarshalSetObjectPermissionsSchema: z.ZodType = - z - .object({ - request_object_type: z.string().optional(), - request_object_id: z.string().optional(), - access_control_list: z - .array(z.lazy(() => unmarshalAccessControlRequestSchema)) - .optional(), - }) - .transform(d => ({ - requestObjectType: d.request_object_type, - requestObjectId: d.request_object_id, - accessControlList: d.access_control_list, - })); - -export const unmarshalUpdateObjectPermissionsSchema: z.ZodType = - z - .object({ - request_object_type: z.string().optional(), - request_object_id: z.string().optional(), - access_control_list: z - .array(z.lazy(() => unmarshalAccessControlRequestSchema)) - .optional(), - }) - .transform(d => ({ - requestObjectType: d.request_object_type, - requestObjectId: d.request_object_id, - accessControlList: d.access_control_list, - })); +export const unmarshalPermissionsDescriptionSchema: z.ZodType = z + .object({ + permission_level: z.enum(PermissionLevel).optional(), + description: z.string().optional(), + }) + .transform(d => ({ + permissionLevel: d.permission_level, + description: d.description, + })); + +export const unmarshalPermissionsResponseSchema: z.ZodType = z + .object({ + object_id: z.string().optional(), + object_type: z.string().optional(), + access_control_list: z.array(z.lazy(() => unmarshalAccessControlResponseSchema)).optional(), + }) + .transform(d => ({ + objectId: d.object_id, + objectType: d.object_type, + accessControlList: d.access_control_list, + })); + +export const unmarshalSetObjectPermissionsSchema: z.ZodType = z + .object({ + request_object_type: z.string().optional(), + request_object_id: z.string().optional(), + access_control_list: z.array(z.lazy(() => unmarshalAccessControlRequestSchema)).optional(), + }) + .transform(d => ({ + requestObjectType: d.request_object_type, + requestObjectId: d.request_object_id, + accessControlList: d.access_control_list, + })); + +export const unmarshalUpdateObjectPermissionsSchema: z.ZodType = z + .object({ + request_object_type: z.string().optional(), + request_object_id: z.string().optional(), + access_control_list: z.array(z.lazy(() => unmarshalAccessControlRequestSchema)).optional(), + }) + .transform(d => ({ + requestObjectType: d.request_object_type, + requestObjectId: d.request_object_id, + accessControlList: d.access_control_list, + })); export const marshalAccessControlRequestSchema: z.ZodType = z .object({ @@ -295,9 +276,7 @@ export const marshalGetPermissionLevelsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalGetPermissionLevels_ResponseSchema: z.ZodType = z .object({ - permissionLevels: z - .array(z.lazy(() => marshalPermissionsDescriptionSchema)) - .optional(), + permissionLevels: z.array(z.lazy(() => marshalPermissionsDescriptionSchema)).optional(), }) .transform(d => ({ permission_levels: d.permissionLevels, @@ -329,9 +308,7 @@ export const marshalPermissionsResponseSchema: z.ZodType = z .object({ objectId: z.string().optional(), objectType: z.string().optional(), - accessControlList: z - .array(z.lazy(() => marshalAccessControlResponseSchema)) - .optional(), + accessControlList: z.array(z.lazy(() => marshalAccessControlResponseSchema)).optional(), }) .transform(d => ({ object_id: d.objectId, @@ -343,9 +320,7 @@ export const marshalSetObjectPermissionsSchema: z.ZodType = z .object({ requestObjectType: z.string().optional(), requestObjectId: z.string().optional(), - accessControlList: z - .array(z.lazy(() => marshalAccessControlRequestSchema)) - .optional(), + accessControlList: z.array(z.lazy(() => marshalAccessControlRequestSchema)).optional(), }) .transform(d => ({ request_object_type: d.requestObjectType, @@ -357,9 +332,7 @@ export const marshalUpdateObjectPermissionsSchema: z.ZodType = z .object({ requestObjectType: z.string().optional(), requestObjectId: z.string().optional(), - accessControlList: z - .array(z.lazy(() => marshalAccessControlRequestSchema)) - .optional(), + accessControlList: z.array(z.lazy(() => marshalAccessControlRequestSchema)).optional(), }) .transform(d => ({ request_object_type: d.requestObjectType, diff --git a/packages/permissions/src/v1/utils.ts b/packages/permissions/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/permissions/src/v1/utils.ts +++ b/packages/permissions/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/permissions/tsconfig.json b/packages/permissions/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/permissions/tsconfig.json +++ b/packages/permissions/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/policyfamilies/package.json b/packages/policyfamilies/package.json new file mode 100644 index 00000000..af4a94d1 --- /dev/null +++ b/packages/policyfamilies/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-policyfamilies", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v2": { + "types": "./dist/v2/index.d.ts", + "import": "./dist/v2/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/policyfamilies/src/v2/client.ts b/packages/policyfamilies/src/v2/client.ts new file mode 100644 index 00000000..b43978ce --- /dev/null +++ b/packages/policyfamilies/src/v2/client.ts @@ -0,0 +1,98 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, parseResponse} from './utils'; +import type { + GetPolicyFamily, + ListPolicyFamilies, + ListPolicyFamilies_Response, + PolicyFamily, +} from './model'; +import { + unmarshalListPolicyFamilies_ResponseSchema, + unmarshalPolicyFamilySchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** Retrieve the information for an policy family based on its identifier and version */ + async getPolicyFamily(signal: AbortSignal | undefined, req: GetPolicyFamily, options?: Options): Promise { + const url = `${this.host}/api/2.0/policy-families/${req.policyFamilyId ?? ''}`; + const params = new URLSearchParams(); + if (req.version !== undefined) { + params.append('version', String(req.version)); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: PolicyFamily | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalPolicyFamilySchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Returns the list of policy definition types available to use at their latest version. This API is paginated. */ + async listPolicyFamilies(signal: AbortSignal | undefined, req: ListPolicyFamilies, options?: Options): Promise { + const url = `${this.host}/api/2.0/policy-families`; + const params = new URLSearchParams(); + if (req.maxResults !== undefined) { + params.append('max_results', String(req.maxResults)); + } + if (req.pageToken !== undefined) { + params.append('page_token', req.pageToken); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListPolicyFamilies_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListPolicyFamilies_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + + async *listPolicyFamiliesIter(signal: AbortSignal | undefined, req: ListPolicyFamilies, options?: Options): AsyncGenerator { + const pageReq: ListPolicyFamilies = {...req}; + for (;;) { + const resp = await this.listPolicyFamilies(signal, pageReq, options); + for (const item of resp.policyFamilies ?? []) { + yield item; + } + if (resp.nextPageToken === undefined || resp.nextPageToken === '') { + return; + } + pageReq.pageToken = resp.nextPageToken; + } + } + +} diff --git a/packages/policyfamilies/src/v2/index.ts b/packages/policyfamilies/src/v2/index.ts new file mode 100644 index 00000000..602f142c --- /dev/null +++ b/packages/policyfamilies/src/v2/index.ts @@ -0,0 +1,14 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { +} from './model'; + +export type { + GetPolicyFamily, + ListPolicyFamilies, + ListPolicyFamilies_Response, + PolicyFamily, +} from './model'; diff --git a/packages/policyfamilies/src/v2/model.ts b/packages/policyfamilies/src/v2/model.ts new file mode 100644 index 00000000..627c4bb4 --- /dev/null +++ b/packages/policyfamilies/src/v2/model.ts @@ -0,0 +1,128 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +/** Returns the details of a policy family at a specific version */ +export interface GetPolicyFamily { + /** The family ID about which to retrieve information. */ + policyFamilyId?: string | undefined; + /** The version number for the family to fetch. Defaults to the latest version. */ + version?: number | undefined; +} + +/** Returns the list of policy families available to use at their latest version */ +export interface ListPolicyFamilies { + /** Maximum number of policy families to return. */ + maxResults?: number | undefined; + /** A token that can be used to get the next page of results. */ + pageToken?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListPolicyFamilies_Response { + /** List of policy families. */ + policyFamilies?: PolicyFamily[] | undefined; + /** 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 | undefined; +} + +export interface PolicyFamily { + /** Unique identifier for the policy family. */ + policyFamilyId?: string | undefined; + /** Name of the policy family. */ + name?: string | undefined; + /** Human-readable description of the purpose of the policy family. */ + description?: string | undefined; + /** Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html). */ + definition?: string | undefined; +} + +export const unmarshalGetPolicyFamilySchema: z.ZodType = z + .object({ + policy_family_id: z.string().optional(), + version: z.number().optional(), + }) + .transform(d => ({ + policyFamilyId: d.policy_family_id, + version: d.version, + })); + +export const unmarshalListPolicyFamiliesSchema: z.ZodType = z + .object({ + max_results: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + maxResults: d.max_results, + pageToken: d.page_token, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListPolicyFamilies_ResponseSchema: z.ZodType = z + .object({ + policy_families: z.array(z.lazy(() => unmarshalPolicyFamilySchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + policyFamilies: d.policy_families, + nextPageToken: d.next_page_token, + })); + +export const unmarshalPolicyFamilySchema: z.ZodType = z + .object({ + policy_family_id: z.string().optional(), + name: z.string().optional(), + description: z.string().optional(), + definition: z.string().optional(), + }) + .transform(d => ({ + policyFamilyId: d.policy_family_id, + name: d.name, + description: d.description, + definition: d.definition, + })); + +export const marshalGetPolicyFamilySchema: z.ZodType = z + .object({ + policyFamilyId: z.string().optional(), + version: z.number().optional(), + }) + .transform(d => ({ + policy_family_id: d.policyFamilyId, + version: d.version, + })); + +export const marshalListPolicyFamiliesSchema: z.ZodType = z + .object({ + maxResults: z.number().optional(), + pageToken: z.string().optional(), + }) + .transform(d => ({ + max_results: d.maxResults, + page_token: d.pageToken, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListPolicyFamilies_ResponseSchema: z.ZodType = z + .object({ + policyFamilies: z.array(z.lazy(() => marshalPolicyFamilySchema)).optional(), + nextPageToken: z.string().optional(), + }) + .transform(d => ({ + policy_families: d.policyFamilies, + next_page_token: d.nextPageToken, + })); + +export const marshalPolicyFamilySchema: z.ZodType = z + .object({ + policyFamilyId: z.string().optional(), + name: z.string().optional(), + description: z.string().optional(), + definition: z.string().optional(), + }) + .transform(d => ({ + policy_family_id: d.policyFamilyId, + name: d.name, + description: d.description, + definition: d.definition, + })); diff --git a/packages/policyfamilies/src/v2/utils.ts b/packages/policyfamilies/src/v2/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/policyfamilies/src/v2/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/policyfamilies/tsconfig.json b/packages/policyfamilies/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/policyfamilies/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/postgres/package.json b/packages/postgres/package.json index f1e5c81f..4782ec87 100644 --- a/packages/postgres/package.json +++ b/packages/postgres/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/postgres/src/v1/client.ts b/packages/postgres/src/v1/client.ts index b2960fa6..4f6fcfe4 100644 --- a/packages/postgres/src/v1/client.ts +++ b/packages/postgres/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import {z} from 'zod'; import type { Branch, @@ -140,11 +135,7 @@ export class Client { } /** Creates a new database branch in the project. */ - async createBranch( - signal: AbortSignal | undefined, - req: CreateBranchRequest, - options?: Options - ): Promise { + async createBranch(signal: AbortSignal | undefined, req: CreateBranchRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/branches`; const params = new URLSearchParams(); if (req.branchId !== undefined) { @@ -156,11 +147,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -170,21 +157,17 @@ export class Client { return resp; } - async createBranchOperation( - signal: AbortSignal | undefined, - req: CreateBranchRequest, - options?: Options - ): Promise { - const op = await this.createBranch(signal, req, options); - return new CreateBranchOperation(this, op); - } +async createBranchOperation( + signal: AbortSignal | undefined, + req: CreateBranchRequest, + options?: Options +): Promise { + const op = await this.createBranch(signal, req, options); + return new CreateBranchOperation(this, op); +} /** Register a Postgres database in the Unity Catalog. */ - async createCatalog( - signal: AbortSignal | undefined, - req: CreateCatalogRequest, - options?: Options - ): Promise { + async createCatalog(signal: AbortSignal | undefined, req: CreateCatalogRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/catalogs`; const params = new URLSearchParams(); if (req.catalogId !== undefined) { @@ -196,11 +179,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -210,25 +189,21 @@ export class Client { return resp; } - async createCatalogOperation( - signal: AbortSignal | undefined, - req: CreateCatalogRequest, - options?: Options - ): Promise { - const op = await this.createCatalog(signal, req, options); - return new CreateCatalogOperation(this, op); - } +async createCatalogOperation( + signal: AbortSignal | undefined, + req: CreateCatalogRequest, + options?: Options +): Promise { + const op = await this.createCatalog(signal, req, options); + return new CreateCatalogOperation(this, op); +} /** * Create a Database. - * + * * Creates a database in the specified branch. A branch can have multiple databases. */ - async createDatabase( - signal: AbortSignal | undefined, - req: CreateDatabaseRequest, - options?: Options - ): Promise { + async createDatabase(signal: AbortSignal | undefined, req: CreateDatabaseRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/databases`; const params = new URLSearchParams(); if (req.databaseId !== undefined) { @@ -240,11 +215,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -254,21 +225,17 @@ export class Client { return resp; } - async createDatabaseOperation( - signal: AbortSignal | undefined, - req: CreateDatabaseRequest, - options?: Options - ): Promise { - const op = await this.createDatabase(signal, req, options); - return new CreateDatabaseOperation(this, op); - } +async createDatabaseOperation( + signal: AbortSignal | undefined, + req: CreateDatabaseRequest, + options?: Options +): Promise { + const op = await this.createDatabase(signal, req, options); + return new CreateDatabaseOperation(this, op); +} /** Creates a new compute endpoint in the branch. */ - async createEndpoint( - signal: AbortSignal | undefined, - req: CreateEndpointRequest, - options?: Options - ): Promise { + async createEndpoint(signal: AbortSignal | undefined, req: CreateEndpointRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/endpoints`; const params = new URLSearchParams(); if (req.endpointId !== undefined) { @@ -280,11 +247,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -294,21 +257,17 @@ export class Client { return resp; } - async createEndpointOperation( - signal: AbortSignal | undefined, - req: CreateEndpointRequest, - options?: Options - ): Promise { - const op = await this.createEndpoint(signal, req, options); - return new CreateEndpointOperation(this, op); - } +async createEndpointOperation( + signal: AbortSignal | undefined, + req: CreateEndpointRequest, + options?: Options +): Promise { + const op = await this.createEndpoint(signal, req, options); + return new CreateEndpointOperation(this, op); +} /** Creates a new Lakebase Autoscaling Postgres database project, which contains branches and compute endpoints. */ - async createProject( - signal: AbortSignal | undefined, - req: CreateProjectRequest, - options?: Options - ): Promise { + async createProject(signal: AbortSignal | undefined, req: CreateProjectRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/projects`; const params = new URLSearchParams(); if (req.projectId !== undefined) { @@ -320,11 +279,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -334,21 +289,17 @@ export class Client { return resp; } - async createProjectOperation( - signal: AbortSignal | undefined, - req: CreateProjectRequest, - options?: Options - ): Promise { - const op = await this.createProject(signal, req, options); - return new CreateProjectOperation(this, op); - } +async createProjectOperation( + signal: AbortSignal | undefined, + req: CreateProjectRequest, + options?: Options +): Promise { + const op = await this.createProject(signal, req, options); + return new CreateProjectOperation(this, op); +} /** Creates a new Postgres role in the branch. */ - async createRole( - signal: AbortSignal | undefined, - req: CreateRoleRequest, - options?: Options - ): Promise { + async createRole(signal: AbortSignal | undefined, req: CreateRoleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/roles`; const params = new URLSearchParams(); if (req.roleId !== undefined) { @@ -360,11 +311,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -374,21 +321,17 @@ export class Client { return resp; } - async createRoleOperation( - signal: AbortSignal | undefined, - req: CreateRoleRequest, - options?: Options - ): Promise { - const op = await this.createRole(signal, req, options); - return new CreateRoleOperation(this, op); - } +async createRoleOperation( + signal: AbortSignal | undefined, + req: CreateRoleRequest, + options?: Options +): Promise { + const op = await this.createRole(signal, req, options); + return new CreateRoleOperation(this, op); +} /** Create a Synced Table. */ - async createSyncedTable( - signal: AbortSignal | undefined, - req: CreateSyncedTableRequest, - options?: Options - ): Promise { + async createSyncedTable(signal: AbortSignal | undefined, req: CreateSyncedTableRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/synced_tables`; const params = new URLSearchParams(); if (req.syncedTableId !== undefined) { @@ -400,11 +343,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -414,31 +353,23 @@ export class Client { return resp; } - async createSyncedTableOperation( - signal: AbortSignal | undefined, - req: CreateSyncedTableRequest, - options?: Options - ): Promise { - const op = await this.createSyncedTable(signal, req, options); - return new CreateSyncedTableOperation(this, op); - } +async createSyncedTableOperation( + signal: AbortSignal | undefined, + req: CreateSyncedTableRequest, + options?: Options +): Promise { + const op = await this.createSyncedTable(signal, req, options); + return new CreateSyncedTableOperation(this, op); +} /** Create a Table (non-synced database table for Autoscaling v2 Lakebase projects). */ - async createTable( - signal: AbortSignal | undefined, - req: CreateTableRequest, - options?: Options - ): Promise { + async createTable(signal: AbortSignal | undefined, req: CreateTableRequest, options?: Options): Promise
{ const url = `${this.host}/api/2.0/postgres/tables`; const body = marshalRequest(req.table, marshalTableSchema); let resp: Table | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTableSchema); }; await execute(signal, call, options); @@ -449,11 +380,7 @@ export class Client { } /** Deletes the specified database branch. */ - async deleteBranch( - signal: AbortSignal | undefined, - req: DeleteBranchRequest, - options?: Options - ): Promise { + async deleteBranch(signal: AbortSignal | undefined, req: DeleteBranchRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.purge !== undefined) { @@ -467,11 +394,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -481,30 +404,22 @@ export class Client { return resp; } - async deleteBranchOperation( - signal: AbortSignal | undefined, - req: DeleteBranchRequest, - options?: Options - ): Promise { - const op = await this.deleteBranch(signal, req, options); - return new DeleteBranchOperation(this, op); - } +async deleteBranchOperation( + signal: AbortSignal | undefined, + req: DeleteBranchRequest, + options?: Options +): Promise { + const op = await this.deleteBranch(signal, req, options); + return new DeleteBranchOperation(this, op); +} /** Delete a Database Catalog. */ - async deleteCatalog( - signal: AbortSignal | undefined, - req: DeleteCatalogRequest, - options?: Options - ): Promise { + async deleteCatalog(signal: AbortSignal | undefined, req: DeleteCatalogRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -514,30 +429,22 @@ export class Client { return resp; } - async deleteCatalogOperation( - signal: AbortSignal | undefined, - req: DeleteCatalogRequest, - options?: Options - ): Promise { - const op = await this.deleteCatalog(signal, req, options); - return new DeleteCatalogOperation(this, op); - } +async deleteCatalogOperation( + signal: AbortSignal | undefined, + req: DeleteCatalogRequest, + options?: Options +): Promise { + const op = await this.deleteCatalog(signal, req, options); + return new DeleteCatalogOperation(this, op); +} /** Delete a Database. */ - async deleteDatabase( - signal: AbortSignal | undefined, - req: DeleteDatabaseRequest, - options?: Options - ): Promise { + async deleteDatabase(signal: AbortSignal | undefined, req: DeleteDatabaseRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -547,30 +454,22 @@ export class Client { return resp; } - async deleteDatabaseOperation( - signal: AbortSignal | undefined, - req: DeleteDatabaseRequest, - options?: Options - ): Promise { - const op = await this.deleteDatabase(signal, req, options); - return new DeleteDatabaseOperation(this, op); - } +async deleteDatabaseOperation( + signal: AbortSignal | undefined, + req: DeleteDatabaseRequest, + options?: Options +): Promise { + const op = await this.deleteDatabase(signal, req, options); + return new DeleteDatabaseOperation(this, op); +} /** Deletes the specified compute endpoint. */ - async deleteEndpoint( - signal: AbortSignal | undefined, - req: DeleteEndpointRequest, - options?: Options - ): Promise { + async deleteEndpoint(signal: AbortSignal | undefined, req: DeleteEndpointRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -580,30 +479,28 @@ export class Client { return resp; } - async deleteEndpointOperation( - signal: AbortSignal | undefined, - req: DeleteEndpointRequest, - options?: Options - ): Promise { - const op = await this.deleteEndpoint(signal, req, options); - return new DeleteEndpointOperation(this, op); - } +async deleteEndpointOperation( + signal: AbortSignal | undefined, + req: DeleteEndpointRequest, + options?: Options +): Promise { + const op = await this.deleteEndpoint(signal, req, options); + return new DeleteEndpointOperation(this, op); +} /** Deletes the specified database project. */ - async deleteProject( - signal: AbortSignal | undefined, - req: DeleteProjectRequest, - options?: Options - ): Promise { + async deleteProject(signal: AbortSignal | undefined, req: DeleteProjectRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; + const params = new URLSearchParams(); + if (req.purge !== undefined) { + params.append('purge', String(req.purge)); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { - const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -613,21 +510,17 @@ export class Client { return resp; } - async deleteProjectOperation( - signal: AbortSignal | undefined, - req: DeleteProjectRequest, - options?: Options - ): Promise { - const op = await this.deleteProject(signal, req, options); - return new DeleteProjectOperation(this, op); - } +async deleteProjectOperation( + signal: AbortSignal | undefined, + req: DeleteProjectRequest, + options?: Options +): Promise { + const op = await this.deleteProject(signal, req, options); + return new DeleteProjectOperation(this, op); +} /** Deletes the specified Postgres role. */ - async deleteRole( - signal: AbortSignal | undefined, - req: DeleteRoleRequest, - options?: Options - ): Promise { + async deleteRole(signal: AbortSignal | undefined, req: DeleteRoleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.reassignOwnedTo !== undefined) { @@ -638,11 +531,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -652,30 +541,22 @@ export class Client { return resp; } - async deleteRoleOperation( - signal: AbortSignal | undefined, - req: DeleteRoleRequest, - options?: Options - ): Promise { - const op = await this.deleteRole(signal, req, options); - return new DeleteRoleOperation(this, op); - } +async deleteRoleOperation( + signal: AbortSignal | undefined, + req: DeleteRoleRequest, + options?: Options +): Promise { + const op = await this.deleteRole(signal, req, options); + return new DeleteRoleOperation(this, op); +} /** Delete a Synced Table. */ - async deleteSyncedTable( - signal: AbortSignal | undefined, - req: DeleteSyncedTableRequest, - options?: Options - ): Promise { + async deleteSyncedTable(signal: AbortSignal | undefined, req: DeleteSyncedTableRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -685,39 +566,27 @@ export class Client { return resp; } - async deleteSyncedTableOperation( - signal: AbortSignal | undefined, - req: DeleteSyncedTableRequest, - options?: Options - ): Promise { - const op = await this.deleteSyncedTable(signal, req, options); - return new DeleteSyncedTableOperation(this, op); - } +async deleteSyncedTableOperation( + signal: AbortSignal | undefined, + req: DeleteSyncedTableRequest, + options?: Options +): Promise { + const op = await this.deleteSyncedTable(signal, req, options); + return new DeleteSyncedTableOperation(this, op); +} /** Delete a Table (non-synced database table for Autoscaling v2 Lakebase projects). */ - async deleteTable( - signal: AbortSignal | undefined, - req: DeleteTableRequest, - options?: Options - ): Promise { + async deleteTable(signal: AbortSignal | undefined, req: DeleteTableRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/tables/${req.name ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Disable Forward ETL for a branch. */ - async disableForwardEtl( - signal: AbortSignal | undefined, - req: DisableForwardEtlRequest, - options?: Options - ): Promise { + async disableForwardEtl(signal: AbortSignal | undefined, req: DisableForwardEtlRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/forward-etl`; const params = new URLSearchParams(); if (req.tenantId !== undefined) { @@ -737,11 +606,7 @@ export class Client { let resp: DisableForwardEtlResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDisableForwardEtlResponseSchema); }; await execute(signal, call, options); @@ -752,24 +617,13 @@ export class Client { } /** Generate OAuth credentials for a Postgres database. */ - async generateDatabaseCredential( - signal: AbortSignal | undefined, - req: GenerateDatabaseCredentialRequest, - options?: Options - ): Promise { + async generateDatabaseCredential(signal: AbortSignal | undefined, req: GenerateDatabaseCredentialRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/credentials`; - const body = marshalRequest( - req, - marshalGenerateDatabaseCredentialRequestSchema - ); + const body = marshalRequest(req, marshalGenerateDatabaseCredentialRequestSchema); let resp: DatabaseCredential | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDatabaseCredentialSchema); }; await execute(signal, call, options); @@ -780,20 +634,12 @@ export class Client { } /** Retrieves information about the specified database branch. */ - async getBranch( - signal: AbortSignal | undefined, - req: GetBranchRequest, - options?: Options - ): Promise { + async getBranch(signal: AbortSignal | undefined, req: GetBranchRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Branch | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalBranchSchema); }; await execute(signal, call, options); @@ -804,20 +650,12 @@ export class Client { } /** Get a Database Catalog. */ - async getCatalog( - signal: AbortSignal | undefined, - req: GetCatalogRequest, - options?: Options - ): Promise { + async getCatalog(signal: AbortSignal | undefined, req: GetCatalogRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Catalog | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCatalogSchema); }; await execute(signal, call, options); @@ -831,20 +669,12 @@ export class Client { * Lists the specific compute instance under an endpoint. * Note: ComputeInstances are managed via the parent Endpoint resource, and cannot be created, updated, or deleted directly. */ - async getComputeInstance( - signal: AbortSignal | undefined, - req: GetComputeInstanceRequest, - options?: Options - ): Promise { + async getComputeInstance(signal: AbortSignal | undefined, req: GetComputeInstanceRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: ComputeInstance | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalComputeInstanceSchema); }; await execute(signal, call, options); @@ -855,20 +685,12 @@ export class Client { } /** Get a Database. */ - async getDatabase( - signal: AbortSignal | undefined, - req: GetDatabaseRequest, - options?: Options - ): Promise { + async getDatabase(signal: AbortSignal | undefined, req: GetDatabaseRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Database | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDatabaseSchema); }; await execute(signal, call, options); @@ -879,20 +701,12 @@ export class Client { } /** Retrieves information about the specified compute endpoint, including its connection details and operational state. */ - async getEndpoint( - signal: AbortSignal | undefined, - req: GetEndpointRequest, - options?: Options - ): Promise { + async getEndpoint(signal: AbortSignal | undefined, req: GetEndpointRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Endpoint | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEndpointSchema); }; await execute(signal, call, options); @@ -903,11 +717,7 @@ export class Client { } /** Get Forward ETL metadata (database and schema OIDs). */ - async getForwardEtlMetadata( - signal: AbortSignal | undefined, - req: GetForwardEtlMetadataRequest, - options?: Options - ): Promise { + async getForwardEtlMetadata(signal: AbortSignal | undefined, req: GetForwardEtlMetadataRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/forward-etl/metadata`; const params = new URLSearchParams(); if (req.tenantId !== undefined) { @@ -921,11 +731,7 @@ export class Client { let resp: ForwardEtlMetadata | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalForwardEtlMetadataSchema); }; await execute(signal, call, options); @@ -936,11 +742,7 @@ export class Client { } /** Get Forward ETL configuration and status for a branch. */ - async getForwardEtlStatus( - signal: AbortSignal | undefined, - req: GetForwardEtlStatusRequest, - options?: Options - ): Promise { + async getForwardEtlStatus(signal: AbortSignal | undefined, req: GetForwardEtlStatusRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/forward-etl`; const params = new URLSearchParams(); if (req.tenantId !== undefined) { @@ -954,11 +756,7 @@ export class Client { let resp: ForwardEtlStatus | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalForwardEtlStatusSchema); }; await execute(signal, call, options); @@ -969,20 +767,12 @@ export class Client { } /** Retrieves the status of a long-running operation. */ - async getOperation( - signal: AbortSignal | undefined, - req: GetOperationRequest, - options?: Options - ): Promise { + async getOperation(signal: AbortSignal | undefined, req: GetOperationRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -993,20 +783,12 @@ export class Client { } /** Retrieves information about the specified database project. */ - async getProject( - signal: AbortSignal | undefined, - req: GetProjectRequest, - options?: Options - ): Promise { + async getProject(signal: AbortSignal | undefined, req: GetProjectRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Project | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalProjectSchema); }; await execute(signal, call, options); @@ -1017,20 +799,12 @@ export class Client { } /** Retrieves information about the specified Postgres role, including its authentication method and permissions. */ - async getRole( - signal: AbortSignal | undefined, - req: GetRoleRequest, - options?: Options - ): Promise { + async getRole(signal: AbortSignal | undefined, req: GetRoleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: Role | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRoleSchema); }; await execute(signal, call, options); @@ -1041,20 +815,12 @@ export class Client { } /** Get a Synced Table. */ - async getSyncedTable( - signal: AbortSignal | undefined, - req: GetSyncedTableRequest, - options?: Options - ): Promise { + async getSyncedTable(signal: AbortSignal | undefined, req: GetSyncedTableRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}`; let resp: SyncedTable | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSyncedTableSchema); }; await execute(signal, call, options); @@ -1065,20 +831,12 @@ export class Client { } /** Get a Table (non-synced database table for Autoscaling v2 Lakebase projects). */ - async getTable( - signal: AbortSignal | undefined, - req: GetTableRequest, - options?: Options - ): Promise
{ + async getTable(signal: AbortSignal | undefined, req: GetTableRequest, options?: Options): Promise
{ const url = `${this.host}/api/2.0/postgres/tables/${req.name ?? ''}`; let resp: Table | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTableSchema); }; await execute(signal, call, options); @@ -1089,11 +847,7 @@ export class Client { } /** Returns a paginated list of database branches in the project. */ - async listBranches( - signal: AbortSignal | undefined, - req: ListBranchesRequest, - options?: Options - ): Promise { + async listBranches(signal: AbortSignal | undefined, req: ListBranchesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/branches`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -1110,11 +864,7 @@ export class Client { let resp: ListBranchesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListBranchesResponseSchema); }; await execute(signal, call, options); @@ -1124,11 +874,8 @@ export class Client { return resp; } - async *listBranchesIter( - signal: AbortSignal | undefined, - req: ListBranchesRequest, - options?: Options - ): AsyncGenerator { + + async *listBranchesIter(signal: AbortSignal | undefined, req: ListBranchesRequest, options?: Options): AsyncGenerator { const pageReq: ListBranchesRequest = {...req}; for (;;) { const resp = await this.listBranches(signal, pageReq, options); @@ -1142,15 +889,12 @@ export class Client { } } + /** * Lists all compute instances that have been created under the specified endpoint. * Note: ComputeInstances are managed via the parent Endpoint resource, and cannot be created, updated, or deleted directly. */ - async listComputeInstances( - signal: AbortSignal | undefined, - req: ListComputeInstancesRequest, - options?: Options - ): Promise { + async listComputeInstances(signal: AbortSignal | undefined, req: ListComputeInstancesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/compute-instances`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -1164,15 +908,8 @@ export class Client { let resp: ListComputeInstancesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListComputeInstancesResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListComputeInstancesResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -1181,11 +918,8 @@ export class Client { return resp; } - async *listComputeInstancesIter( - signal: AbortSignal | undefined, - req: ListComputeInstancesRequest, - options?: Options - ): AsyncGenerator { + + async *listComputeInstancesIter(signal: AbortSignal | undefined, req: ListComputeInstancesRequest, options?: Options): AsyncGenerator { const pageReq: ListComputeInstancesRequest = {...req}; for (;;) { const resp = await this.listComputeInstances(signal, pageReq, options); @@ -1199,12 +933,9 @@ export class Client { } } + /** List Databases. */ - async listDatabases( - signal: AbortSignal | undefined, - req: ListDatabasesRequest, - options?: Options - ): Promise { + async listDatabases(signal: AbortSignal | undefined, req: ListDatabasesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/databases`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -1218,11 +949,7 @@ export class Client { let resp: ListDatabasesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListDatabasesResponseSchema); }; await execute(signal, call, options); @@ -1232,11 +959,8 @@ export class Client { return resp; } - async *listDatabasesIter( - signal: AbortSignal | undefined, - req: ListDatabasesRequest, - options?: Options - ): AsyncGenerator { + + async *listDatabasesIter(signal: AbortSignal | undefined, req: ListDatabasesRequest, options?: Options): AsyncGenerator { const pageReq: ListDatabasesRequest = {...req}; for (;;) { const resp = await this.listDatabases(signal, pageReq, options); @@ -1250,12 +974,9 @@ export class Client { } } + /** Returns a paginated list of compute endpoints in the branch. */ - async listEndpoints( - signal: AbortSignal | undefined, - req: ListEndpointsRequest, - options?: Options - ): Promise { + async listEndpoints(signal: AbortSignal | undefined, req: ListEndpointsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/endpoints`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -1269,11 +990,7 @@ export class Client { let resp: ListEndpointsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListEndpointsResponseSchema); }; await execute(signal, call, options); @@ -1283,11 +1000,8 @@ export class Client { return resp; } - async *listEndpointsIter( - signal: AbortSignal | undefined, - req: ListEndpointsRequest, - options?: Options - ): AsyncGenerator { + + async *listEndpointsIter(signal: AbortSignal | undefined, req: ListEndpointsRequest, options?: Options): AsyncGenerator { const pageReq: ListEndpointsRequest = {...req}; for (;;) { const resp = await this.listEndpoints(signal, pageReq, options); @@ -1301,12 +1015,9 @@ export class Client { } } + /** Returns a paginated list of database projects in the workspace that the user has permission to access. */ - async listProjects( - signal: AbortSignal | undefined, - req: ListProjectsRequest, - options?: Options - ): Promise { + async listProjects(signal: AbortSignal | undefined, req: ListProjectsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/projects`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -1323,11 +1034,7 @@ export class Client { let resp: ListProjectsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListProjectsResponseSchema); }; await execute(signal, call, options); @@ -1337,11 +1044,8 @@ export class Client { return resp; } - async *listProjectsIter( - signal: AbortSignal | undefined, - req: ListProjectsRequest, - options?: Options - ): AsyncGenerator { + + async *listProjectsIter(signal: AbortSignal | undefined, req: ListProjectsRequest, options?: Options): AsyncGenerator { const pageReq: ListProjectsRequest = {...req}; for (;;) { const resp = await this.listProjects(signal, pageReq, options); @@ -1355,12 +1059,9 @@ export class Client { } } + /** Returns a paginated list of Postgres roles in the branch. */ - async listRoles( - signal: AbortSignal | undefined, - req: ListRolesRequest, - options?: Options - ): Promise { + async listRoles(signal: AbortSignal | undefined, req: ListRolesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.parent ?? ''}/roles`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -1374,11 +1075,7 @@ export class Client { let resp: ListRolesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListRolesResponseSchema); }; await execute(signal, call, options); @@ -1388,11 +1085,8 @@ export class Client { return resp; } - async *listRolesIter( - signal: AbortSignal | undefined, - req: ListRolesRequest, - options?: Options - ): AsyncGenerator { + + async *listRolesIter(signal: AbortSignal | undefined, req: ListRolesRequest, options?: Options): AsyncGenerator { const pageReq: ListRolesRequest = {...req}; for (;;) { const resp = await this.listRoles(signal, pageReq, options); @@ -1406,22 +1100,15 @@ export class Client { } } + /** Undeletes the specified database branch. */ - async undeleteBranch( - signal: AbortSignal | undefined, - req: UndeleteBranchRequest, - options?: Options - ): Promise { + async undeleteBranch(signal: AbortSignal | undefined, req: UndeleteBranchRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.name ?? ''}/undelete`; const body = marshalRequest(req, marshalUndeleteBranchRequestSchema); let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -1431,25 +1118,21 @@ export class Client { return resp; } - async undeleteBranchOperation( - signal: AbortSignal | undefined, - req: UndeleteBranchRequest, - options?: Options - ): Promise { - const op = await this.undeleteBranch(signal, req, options); - return new UndeleteBranchOperation(this, op); - } +async undeleteBranchOperation( + signal: AbortSignal | undefined, + req: UndeleteBranchRequest, + options?: Options +): Promise { + const op = await this.undeleteBranch(signal, req, options); + return new UndeleteBranchOperation(this, op); +} /** Updates the specified database branch. You can set this branch as the project's default branch, or protect/unprotect it. */ - async updateBranch( - signal: AbortSignal | undefined, - req: UpdateBranchRequest, - options?: Options - ): Promise { + async updateBranch(signal: AbortSignal | undefined, req: UpdateBranchRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.branch?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1457,11 +1140,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -1471,25 +1150,21 @@ export class Client { return resp; } - async updateBranchOperation( - signal: AbortSignal | undefined, - req: UpdateBranchRequest, - options?: Options - ): Promise { - const op = await this.updateBranch(signal, req, options); - return new UpdateBranchOperation(this, op); - } +async updateBranchOperation( + signal: AbortSignal | undefined, + req: UpdateBranchRequest, + options?: Options +): Promise { + const op = await this.updateBranch(signal, req, options); + return new UpdateBranchOperation(this, op); +} /** Update a Database. */ - async updateDatabase( - signal: AbortSignal | undefined, - req: UpdateDatabaseRequest, - options?: Options - ): Promise { + async updateDatabase(signal: AbortSignal | undefined, req: UpdateDatabaseRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.database?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1497,11 +1172,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -1511,25 +1182,21 @@ export class Client { return resp; } - async updateDatabaseOperation( - signal: AbortSignal | undefined, - req: UpdateDatabaseRequest, - options?: Options - ): Promise { - const op = await this.updateDatabase(signal, req, options); - return new UpdateDatabaseOperation(this, op); - } +async updateDatabaseOperation( + signal: AbortSignal | undefined, + req: UpdateDatabaseRequest, + options?: Options +): Promise { + const op = await this.updateDatabase(signal, req, options); + return new UpdateDatabaseOperation(this, op); +} /** Updates the specified compute endpoint. You can update autoscaling limits, suspend timeout, or enable/disable the compute endpoint. */ - async updateEndpoint( - signal: AbortSignal | undefined, - req: UpdateEndpointRequest, - options?: Options - ): Promise { + async updateEndpoint(signal: AbortSignal | undefined, req: UpdateEndpointRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.endpoint?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1537,11 +1204,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -1551,25 +1214,21 @@ export class Client { return resp; } - async updateEndpointOperation( - signal: AbortSignal | undefined, - req: UpdateEndpointRequest, - options?: Options - ): Promise { - const op = await this.updateEndpoint(signal, req, options); - return new UpdateEndpointOperation(this, op); - } +async updateEndpointOperation( + signal: AbortSignal | undefined, + req: UpdateEndpointRequest, + options?: Options +): Promise { + const op = await this.updateEndpoint(signal, req, options); + return new UpdateEndpointOperation(this, op); +} /** Updates the specified database project. */ - async updateProject( - signal: AbortSignal | undefined, - req: UpdateProjectRequest, - options?: Options - ): Promise { + async updateProject(signal: AbortSignal | undefined, req: UpdateProjectRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.project?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1577,11 +1236,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -1591,25 +1246,21 @@ export class Client { return resp; } - async updateProjectOperation( - signal: AbortSignal | undefined, - req: UpdateProjectRequest, - options?: Options - ): Promise { - const op = await this.updateProject(signal, req, options); - return new UpdateProjectOperation(this, op); - } +async updateProjectOperation( + signal: AbortSignal | undefined, + req: UpdateProjectRequest, + options?: Options +): Promise { + const op = await this.updateProject(signal, req, options); + return new UpdateProjectOperation(this, op); +} /** Update a role for a branch. */ - async updateRole( - signal: AbortSignal | undefined, - req: UpdateRoleRequest, - options?: Options - ): Promise { + async updateRole(signal: AbortSignal | undefined, req: UpdateRoleRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/postgres/${req.role?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -1617,11 +1268,7 @@ export class Client { let resp: Operation | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalOperationSchema); }; await execute(signal, call, options); @@ -1631,14 +1278,14 @@ export class Client { return resp; } - async updateRoleOperation( - signal: AbortSignal | undefined, - req: UpdateRoleRequest, - options?: Options - ): Promise { - const op = await this.updateRole(signal, req, options); - return new UpdateRoleOperation(this, op); - } +async updateRoleOperation( + signal: AbortSignal | undefined, + req: UpdateRoleRequest, + options?: Options +): Promise { + const op = await this.updateRole(signal, req, options); + return new UpdateRoleOperation(this, op); +} } export class CreateBranchOperation { @@ -1658,9 +1305,7 @@ export class CreateBranchOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalBranchOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -1758,9 +1403,7 @@ export class CreateCatalogOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalCatalogOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalCatalogOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -1858,9 +1501,7 @@ export class CreateDatabaseOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalDatabaseOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -1958,9 +1599,7 @@ export class CreateEndpointOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalEndpointOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2058,9 +1697,7 @@ export class CreateProjectOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalProjectOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2158,9 +1795,7 @@ export class CreateRoleOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalRoleOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2258,9 +1893,7 @@ export class CreateSyncedTableOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalSyncedTableOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalSyncedTableOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2358,9 +1991,7 @@ export class DeleteBranchOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalBranchOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2447,9 +2078,7 @@ export class DeleteCatalogOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalCatalogOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalCatalogOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2536,9 +2165,7 @@ export class DeleteDatabaseOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalDatabaseOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2625,9 +2252,7 @@ export class DeleteEndpointOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalEndpointOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2714,9 +2339,7 @@ export class DeleteProjectOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalProjectOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2803,9 +2426,7 @@ export class DeleteRoleOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalRoleOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2892,9 +2513,7 @@ export class DeleteSyncedTableOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalSyncedTableOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalSyncedTableOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -2981,9 +2600,7 @@ export class UndeleteBranchOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalBranchOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -3070,9 +2687,7 @@ export class UpdateBranchOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalBranchOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalBranchOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -3170,9 +2785,7 @@ export class UpdateDatabaseOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalDatabaseOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalDatabaseOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -3270,9 +2883,7 @@ export class UpdateEndpointOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalEndpointOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalEndpointOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -3370,9 +2981,7 @@ export class UpdateProjectOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalProjectOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalProjectOperationMetadataSchema).parse(this.operation.metadata) ); } @@ -3470,9 +3079,7 @@ export class UpdateRoleOperation { return Promise.resolve(undefined); } return Promise.resolve( - z - .lazy(() => unmarshalRoleOperationMetadataSchema) - .parse(this.operation.metadata) + z.lazy(() => unmarshalRoleOperationMetadataSchema).parse(this.operation.metadata) ); } diff --git a/packages/postgres/src/v1/index.ts b/packages/postgres/src/v1/index.ts index df1993b1..b1ac0cbc 100644 --- a/packages/postgres/src/v1/index.ts +++ b/packages/postgres/src/v1/index.ts @@ -1,28 +1,7 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. -export { - Client, - CreateBranchOperation, - CreateCatalogOperation, - CreateDatabaseOperation, - CreateEndpointOperation, - CreateProjectOperation, - CreateRoleOperation, - CreateSyncedTableOperation, - DeleteBranchOperation, - DeleteCatalogOperation, - DeleteDatabaseOperation, - DeleteEndpointOperation, - DeleteProjectOperation, - DeleteRoleOperation, - DeleteSyncedTableOperation, - UndeleteBranchOperation, - UpdateBranchOperation, - UpdateDatabaseOperation, - UpdateEndpointOperation, - UpdateProjectOperation, - UpdateRoleOperation, -} from './client'; + +export {Client, CreateBranchOperation, CreateCatalogOperation, CreateDatabaseOperation, CreateEndpointOperation, CreateProjectOperation, CreateRoleOperation, CreateSyncedTableOperation, DeleteBranchOperation, DeleteCatalogOperation, DeleteDatabaseOperation, DeleteEndpointOperation, DeleteProjectOperation, DeleteRoleOperation, DeleteSyncedTableOperation, UndeleteBranchOperation, UpdateBranchOperation, UpdateDatabaseOperation, UpdateEndpointOperation, UpdateProjectOperation, UpdateRoleOperation} from './client'; export { EndpointType, diff --git a/packages/postgres/src/v1/model.ts b/packages/postgres/src/v1/model.ts index bed051d3..0f52bb82 100644 --- a/packages/postgres/src/v1/model.ts +++ b/packages/postgres/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** The compute endpoint type. Either `read_write` or `read_only`. */ @@ -16,10 +18,10 @@ export enum ErrorCode { /** * Unknown error. This error generally should not be returned explicitly, but will be used * as a fallback if the error enum is missing from the message for some reason. - * + * * It's assigned tag 0 to follow the best practice from * https://developers.google.com/protocol-buffers/docs/style#enums - * + * * TODO(PLAT-55898): Add custom option to declare HTTP and gRPC mappings. * Maps to: * - google.rpc.Code: UNKNOWN = 2; @@ -30,10 +32,10 @@ export enum ErrorCode { * Internal error. This means that some invariants expected by the underlying system have been * broken. This error code is reserved for serious errors, which generally cannot be resolved * by the user. - * + * * Prefer this over all kinds of detailed error messages (e.g IO_ERROR), unless there's some * automation that relies on the custom error code. - * + * * Maps to: * - google.rpc.Code: INTERNAL = 13; * - HTTP code: 500 Internal Server Error @@ -43,12 +45,12 @@ export enum ErrorCode { * The service is currently unavailable. This is most likely a transient condition, which can be * corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent * operations. - * + * * Prefer this over SERVICE_UNDER_MAINTENANCE, WORKSPACE_TEMPORARILY_UNAVAILABLE. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on how to pick this vs RESOURCE_EXHAUSTED. - * + * * Maps to: * - google.rpc.Code: UNAVAILABLE = 14; * - HTTP code: 503 Service Unavailable @@ -63,9 +65,9 @@ export enum ErrorCode { /** * The request is invalid. Prefer more specific error code whenever possible. * Also see similar recommendation for the google.rpc.Code.FAILED_PRECONDITION. - * + * * Prefer this error code over MALFORMED_REQUEST, INVALID_STATE, UNPARSEABLE_HTTP_ERROR. - * + * * Maps to: * - google.rpc.Code: FAILED_PRECONDITION = 9; * - HTTP code: 400 Bad Request @@ -85,7 +87,7 @@ export enum ErrorCode { * the deadline to expire. When possible - implementations should make sure further processing of * the request is aborted, e.g. by throwing an exception instead of making the RPC request, * making the database query, etc. - * + * * Maps to: * - google.rpc.Code: DEADLINE_EXCEEDED = 4; * - HTTP code: 504 Gateway Timeout @@ -94,7 +96,7 @@ export enum ErrorCode { /** * The operation was canceled by the caller. An example - client closed the connection without * waiting for a response. - * + * * Maps to: * - google.rpc.Code: CANCELLED = 1; * - HTTP code: 499 Client Closed Request @@ -104,10 +106,10 @@ export enum ErrorCode { * The operation is rejected because of either rate limiting or resource quota, * such as the client has sent too many requests recently or the client has allocated too many * resources. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on how to pick this vs TEMPORARILY_UNAVAILABLE. - * + * * Maps to: * - google.rpc.Code: RESOURCE_EXHAUSTED = 8; * - HTTP code: 429 Too Many Requests @@ -116,7 +118,7 @@ export enum ErrorCode { /** * The operation was aborted, typically due to a concurrency issue such as a sequencer * check failure, transaction abort, or transaction conflict. - * + * * Maps to: * - google.rpc.Code: ABORTED = 10; * - HTTP code: 409 Conflict @@ -125,7 +127,7 @@ export enum ErrorCode { /** * Operation was performed on a resource that does not exist, * e.g. file or directory was not found. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -134,9 +136,9 @@ export enum ErrorCode { /** * Operation was rejected due a conflict with an existing resource, e.g. attempted to create * file or directory that already exists. - * + * * Prefer this over RESOURCE_CONFLICT. - * + * * Maps to: * - google.rpc.Code: ALREADY_EXISTS = 6; * - HTTP code: 409 Conflict @@ -144,11 +146,11 @@ export enum ErrorCode { ALREADY_EXISTS = 'ALREADY_EXISTS', /** * The request does not have valid authentication (AuthN) credentials for the operation. - * + * * Prefer this over CUSTOMER_UNAUTHORIZED, unless you need to keep consistent behavior with legacy * code. * For authorization (AuthZ) errors use PERMISSION_DENIED. - * + * * Maps to: * - google.rpc.Code: UNAUTHENTICATED = 16; * - HTTP code: 401 Unauthorized @@ -163,7 +165,7 @@ export enum ErrorCode { * not know whether it is because the domain name is completely wrong (non-transient situation) or * the domain name is valid but the DNS server does not have an entry for this domain name yet (transient * situation). Hence, `UNAVAILABLE` is suitable for this case. - * + * * Maps to: * - google.rpc.Code: UNAVAILABLE = 14; * - HTTP code: 503 Service Unavailable @@ -171,7 +173,7 @@ export enum ErrorCode { UNAVAILABLE = 'UNAVAILABLE', /** * Supplied value for a parameter was invalid (e.g., giving a number for a string parameter). - * + * * Maps to: * - google.rpc.Code: INVALID_ARGUMENT = 3; * - HTTP code: 400 Bad Request @@ -180,7 +182,7 @@ export enum ErrorCode { /** * Indicates that the given API endpoint does not exist. Legacy, when possible - NOT_IMPLEMENTED * should be used instead to indicate that API doesn't exist. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -202,7 +204,7 @@ export enum ErrorCode { * use CUSTOMER_UNAUTHORIZED instead for those errors. * This error code does not imply the request is valid or the requested entity exists or * satisfies other pre-conditions. - * + * * Maps to: * - google.rpc.Code: PERMISSION_DENIED = 7; * - HTTP code: 403 Forbidden @@ -212,9 +214,9 @@ export enum ErrorCode { * NOTE: Deprecated due to inconsistent mapping in legacy code, see * https://docs.google.com/document/d/17TZIKX_Y39cJMBr333lc-d5dTvvBLSu3DPUyGU5eMJg/edit?disco=AAAAzVGt6FA. * Prefer using NOT_FOUND or PERMISSION_DENIED. - * + * * If a given user/entity is trying to use a feature which has been disabled. - * + * * Maps to: * - google.rpc.Code: NOT_FOUND = 5; * - HTTP code: 404 Not Found @@ -222,20 +224,20 @@ export enum ErrorCode { FEATURE_DISABLED = 'FEATURE_DISABLED', /** * The request does not have valid authentication (AuthN) credentials for the operation. - * + * * For authentication (AuthN) errors prefer using UNAUTHENTICATED, unless you need to keep * consistent behavior with legacy code. * For authorization (AuthZ) errors use PERMISSION_DENIED. - * + * * Important: name is confusing, this error code is for authentication (AuthN) errors, not * authorization (AuthZ) errors. It maps to 401 Unauthorized and suffers from the same confusing * naming. See https://datatracker.ietf.org/doc/html/rfc7235#section-3.1 - "[...] status code * indicates that the request has not been applied because it lacks valid authentication * credentials for the target resource. [...] If the request included authentication credentials, * then the 401 response indicates that authorization has been refused for those credentials." - * + * * Also, see https://stackoverflow.com/a/6937030/16352922, it covers it pretty well. - * + * * Maps to: * - google.rpc.Code: UNAUTHENTICATED = 16; * - HTTP code: 401 Unauthorized @@ -244,12 +246,12 @@ export enum ErrorCode { /** * The operation is rejected because of request rate limit, for example rate limiting applied to * users, workspaces, IP addresses, etc. - * + * * Prefer a more generic RESOURCE_EXHAUSTED for the new use cases. - * + * * See https://docs.google.com/document/d/1FL8p2sbYWqBPL-UvhzI7uXAw4EoLG7Rj6PAOQWZRSOk/edit# * for guideline on the rate limiting vs throttling. - * + * * Maps to: * - google.rpc.Code: RESOURCE_EXHAUSTED = 8; * - HTTP code: 429 Too Many Requests @@ -266,7 +268,7 @@ export enum ErrorCode { UNPARSEABLE_HTTP_ERROR = 'UNPARSEABLE_HTTP_ERROR', /** * The operation is not implemented or is not supported/enabled in this service. - * + * * Maps to: * - google.rpc.Code: UNIMPLEMENTED = 12; * - HTTP code: 501 Not Implemented @@ -274,14 +276,14 @@ export enum ErrorCode { NOT_IMPLEMENTED = 'NOT_IMPLEMENTED', /** * Unrecoverable data loss or corruption. - * + * * One of the major use cases is to indicate that server failed to validate the integrity of * the request. This error can occur when the checksum specified in the `X-Databricks-Checksum` * request header (or trailer) doesn't match the actual request content checksum. - * + * * Note, in case of the severe corruption that results in a malformed request, the server may * send a generic `400 Bad Request` response rather than sending this error code. - * + * * Maps to: * - google.rpc.Code: DATA_LOSS = 15; * - HTTP code: 500 Internal Server Error @@ -299,7 +301,7 @@ export enum ErrorCode { * NOTE: Deprecated, prefer using ALREADY_EXISTS. * Unlike ALREADY_EXISTS - this maps to HTTP code 400 Bad Request due to legacy reasons, * remapping will be a backwards incompatible change. - * + * * Operation was performed on a resource that already exists. */ RESOURCE_ALREADY_EXISTS = 'RESOURCE_ALREADY_EXISTS', @@ -307,7 +309,7 @@ export enum ErrorCode { * NOTE: Deprecated, prefer using NOT_FOUND - see the note for the RESOURCE_ALREADY_EXISTS, * because this pair of codes is related and RESOURCE_ALREADY_EXISTS has bad mapping to the HTTP * codes we added new error codes NOT_FOUND and ALREADY_EXISTS, and recommend to use them instead. - * + * * Operation was performed on a resource that does not exist. */ RESOURCE_DOES_NOT_EXIST = 'RESOURCE_DOES_NOT_EXIST', @@ -725,7 +727,7 @@ export interface Branch { /** * 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`. */ @@ -794,7 +796,7 @@ export interface BranchStatus { /** * The short identifier of the branch, suitable for showing to the users. * For a branch with name `projects/my-project/branches/my-branch`, the branch_id is `my-branch`. - * + * * Use this field when building UI components that display branches to users (e.g., a drop-down * selector). Prefer showing `branch_id` instead of the full resource name from `Branch.name`, * which follows the `projects/{project_id}/branches/{branch_id}` format and is not user-friendly. @@ -815,7 +817,7 @@ export interface BranchStatus { export interface Catalog { /** * Output only. The full resource path of the catalog. - * + * * Format: "catalogs/{catalog_id}". */ name?: string | undefined; @@ -837,16 +839,16 @@ export interface Catalog_CatalogSpec { /** * 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. */ @@ -855,13 +857,13 @@ export interface Catalog_CatalogSpec { * 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?: boolean | undefined; /** * The resource path of the branch associated with the catalog. - * + * * Format: projects/{project_id}/branches/{branch_id}. */ branch?: string | undefined; @@ -874,20 +876,20 @@ export interface Catalog_CatalogStatus { postgresDatabase?: string | undefined; /** * The resource path of the project associated with the catalog. - * + * * Format: projects/{project_id}. */ project?: string | undefined; /** * The resource path of the branch associated with the catalog. - * + * * Format: projects/{project_id}/branches/{branch_id}. */ branch?: string | undefined; /** * The short identifier of the catalog, suitable for showing to the users. * For a catalog with name `catalogs/my-catalog`, the catalog_id is `my-catalog`. - * + * * Use this field when building UI components that display catalogs to users (e.g., a drop-down * selector). Prefer showing `catalog_id` instead of the full resource name from `Catalog.name`, * which follows the `catalogs/{catalog_id}` format and is not user-friendly. @@ -955,10 +957,10 @@ export interface CreateDatabaseRequest { * 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 | undefined; @@ -1003,10 +1005,10 @@ export interface CreateRoleRequest { * 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 | undefined; @@ -1020,11 +1022,11 @@ export interface CreateSyncedTableRequest { * 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 */ @@ -1063,19 +1065,19 @@ export interface Database_DatabaseSpec { /** * 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 | undefined; /** * 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 | undefined; @@ -1094,7 +1096,7 @@ export interface Database_DatabaseStatus { * The short identifier of the database, suitable for showing to the users. * For a database with name `projects/my-project/branches/my-branch/databases/my-db`, * the database_id is `my-db`. - * + * * Use this field when building UI components that display databases to users (e.g., a drop-down * selector). Prefer showing `database_id` instead of the full resource name from `Database.name`, * which follows the `projects/{project_id}/branches/{branch_id}/databases/{database_id}` format @@ -1142,7 +1144,7 @@ export interface DeleteBranchRequest { export interface DeleteCatalogRequest { /** * The full resource path of the catalog to delete. - * + * * Format: "catalogs/{catalog_id}". */ name?: string | undefined; @@ -1170,6 +1172,11 @@ export interface DeleteProjectRequest { * Format: projects/{project_id} */ name?: string | undefined; + /** + * If true, permanently deletes the project (hard delete). + * If false or unset, performs a soft delete. + */ + purge?: boolean | undefined; } export interface DeleteRoleRequest { @@ -1181,7 +1188,7 @@ export interface DeleteRoleRequest { /** * 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. */ @@ -1394,7 +1401,7 @@ export interface EndpointStatus { * The short identifier of the endpoint, suitable for showing to the users. * For an endpoint with name `projects/my-project/branches/my-branch/endpoints/my-endpoint`, * the endpoint_id is `my-endpoint`. - * + * * Use this field when building UI components that display endpoints to users (e.g., a drop-down * selector). Prefer showing `endpoint_id` instead of the full resource name from `Endpoint.name`, * which follows the `projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}` format @@ -1512,7 +1519,7 @@ export interface GetBranchRequest { export interface GetCatalogRequest { /** * The full resource path of the catalog to retrieve. - * + * * Format: "catalogs/{catalog_id}". */ name?: string | undefined; @@ -1639,7 +1646,7 @@ export interface ListComputeInstancesRequest { /** * The maximum number of compute instances to return. The service may * return fewer than this value. - * + * * If unspecified, at most 50 compute instances will be returned. * The maximum value is 1000; values above 1000 will be coerced to 1000. */ @@ -1647,7 +1654,7 @@ export interface ListComputeInstancesRequest { /** * A page token, received from a previous `ListInstances` call. * Provide this to retrieve the subsequent page. - * + * * When paginating, all other parameters provided to `ListInstances` must * match the call that provided the page token. */ @@ -1921,7 +1928,7 @@ export interface ProjectStatus { /** * The short identifier of the project, suitable for showing to the users. * For a project with name `projects/my-project`, the project_id is `my-project`. - * + * * Use this field when building UI components that display projects to users (e.g., a drop-down * selector). Prefer showing `project_id` instead of the full resource name from `Project.name`, * which follows the `projects/{project_id}` format and is not user-friendly. @@ -1983,7 +1990,7 @@ export interface Role_RoleSpec { /** * 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 @@ -1995,22 +2002,22 @@ export interface Role_RoleSpec { * 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 | undefined; /** * 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 @@ -2033,7 +2040,7 @@ export interface Role_RoleStatus { * The short identifier of the role, suitable for showing to the users. * For a role with name `projects/my-project/branches/my-branch/roles/my-role`, * the role_id is `my-role`. - * + * * Use this field when building UI components that display roles to users (e.g., a drop-down * selector). Prefer showing `role_id` instead of the full resource name from `Role.name`, * which follows the `projects/{project_id}/branches/{branch_id}/roles/{role_id}` format @@ -2049,9 +2056,9 @@ export interface SyncedTable { /** * 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 | undefined; @@ -2071,28 +2078,26 @@ export interface SyncedTable { export interface SyncedTable_SyncedTableSpec { /** * 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 | undefined; /** * The full resource name the branch associated with the table. - * + * * Format: "projects/{project_id}/branches/{branch_id}". */ branch?: string | undefined; /** Scheduling policy of the underlying pipeline. */ - schedulingPolicy?: - | SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy - | undefined; + schedulingPolicy?: SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy | undefined; /** * 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. */ @@ -2104,7 +2109,7 @@ export interface SyncedTable_SyncedTableSpec { /** * 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 | undefined; @@ -2112,14 +2117,14 @@ export interface SyncedTable_SyncedTableSpec { * 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?: boolean | undefined; /** * 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 | undefined; @@ -2155,7 +2160,7 @@ export interface SyncedTable_SyncedTableStatus { unityCatalogProvisioningState?: ProvisioningInfo_State | undefined; /** * The full resource name of the project associated with the table. - * + * * Format: "projects/{project_id}". */ project?: string | undefined; @@ -2230,55 +2235,55 @@ export interface UndeleteBranchRequest { export interface UpdateBranchRequest { /** * 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 | undefined; /** The list of fields to update. If unspecified, all fields will be updated when possible. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface UpdateDatabaseRequest { /** * 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 | undefined; /** The list of fields to update. If unspecified, all fields will be updated when possible. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface UpdateEndpointRequest { /** * 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 | undefined; /** The list of fields to update. If unspecified, all fields will be updated when possible. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface UpdateProjectRequest { /** * The Project to update. - * + * * The project's `name` field is used to identify the project to update. * Format: projects/{project_id} */ project?: Project | undefined; /** The list of fields to update. If unspecified, all fields will be updated when possible. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface UpdateRoleRequest { /** * 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} */ @@ -2287,7 +2292,7 @@ export interface UpdateRoleRequest { * The list of fields to update in Postgres Role. * If unspecified, all fields will be updated when possible. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export const unmarshalBranchSchema: z.ZodType = z @@ -2295,14 +2300,8 @@ export const unmarshalBranchSchema: z.ZodType = z name: z.string().optional(), uid: z.string().optional(), parent: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), spec: z.lazy(() => unmarshalBranchSpecSchema).optional(), status: z.lazy(() => unmarshalBranchStatusSchema).optional(), }) @@ -2316,26 +2315,18 @@ export const unmarshalBranchSchema: z.ZodType = z status: d.status, })); -export const unmarshalBranchOperationMetadataSchema: z.ZodType = - z.object({}); +export const unmarshalBranchOperationMetadataSchema: z.ZodType = z + .object({ + }); export const unmarshalBranchSpecSchema: z.ZodType = z .object({ source_branch: z.string().optional(), source_branch_lsn: z.string().optional(), - source_branch_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + source_branch_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), is_protected: z.boolean().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - ttl: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + ttl: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), no_expiry: z.boolean().optional(), }) .transform(d => ({ @@ -2352,32 +2343,17 @@ export const unmarshalBranchStatusSchema: z.ZodType = z .object({ source_branch: z.string().optional(), source_branch_lsn: z.string().optional(), - source_branch_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + source_branch_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), default: z.boolean().optional(), is_protected: z.boolean().optional(), current_state: z.enum(BranchStatus_State).optional(), pending_state: z.enum(BranchStatus_State).optional(), - state_change_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + state_change_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), logical_size_bytes: z.number().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), branch_id: z.string().optional(), - delete_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - purge_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + delete_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + purge_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), }) .transform(d => ({ sourceBranch: d.source_branch, @@ -2401,14 +2377,8 @@ export const unmarshalCatalogSchema: z.ZodType = z uid: z.string().optional(), spec: z.lazy(() => unmarshalCatalog_CatalogSpecSchema).optional(), status: z.lazy(() => unmarshalCatalog_CatalogStatusSchema).optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), }) .transform(d => ({ name: d.name, @@ -2420,37 +2390,36 @@ export const unmarshalCatalogSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCatalog_CatalogSpecSchema: z.ZodType = - z - .object({ - postgres_database: z.string().optional(), - create_database_if_missing: z.boolean().optional(), - branch: z.string().optional(), - }) - .transform(d => ({ - postgresDatabase: d.postgres_database, - createDatabaseIfMissing: d.create_database_if_missing, - branch: d.branch, - })); +export const unmarshalCatalog_CatalogSpecSchema: z.ZodType = z + .object({ + postgres_database: z.string().optional(), + create_database_if_missing: z.boolean().optional(), + branch: z.string().optional(), + }) + .transform(d => ({ + postgresDatabase: d.postgres_database, + createDatabaseIfMissing: d.create_database_if_missing, + branch: d.branch, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCatalog_CatalogStatusSchema: z.ZodType = - z - .object({ - postgres_database: z.string().optional(), - project: z.string().optional(), - branch: z.string().optional(), - catalog_id: z.string().optional(), - }) - .transform(d => ({ - postgresDatabase: d.postgres_database, - project: d.project, - branch: d.branch, - catalogId: d.catalog_id, - })); - -export const unmarshalCatalogOperationMetadataSchema: z.ZodType = - z.object({}); +export const unmarshalCatalog_CatalogStatusSchema: z.ZodType = z + .object({ + postgres_database: z.string().optional(), + project: z.string().optional(), + branch: z.string().optional(), + catalog_id: z.string().optional(), + }) + .transform(d => ({ + postgresDatabase: d.postgres_database, + project: d.project, + branch: d.branch, + catalogId: d.catalog_id, + })); + +export const unmarshalCatalogOperationMetadataSchema: z.ZodType = z + .object({ + }); export const unmarshalComputeInstanceSchema: z.ZodType = z .object({ @@ -2460,14 +2429,8 @@ export const unmarshalComputeInstanceSchema: z.ZodType = z pending_state: z.enum(ComputeInstance_ComputeState).optional(), role: z.enum(ComputeInstance_ComputeType).optional(), compute_host: z.string().optional(), - start_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - suspend_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + start_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + suspend_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), }) .transform(d => ({ name: d.name, @@ -2480,66 +2443,61 @@ export const unmarshalComputeInstanceSchema: z.ZodType = z suspendTime: d.suspend_time, })); -export const unmarshalCreateBranchRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - branch_id: z.string().optional(), - branch: z.lazy(() => unmarshalBranchSchema).optional(), - }) - .transform(d => ({ - parent: d.parent, - branchId: d.branch_id, - branch: d.branch, - })); - -export const unmarshalCreateCatalogRequestSchema: z.ZodType = - z - .object({ - catalog_id: z.string().optional(), - catalog: z.lazy(() => unmarshalCatalogSchema).optional(), - }) - .transform(d => ({ - catalogId: d.catalog_id, - catalog: d.catalog, - })); - -export const unmarshalCreateDatabaseRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - database_id: z.string().optional(), - database: z.lazy(() => unmarshalDatabaseSchema).optional(), - }) - .transform(d => ({ - parent: d.parent, - databaseId: d.database_id, - database: d.database, - })); - -export const unmarshalCreateEndpointRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - endpoint_id: z.string().optional(), - endpoint: z.lazy(() => unmarshalEndpointSchema).optional(), - }) - .transform(d => ({ - parent: d.parent, - endpointId: d.endpoint_id, - endpoint: d.endpoint, - })); - -export const unmarshalCreateProjectRequestSchema: z.ZodType = - z - .object({ - project_id: z.string().optional(), - project: z.lazy(() => unmarshalProjectSchema).optional(), - }) - .transform(d => ({ - projectId: d.project_id, - project: d.project, - })); +export const unmarshalCreateBranchRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + branch_id: z.string().optional(), + branch: z.lazy(() => unmarshalBranchSchema).optional(), + }) + .transform(d => ({ + parent: d.parent, + branchId: d.branch_id, + branch: d.branch, + })); + +export const unmarshalCreateCatalogRequestSchema: z.ZodType = z + .object({ + catalog_id: z.string().optional(), + catalog: z.lazy(() => unmarshalCatalogSchema).optional(), + }) + .transform(d => ({ + catalogId: d.catalog_id, + catalog: d.catalog, + })); + +export const unmarshalCreateDatabaseRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + database_id: z.string().optional(), + database: z.lazy(() => unmarshalDatabaseSchema).optional(), + }) + .transform(d => ({ + parent: d.parent, + databaseId: d.database_id, + database: d.database, + })); + +export const unmarshalCreateEndpointRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + endpoint_id: z.string().optional(), + endpoint: z.lazy(() => unmarshalEndpointSchema).optional(), + }) + .transform(d => ({ + parent: d.parent, + endpointId: d.endpoint_id, + endpoint: d.endpoint, + })); + +export const unmarshalCreateProjectRequestSchema: z.ZodType = z + .object({ + project_id: z.string().optional(), + project: z.lazy(() => unmarshalProjectSchema).optional(), + }) + .transform(d => ({ + projectId: d.project_id, + project: d.project, + })); export const unmarshalCreateRoleRequestSchema: z.ZodType = z .object({ @@ -2553,38 +2511,30 @@ export const unmarshalCreateRoleRequestSchema: z.ZodType = z role: d.role, })); -export const unmarshalCreateSyncedTableRequestSchema: z.ZodType = - z - .object({ - synced_table_id: z.string().optional(), - synced_table: z.lazy(() => unmarshalSyncedTableSchema).optional(), - }) - .transform(d => ({ - syncedTableId: d.synced_table_id, - syncedTable: d.synced_table, - })); - -export const unmarshalCreateTableRequestSchema: z.ZodType = - z - .object({ - table: z.lazy(() => unmarshalTableSchema).optional(), - }) - .transform(d => ({ - table: d.table, - })); +export const unmarshalCreateSyncedTableRequestSchema: z.ZodType = z + .object({ + synced_table_id: z.string().optional(), + synced_table: z.lazy(() => unmarshalSyncedTableSchema).optional(), + }) + .transform(d => ({ + syncedTableId: d.synced_table_id, + syncedTable: d.synced_table, + })); + +export const unmarshalCreateTableRequestSchema: z.ZodType = z + .object({ + table: z.lazy(() => unmarshalTableSchema).optional(), + }) + .transform(d => ({ + table: d.table, + })); export const unmarshalDatabaseSchema: z.ZodType = z .object({ name: z.string().optional(), parent: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), spec: z.lazy(() => unmarshalDatabase_DatabaseSpecSchema).optional(), status: z.lazy(() => unmarshalDatabase_DatabaseStatusSchema).optional(), }) @@ -2598,111 +2548,102 @@ export const unmarshalDatabaseSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDatabase_DatabaseSpecSchema: z.ZodType = - z - .object({ - role: z.string().optional(), - postgres_database: z.string().optional(), - }) - .transform(d => ({ - role: d.role, - postgresDatabase: d.postgres_database, - })); +export const unmarshalDatabase_DatabaseSpecSchema: z.ZodType = z + .object({ + role: z.string().optional(), + postgres_database: z.string().optional(), + }) + .transform(d => ({ + role: d.role, + postgresDatabase: d.postgres_database, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDatabase_DatabaseStatusSchema: z.ZodType = - z - .object({ - role: z.string().optional(), - postgres_database: z.string().optional(), - database_id: z.string().optional(), - }) - .transform(d => ({ - role: d.role, - postgresDatabase: d.postgres_database, - databaseId: d.database_id, - })); - -export const unmarshalDatabaseCredentialSchema: z.ZodType = - z - .object({ - token: z.string().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - token: d.token, - expireTime: d.expire_time, - })); - -export const unmarshalDatabaseOperationMetadataSchema: z.ZodType = - z.object({}); - -export const unmarshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = - z - .object({ - error_code: z.enum(ErrorCode).optional(), - message: z.string().optional(), - stack_trace: z.string().optional(), - details: z.array(z.record(z.string(), z.unknown())).optional(), - }) - .transform(d => ({ - errorCode: d.error_code, - message: d.message, - stackTrace: d.stack_trace, - details: d.details, - })); - -export const unmarshalDeleteBranchRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - purge: z.boolean().optional(), - allow_missing: z.boolean().optional(), - }) - .transform(d => ({ - name: d.name, - purge: d.purge, - allowMissing: d.allow_missing, - })); - -export const unmarshalDeleteCatalogRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeleteDatabaseRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeleteEndpointRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeleteProjectRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalDatabase_DatabaseStatusSchema: z.ZodType = z + .object({ + role: z.string().optional(), + postgres_database: z.string().optional(), + database_id: z.string().optional(), + }) + .transform(d => ({ + role: d.role, + postgresDatabase: d.postgres_database, + databaseId: d.database_id, + })); + +export const unmarshalDatabaseCredentialSchema: z.ZodType = z + .object({ + token: z.string().optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + token: d.token, + expireTime: d.expire_time, + })); + +export const unmarshalDatabaseOperationMetadataSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = z + .object({ + error_code: z.enum(ErrorCode).optional(), + message: z.string().optional(), + stack_trace: z.string().optional(), + details: z.array(z.record(z.string(), z.unknown())).optional(), + }) + .transform(d => ({ + errorCode: d.error_code, + message: d.message, + stackTrace: d.stack_trace, + details: d.details, + })); + +export const unmarshalDeleteBranchRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + purge: z.boolean().optional(), + allow_missing: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + purge: d.purge, + allowMissing: d.allow_missing, + })); + +export const unmarshalDeleteCatalogRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeleteDatabaseRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeleteEndpointRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeleteProjectRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + purge: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + purge: d.purge, + })); export const unmarshalDeleteRoleRequestSchema: z.ZodType = z .object({ @@ -2714,77 +2655,63 @@ export const unmarshalDeleteRoleRequestSchema: z.ZodType = z reassignOwnedTo: d.reassign_owned_to, })); -export const unmarshalDeleteSyncedTableRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeleteTableRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalDeltaTableSyncInfoSchema: z.ZodType = - z - .object({ - delta_commit_version: z.number().optional(), - delta_commit_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - deltaCommitVersion: d.delta_commit_version, - deltaCommitTime: d.delta_commit_time, - })); - -export const unmarshalDisableForwardEtlRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - tenant_id: z.string().optional(), - timeline_id: z.string().optional(), - pg_database_oid: z.number().optional(), - pg_schema_oid: z.number().optional(), - }) - .transform(d => ({ - parent: d.parent, - tenantId: d.tenant_id, - timelineId: d.timeline_id, - pgDatabaseOid: d.pg_database_oid, - pgSchemaOid: d.pg_schema_oid, - })); - -export const unmarshalDisableForwardEtlResponseSchema: z.ZodType = - z - .object({ - disabled: z.boolean().optional(), - }) - .transform(d => ({ - disabled: d.disabled, - })); +export const unmarshalDeleteSyncedTableRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeleteTableRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalDeltaTableSyncInfoSchema: z.ZodType = z + .object({ + delta_commit_version: z.number().optional(), + delta_commit_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + deltaCommitVersion: d.delta_commit_version, + deltaCommitTime: d.delta_commit_time, + })); + +export const unmarshalDisableForwardEtlRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + tenant_id: z.string().optional(), + timeline_id: z.string().optional(), + pg_database_oid: z.number().optional(), + pg_schema_oid: z.number().optional(), + }) + .transform(d => ({ + parent: d.parent, + tenantId: d.tenant_id, + timelineId: d.timeline_id, + pgDatabaseOid: d.pg_database_oid, + pgSchemaOid: d.pg_schema_oid, + })); + +export const unmarshalDisableForwardEtlResponseSchema: z.ZodType = z + .object({ + disabled: z.boolean().optional(), + }) + .transform(d => ({ + disabled: d.disabled, + })); export const unmarshalEndpointSchema: z.ZodType = z .object({ name: z.string().optional(), uid: z.string().optional(), parent: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), spec: z.lazy(() => unmarshalEndpointSpecSchema).optional(), status: z.lazy(() => unmarshalEndpointStatusSchema).optional(), }) @@ -2810,18 +2737,17 @@ export const unmarshalEndpointGroupSpecSchema: z.ZodType = z enableReadableSecondaries: d.enable_readable_secondaries, })); -export const unmarshalEndpointGroupStatusSchema: z.ZodType = - z - .object({ - min: z.number().optional(), - max: z.number().optional(), - enable_readable_secondaries: z.boolean().optional(), - }) - .transform(d => ({ - min: d.min, - max: d.max, - enableReadableSecondaries: d.enable_readable_secondaries, - })); +export const unmarshalEndpointGroupStatusSchema: z.ZodType = z + .object({ + min: z.number().optional(), + max: z.number().optional(), + enable_readable_secondaries: z.boolean().optional(), + }) + .transform(d => ({ + min: d.min, + max: d.max, + enableReadableSecondaries: d.enable_readable_secondaries, + })); export const unmarshalEndpointHostsSchema: z.ZodType = z .object({ @@ -2837,8 +2763,9 @@ export const unmarshalEndpointHostsSchema: z.ZodType = z readOnlyPooledHost: d.read_only_pooled_host, })); -export const unmarshalEndpointOperationMetadataSchema: z.ZodType = - z.object({}); +export const unmarshalEndpointOperationMetadataSchema: z.ZodType = z + .object({ + }); export const unmarshalEndpointSettingsSchema: z.ZodType = z .object({ @@ -2849,16 +2776,15 @@ export const unmarshalEndpointSettingsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalEndpointSettings_PgSettingsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalEndpointSettings_PgSettingsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalEndpointSpecSchema: z.ZodType = z .object({ @@ -2866,10 +2792,7 @@ export const unmarshalEndpointSpecSchema: z.ZodType = z autoscaling_limit_min_cu: z.number().optional(), autoscaling_limit_max_cu: z.number().optional(), disabled: z.boolean().optional(), - suspend_timeout_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), + suspend_timeout_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), no_suspension: z.boolean().optional(), settings: z.lazy(() => unmarshalEndpointSettingsSchema).optional(), group: z.lazy(() => unmarshalEndpointGroupSpecSchema).optional(), @@ -2889,19 +2812,13 @@ export const unmarshalEndpointStatusSchema: z.ZodType = z .object({ endpoint_type: z.enum(EndpointType).optional(), hosts: z.lazy(() => unmarshalEndpointHostsSchema).optional(), - last_active_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + last_active_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), autoscaling_limit_min_cu: z.number().optional(), autoscaling_limit_max_cu: z.number().optional(), current_state: z.enum(EndpointStatus_State).optional(), pending_state: z.enum(EndpointStatus_State).optional(), disabled: z.boolean().optional(), - suspend_timeout_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), + suspend_timeout_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), settings: z.lazy(() => unmarshalEndpointSettingsSchema).optional(), group: z.lazy(() => unmarshalEndpointGroupStatusSchema).optional(), endpoint_id: z.string().optional(), @@ -2947,31 +2864,25 @@ export const unmarshalForwardEtlConfigSchema: z.ZodType = z updateTimeMillis: d.update_time_millis, })); -export const unmarshalForwardEtlDatabaseSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - oid: z.number().optional(), - }) - .transform(d => ({ - name: d.name, - oid: d.oid, - })); - -export const unmarshalForwardEtlMetadataSchema: z.ZodType = - z - .object({ - databases: z - .array(z.lazy(() => unmarshalForwardEtlDatabaseSchema)) - .optional(), - schemas: z - .array(z.lazy(() => unmarshalForwardEtlSchemaSchema)) - .optional(), - }) - .transform(d => ({ - databases: d.databases, - schemas: d.schemas, - })); +export const unmarshalForwardEtlDatabaseSchema: z.ZodType = z + .object({ + name: z.string().optional(), + oid: z.number().optional(), + }) + .transform(d => ({ + name: d.name, + oid: d.oid, + })); + +export const unmarshalForwardEtlMetadataSchema: z.ZodType = z + .object({ + databases: z.array(z.lazy(() => unmarshalForwardEtlDatabaseSchema)).optional(), + schemas: z.array(z.lazy(() => unmarshalForwardEtlSchemaSchema)).optional(), + }) + .transform(d => ({ + databases: d.databases, + schemas: d.schemas, + })); export const unmarshalForwardEtlSchemaSchema: z.ZodType = z .object({ @@ -2985,59 +2896,47 @@ export const unmarshalForwardEtlSchemaSchema: z.ZodType = z export const unmarshalForwardEtlStatusSchema: z.ZodType = z .object({ - configurations: z - .array(z.lazy(() => unmarshalForwardEtlConfigSchema)) - .optional(), - table_mappings: z - .array(z.lazy(() => unmarshalForwardEtlTableMappingSchema)) - .optional(), + configurations: z.array(z.lazy(() => unmarshalForwardEtlConfigSchema)).optional(), + table_mappings: z.array(z.lazy(() => unmarshalForwardEtlTableMappingSchema)).optional(), }) .transform(d => ({ configurations: d.configurations, tableMappings: d.table_mappings, })); -export const unmarshalForwardEtlTableMappingSchema: z.ZodType = - z - .object({ - pg_table_oid: z.number().optional(), - uc_table_id: z.string().optional(), - last_synced_lsn: z.string().optional(), - pg_table_name: z.string().optional(), - uc_table_name: z.string().optional(), - enabled: z.boolean().optional(), - }) - .transform(d => ({ - pgTableOid: d.pg_table_oid, - ucTableId: d.uc_table_id, - lastSyncedLsn: d.last_synced_lsn, - pgTableName: d.pg_table_name, - ucTableName: d.uc_table_name, - enabled: d.enabled, - })); - -export const unmarshalGenerateDatabaseCredentialRequestSchema: z.ZodType = - z - .object({ - claims: z.array(z.lazy(() => unmarshalRequestedClaimsSchema)).optional(), - endpoint: z.string().optional(), - group_name: z.string().optional(), - ttl: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - claims: d.claims, - endpoint: d.endpoint, - groupName: d.group_name, - ttl: d.ttl, - expireTime: d.expire_time, - })); +export const unmarshalForwardEtlTableMappingSchema: z.ZodType = z + .object({ + pg_table_oid: z.number().optional(), + uc_table_id: z.string().optional(), + last_synced_lsn: z.string().optional(), + pg_table_name: z.string().optional(), + uc_table_name: z.string().optional(), + enabled: z.boolean().optional(), + }) + .transform(d => ({ + pgTableOid: d.pg_table_oid, + ucTableId: d.uc_table_id, + lastSyncedLsn: d.last_synced_lsn, + pgTableName: d.pg_table_name, + ucTableName: d.uc_table_name, + enabled: d.enabled, + })); + +export const unmarshalGenerateDatabaseCredentialRequestSchema: z.ZodType = z + .object({ + claims: z.array(z.lazy(() => unmarshalRequestedClaimsSchema)).optional(), + endpoint: z.string().optional(), + group_name: z.string().optional(), + ttl: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + claims: d.claims, + endpoint: d.endpoint, + groupName: d.group_name, + ttl: d.ttl, + expireTime: d.expire_time, + })); export const unmarshalGetBranchRequestSchema: z.ZodType = z .object({ @@ -3055,67 +2954,61 @@ export const unmarshalGetCatalogRequestSchema: z.ZodType = z name: d.name, })); -export const unmarshalGetComputeInstanceRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalGetDatabaseRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalGetEndpointRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalGetForwardEtlMetadataRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - tenant_id: z.string().optional(), - timeline_id: z.string().optional(), - }) - .transform(d => ({ - parent: d.parent, - tenantId: d.tenant_id, - timelineId: d.timeline_id, - })); - -export const unmarshalGetForwardEtlStatusRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - tenant_id: z.string().optional(), - timeline_id: z.string().optional(), - }) - .transform(d => ({ - parent: d.parent, - tenantId: d.tenant_id, - timelineId: d.timeline_id, - })); - -export const unmarshalGetOperationRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalGetComputeInstanceRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalGetDatabaseRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalGetEndpointRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalGetForwardEtlMetadataRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + tenant_id: z.string().optional(), + timeline_id: z.string().optional(), + }) + .transform(d => ({ + parent: d.parent, + tenantId: d.tenant_id, + timelineId: d.timeline_id, + })); + +export const unmarshalGetForwardEtlStatusRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + tenant_id: z.string().optional(), + timeline_id: z.string().optional(), + }) + .transform(d => ({ + parent: d.parent, + tenantId: d.tenant_id, + timelineId: d.timeline_id, + })); + +export const unmarshalGetOperationRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const unmarshalGetProjectRequestSchema: z.ZodType = z .object({ @@ -3133,14 +3026,13 @@ export const unmarshalGetRoleRequestSchema: z.ZodType = z name: d.name, })); -export const unmarshalGetSyncedTableRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalGetSyncedTableRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const unmarshalGetTableRequestSchema: z.ZodType = z .object({ @@ -3150,138 +3042,125 @@ export const unmarshalGetTableRequestSchema: z.ZodType = z name: d.name, })); -export const unmarshalInitialEndpointSpecSchema: z.ZodType = - z - .object({ - group: z.lazy(() => unmarshalEndpointGroupSpecSchema).optional(), - }) - .transform(d => ({ - group: d.group, - })); - -export const unmarshalListBranchesRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - show_deleted: z.boolean().optional(), - }) - .transform(d => ({ - parent: d.parent, - pageToken: d.page_token, - pageSize: d.page_size, - showDeleted: d.show_deleted, - })); - -export const unmarshalListBranchesResponseSchema: z.ZodType = - z - .object({ - branches: z.array(z.lazy(() => unmarshalBranchSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - branches: d.branches, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListComputeInstancesRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - parent: d.parent, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListComputeInstancesResponseSchema: z.ZodType = - z - .object({ - compute_instances: z - .array(z.lazy(() => unmarshalComputeInstanceSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - computeInstances: d.compute_instances, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListDatabasesRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - parent: d.parent, - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListDatabasesResponseSchema: z.ZodType = - z - .object({ - databases: z.array(z.lazy(() => unmarshalDatabaseSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - databases: d.databases, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListEndpointsRequestSchema: z.ZodType = - z - .object({ - parent: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - parent: d.parent, - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListEndpointsResponseSchema: z.ZodType = - z - .object({ - endpoints: z.array(z.lazy(() => unmarshalEndpointSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - endpoints: d.endpoints, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListProjectsRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - show_deleted: z.boolean().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - showDeleted: d.show_deleted, - })); - -export const unmarshalListProjectsResponseSchema: z.ZodType = - z - .object({ - projects: z.array(z.lazy(() => unmarshalProjectSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - projects: d.projects, - nextPageToken: d.next_page_token, - })); +export const unmarshalInitialEndpointSpecSchema: z.ZodType = z + .object({ + group: z.lazy(() => unmarshalEndpointGroupSpecSchema).optional(), + }) + .transform(d => ({ + group: d.group, + })); + +export const unmarshalListBranchesRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + show_deleted: z.boolean().optional(), + }) + .transform(d => ({ + parent: d.parent, + pageToken: d.page_token, + pageSize: d.page_size, + showDeleted: d.show_deleted, + })); + +export const unmarshalListBranchesResponseSchema: z.ZodType = z + .object({ + branches: z.array(z.lazy(() => unmarshalBranchSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + branches: d.branches, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListComputeInstancesRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + parent: d.parent, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListComputeInstancesResponseSchema: z.ZodType = z + .object({ + compute_instances: z.array(z.lazy(() => unmarshalComputeInstanceSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + computeInstances: d.compute_instances, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListDatabasesRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + parent: d.parent, + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListDatabasesResponseSchema: z.ZodType = z + .object({ + databases: z.array(z.lazy(() => unmarshalDatabaseSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + databases: d.databases, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListEndpointsRequestSchema: z.ZodType = z + .object({ + parent: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + parent: d.parent, + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListEndpointsResponseSchema: z.ZodType = z + .object({ + endpoints: z.array(z.lazy(() => unmarshalEndpointSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + endpoints: d.endpoints, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListProjectsRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + show_deleted: z.boolean().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + showDeleted: d.show_deleted, + })); + +export const unmarshalListProjectsResponseSchema: z.ZodType = z + .object({ + projects: z.array(z.lazy(() => unmarshalProjectSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + projects: d.projects, + nextPageToken: d.next_page_token, + })); export const unmarshalListRolesRequestSchema: z.ZodType = z .object({ @@ -3322,9 +3201,7 @@ export const unmarshalOperationSchema: z.ZodType = z name: z.string().optional(), metadata: z.record(z.string(), z.unknown()).optional(), done: z.boolean().optional(), - error: z - .lazy(() => unmarshalDatabricksServiceExceptionWithDetailsProtoSchema) - .optional(), + error: z.lazy(() => unmarshalDatabricksServiceExceptionWithDetailsProtoSchema).optional(), response: z.record(z.string(), z.unknown()).optional(), }) .transform(d => ({ @@ -3339,27 +3216,13 @@ export const unmarshalProjectSchema: z.ZodType = z .object({ name: z.string().optional(), uid: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), spec: z.lazy(() => unmarshalProjectSpecSchema).optional(), status: z.lazy(() => unmarshalProjectStatusSchema).optional(), - initial_endpoint_spec: z - .lazy(() => unmarshalInitialEndpointSpecSchema) - .optional(), - delete_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - purge_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + initial_endpoint_spec: z.lazy(() => unmarshalInitialEndpointSpecSchema).optional(), + delete_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + purge_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), }) .transform(d => ({ name: d.name, @@ -3383,56 +3246,45 @@ export const unmarshalProjectCustomTagSchema: z.ZodType = z value: d.value, })); -export const unmarshalProjectDefaultEndpointSettingsSchema: z.ZodType = - z - .object({ - autoscaling_limit_min_cu: z.number().optional(), - autoscaling_limit_max_cu: z.number().optional(), - suspend_timeout_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - no_suspension: z.boolean().optional(), - pg_settings: z.record(z.string(), z.string()).optional(), - }) - .transform(d => ({ - autoscalingLimitMinCu: d.autoscaling_limit_min_cu, - autoscalingLimitMaxCu: d.autoscaling_limit_max_cu, - suspendTimeoutDuration: d.suspend_timeout_duration, - noSuspension: d.no_suspension, - pgSettings: d.pg_settings, - })); +export const unmarshalProjectDefaultEndpointSettingsSchema: z.ZodType = z + .object({ + autoscaling_limit_min_cu: z.number().optional(), + autoscaling_limit_max_cu: z.number().optional(), + suspend_timeout_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + no_suspension: z.boolean().optional(), + pg_settings: z.record(z.string(), z.string()).optional(), + }) + .transform(d => ({ + autoscalingLimitMinCu: d.autoscaling_limit_min_cu, + autoscalingLimitMaxCu: d.autoscaling_limit_max_cu, + suspendTimeoutDuration: d.suspend_timeout_duration, + noSuspension: d.no_suspension, + pgSettings: d.pg_settings, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalProjectDefaultEndpointSettings_PgSettingsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -export const unmarshalProjectOperationMetadataSchema: z.ZodType = - z.object({}); +export const unmarshalProjectDefaultEndpointSettings_PgSettingsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalProjectOperationMetadataSchema: z.ZodType = z + .object({ + }); export const unmarshalProjectSpecSchema: z.ZodType = z .object({ display_name: z.string().optional(), pg_version: z.number().optional(), - history_retention_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - default_endpoint_settings: z - .lazy(() => unmarshalProjectDefaultEndpointSettingsSchema) - .optional(), + history_retention_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + default_endpoint_settings: z.lazy(() => unmarshalProjectDefaultEndpointSettingsSchema).optional(), budget_policy_id: z.string().optional(), - custom_tags: z - .array(z.lazy(() => unmarshalProjectCustomTagSchema)) - .optional(), + custom_tags: z.array(z.lazy(() => unmarshalProjectCustomTagSchema)).optional(), workspace_key_encrypted: z.boolean().optional(), enable_pg_native_login: z.boolean().optional(), default_branch: z.string().optional(), @@ -3453,23 +3305,13 @@ export const unmarshalProjectStatusSchema: z.ZodType = z .object({ display_name: z.string().optional(), pg_version: z.number().optional(), - history_retention_duration: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - default_endpoint_settings: z - .lazy(() => unmarshalProjectDefaultEndpointSettingsSchema) - .optional(), + history_retention_duration: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + default_endpoint_settings: z.lazy(() => unmarshalProjectDefaultEndpointSettingsSchema).optional(), branch_logical_size_limit_bytes: z.number().optional(), synthetic_storage_size_bytes: z.number().optional(), - compute_last_active_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + compute_last_active_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), budget_policy_id: z.string().optional(), - custom_tags: z - .array(z.lazy(() => unmarshalProjectCustomTagSchema)) - .optional(), + custom_tags: z.array(z.lazy(() => unmarshalProjectCustomTagSchema)).optional(), owner: z.string().optional(), enable_pg_native_login: z.boolean().optional(), default_branch: z.string().optional(), @@ -3491,15 +3333,14 @@ export const unmarshalProjectStatusSchema: z.ZodType = z projectId: d.project_id, })); -export const unmarshalProvisioningInfoSchema: z.ZodType = - z.object({}); +export const unmarshalProvisioningInfoSchema: z.ZodType = z + .object({ + }); export const unmarshalRequestedClaimsSchema: z.ZodType = z .object({ permission_set: z.enum(RequestedClaims_PermissionSet).optional(), - resources: z - .array(z.lazy(() => unmarshalRequestedResourceSchema)) - .optional(), + resources: z.array(z.lazy(() => unmarshalRequestedResourceSchema)).optional(), }) .transform(d => ({ permissionSet: d.permission_set, @@ -3520,14 +3361,8 @@ export const unmarshalRoleSchema: z.ZodType = z .object({ name: z.string().optional(), parent: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), spec: z.lazy(() => unmarshalRole_RoleSpecSchema).optional(), status: z.lazy(() => unmarshalRole_RoleStatusSchema).optional(), }) @@ -3589,21 +3424,17 @@ export const unmarshalRole_RoleStatusSchema: z.ZodType = z roleId: d.role_id, })); -export const unmarshalRoleOperationMetadataSchema: z.ZodType = - z.object({}); +export const unmarshalRoleOperationMetadataSchema: z.ZodType = z + .object({ + }); export const unmarshalSyncedTableSchema: z.ZodType = z .object({ name: z.string().optional(), uid: z.string().optional(), spec: z.lazy(() => unmarshalSyncedTable_SyncedTableSpecSchema).optional(), - status: z - .lazy(() => unmarshalSyncedTable_SyncedTableStatusSchema) - .optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + status: z.lazy(() => unmarshalSyncedTable_SyncedTableStatusSchema).optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), }) .transform(d => ({ name: d.name, @@ -3614,112 +3445,90 @@ export const unmarshalSyncedTableSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalSyncedTable_SyncedTableSpecSchema: z.ZodType = - z - .object({ - postgres_database: z.string().optional(), - branch: z.string().optional(), - scheduling_policy: z - .enum(SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy) - .optional(), - source_table_full_name: z.string().optional(), - primary_key_columns: z.array(z.string()).optional(), - timeseries_key: z.string().optional(), - existing_pipeline_id: z.string().optional(), - create_database_objects_if_missing: z.boolean().optional(), - new_pipeline_spec: z - .lazy(() => unmarshalNewPipelineSpecSchema) - .optional(), - accelerated_sync: z.boolean().optional(), - }) - .transform(d => ({ - postgresDatabase: d.postgres_database, - branch: d.branch, - schedulingPolicy: d.scheduling_policy, - sourceTableFullName: d.source_table_full_name, - primaryKeyColumns: d.primary_key_columns, - timeseriesKey: d.timeseries_key, - existingPipelineId: d.existing_pipeline_id, - createDatabaseObjectsIfMissing: d.create_database_objects_if_missing, - newPipelineSpec: d.new_pipeline_spec, - acceleratedSync: d.accelerated_sync, - })); +export const unmarshalSyncedTable_SyncedTableSpecSchema: z.ZodType = z + .object({ + postgres_database: z.string().optional(), + branch: z.string().optional(), + scheduling_policy: z.enum(SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy).optional(), + source_table_full_name: z.string().optional(), + primary_key_columns: z.array(z.string()).optional(), + timeseries_key: z.string().optional(), + existing_pipeline_id: z.string().optional(), + create_database_objects_if_missing: z.boolean().optional(), + new_pipeline_spec: z.lazy(() => unmarshalNewPipelineSpecSchema).optional(), + accelerated_sync: z.boolean().optional(), + }) + .transform(d => ({ + postgresDatabase: d.postgres_database, + branch: d.branch, + schedulingPolicy: d.scheduling_policy, + sourceTableFullName: d.source_table_full_name, + primaryKeyColumns: d.primary_key_columns, + timeseriesKey: d.timeseries_key, + existingPipelineId: d.existing_pipeline_id, + createDatabaseObjectsIfMissing: d.create_database_objects_if_missing, + newPipelineSpec: d.new_pipeline_spec, + acceleratedSync: d.accelerated_sync, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalSyncedTable_SyncedTableStatusSchema: z.ZodType = - z - .object({ - message: z.string().optional(), - detailed_state: z.enum(SyncedTableState).optional(), - last_sync: z.lazy(() => unmarshalSyncedTablePositionSchema).optional(), - ongoing_sync_progress: z - .lazy(() => unmarshalSyncedTablePipelineProgressSchema) - .optional(), - provisioning_phase: z.enum(ProvisioningPhase).optional(), - last_processed_commit_version: z.number().optional(), - last_sync_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - pipeline_id: z.string().optional(), - unity_catalog_provisioning_state: z - .enum(ProvisioningInfo_State) - .optional(), - project: z.string().optional(), - }) - .transform(d => ({ - message: d.message, - detailedState: d.detailed_state, - lastSync: d.last_sync, - ongoingSyncProgress: d.ongoing_sync_progress, - provisioningPhase: d.provisioning_phase, - lastProcessedCommitVersion: d.last_processed_commit_version, - lastSyncTime: d.last_sync_time, - pipelineId: d.pipeline_id, - unityCatalogProvisioningState: d.unity_catalog_provisioning_state, - project: d.project, - })); - -export const unmarshalSyncedTableOperationMetadataSchema: z.ZodType = - z.object({}); - -export const unmarshalSyncedTablePipelineProgressSchema: z.ZodType = - z - .object({ - latest_version_currently_processing: z.number().optional(), - synced_row_count: z.number().optional(), - total_row_count: z.number().optional(), - sync_progress_completion: z.number().optional(), - estimated_completion_time_seconds: z.number().optional(), - }) - .transform(d => ({ - latestVersionCurrentlyProcessing: d.latest_version_currently_processing, - syncedRowCount: d.synced_row_count, - totalRowCount: d.total_row_count, - syncProgressCompletion: d.sync_progress_completion, - estimatedCompletionTimeSeconds: d.estimated_completion_time_seconds, - })); - -export const unmarshalSyncedTablePositionSchema: z.ZodType = - z - .object({ - sync_start_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - sync_end_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - delta_table_sync_info: z - .lazy(() => unmarshalDeltaTableSyncInfoSchema) - .optional(), - }) - .transform(d => ({ - syncStartTime: d.sync_start_time, - syncEndTime: d.sync_end_time, - deltaTableSyncInfo: d.delta_table_sync_info, - })); +export const unmarshalSyncedTable_SyncedTableStatusSchema: z.ZodType = z + .object({ + message: z.string().optional(), + detailed_state: z.enum(SyncedTableState).optional(), + last_sync: z.lazy(() => unmarshalSyncedTablePositionSchema).optional(), + ongoing_sync_progress: z.lazy(() => unmarshalSyncedTablePipelineProgressSchema).optional(), + provisioning_phase: z.enum(ProvisioningPhase).optional(), + last_processed_commit_version: z.number().optional(), + last_sync_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + pipeline_id: z.string().optional(), + unity_catalog_provisioning_state: z.enum(ProvisioningInfo_State).optional(), + project: z.string().optional(), + }) + .transform(d => ({ + message: d.message, + detailedState: d.detailed_state, + lastSync: d.last_sync, + ongoingSyncProgress: d.ongoing_sync_progress, + provisioningPhase: d.provisioning_phase, + lastProcessedCommitVersion: d.last_processed_commit_version, + lastSyncTime: d.last_sync_time, + pipelineId: d.pipeline_id, + unityCatalogProvisioningState: d.unity_catalog_provisioning_state, + project: d.project, + })); + +export const unmarshalSyncedTableOperationMetadataSchema: z.ZodType = z + .object({ + }); + +export const unmarshalSyncedTablePipelineProgressSchema: z.ZodType = z + .object({ + latest_version_currently_processing: z.number().optional(), + synced_row_count: z.number().optional(), + total_row_count: z.number().optional(), + sync_progress_completion: z.number().optional(), + estimated_completion_time_seconds: z.number().optional(), + }) + .transform(d => ({ + latestVersionCurrentlyProcessing: d.latest_version_currently_processing, + syncedRowCount: d.synced_row_count, + totalRowCount: d.total_row_count, + syncProgressCompletion: d.sync_progress_completion, + estimatedCompletionTimeSeconds: d.estimated_completion_time_seconds, + })); + +export const unmarshalSyncedTablePositionSchema: z.ZodType = z + .object({ + sync_start_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + sync_end_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + delta_table_sync_info: z.lazy(() => unmarshalDeltaTableSyncInfoSchema).optional(), + }) + .transform(d => ({ + syncStartTime: d.sync_start_time, + syncEndTime: d.sync_end_time, + deltaTableSyncInfo: d.delta_table_sync_info, + })); export const unmarshalTableSchema: z.ZodType
= z .object({ @@ -3737,63 +3546,58 @@ export const unmarshalTableSchema: z.ZodType
= z tableServingUrl: d.table_serving_url, })); -export const unmarshalUndeleteBranchRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalUpdateBranchRequestSchema: z.ZodType = - z - .object({ - branch: z.lazy(() => unmarshalBranchSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - branch: d.branch, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateDatabaseRequestSchema: z.ZodType = - z - .object({ - database: z.lazy(() => unmarshalDatabaseSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - database: d.database, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateEndpointRequestSchema: z.ZodType = - z - .object({ - endpoint: z.lazy(() => unmarshalEndpointSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - endpoint: d.endpoint, - updateMask: d.update_mask, - })); - -export const unmarshalUpdateProjectRequestSchema: z.ZodType = - z - .object({ - project: z.lazy(() => unmarshalProjectSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - project: d.project, - updateMask: d.update_mask, - })); +export const unmarshalUndeleteBranchRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalUpdateBranchRequestSchema: z.ZodType = z + .object({ + branch: z.lazy(() => unmarshalBranchSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + branch: d.branch, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateDatabaseRequestSchema: z.ZodType = z + .object({ + database: z.lazy(() => unmarshalDatabaseSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + database: d.database, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateEndpointRequestSchema: z.ZodType = z + .object({ + endpoint: z.lazy(() => unmarshalEndpointSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + endpoint: d.endpoint, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateProjectRequestSchema: z.ZodType = z + .object({ + project: z.lazy(() => unmarshalProjectSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + project: d.project, + updateMask: d.update_mask, + })); export const unmarshalUpdateRoleRequestSchema: z.ZodType = z .object({ role: z.lazy(() => unmarshalRoleSchema).optional(), - update_mask: z.string().optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), }) .transform(d => ({ role: d.role, @@ -3805,14 +3609,8 @@ export const marshalBranchSchema: z.ZodType = z name: z.string().optional(), uid: z.string().optional(), parent: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), spec: z.lazy(() => marshalBranchSpecSchema).optional(), status: z.lazy(() => marshalBranchStatusSchema).optional(), }) @@ -3826,25 +3624,18 @@ export const marshalBranchSchema: z.ZodType = z status: d.status, })); -export const marshalBranchOperationMetadataSchema: z.ZodType = z.object({}); +export const marshalBranchOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalBranchSpecSchema: z.ZodType = z .object({ sourceBranch: z.string().optional(), sourceBranchLsn: z.string().optional(), - sourceBranchTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + sourceBranchTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), isProtected: z.boolean().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - ttl: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + ttl: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), noExpiry: z.boolean().optional(), }) .transform(d => ({ @@ -3861,32 +3652,17 @@ export const marshalBranchStatusSchema: z.ZodType = z .object({ sourceBranch: z.string().optional(), sourceBranchLsn: z.string().optional(), - sourceBranchTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + sourceBranchTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), default: z.boolean().optional(), isProtected: z.boolean().optional(), currentState: z.enum(BranchStatus_State).optional(), pendingState: z.enum(BranchStatus_State).optional(), - stateChangeTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + stateChangeTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), logicalSizeBytes: z.number().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), branchId: z.string().optional(), - deleteTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - purgeTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + deleteTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + purgeTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ source_branch: d.sourceBranch, @@ -3910,14 +3686,8 @@ export const marshalCatalogSchema: z.ZodType = z uid: z.string().optional(), spec: z.lazy(() => marshalCatalog_CatalogSpecSchema).optional(), status: z.lazy(() => marshalCatalog_CatalogStatusSchema).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ name: d.name, @@ -3956,7 +3726,9 @@ export const marshalCatalog_CatalogStatusSchema: z.ZodType = z catalog_id: d.catalogId, })); -export const marshalCatalogOperationMetadataSchema: z.ZodType = z.object({}); +export const marshalCatalogOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalComputeInstanceSchema: z.ZodType = z .object({ @@ -3966,14 +3738,8 @@ export const marshalComputeInstanceSchema: z.ZodType = z pendingState: z.enum(ComputeInstance_ComputeState).optional(), role: z.enum(ComputeInstance_ComputeType).optional(), computeHost: z.string().optional(), - startTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - suspendTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + startTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + suspendTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ name: d.name, @@ -4076,14 +3842,8 @@ export const marshalDatabaseSchema: z.ZodType = z .object({ name: z.string().optional(), parent: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), spec: z.lazy(() => marshalDatabase_DatabaseSpecSchema).optional(), status: z.lazy(() => marshalDatabase_DatabaseStatusSchema).optional(), }) @@ -4123,32 +3883,30 @@ export const marshalDatabase_DatabaseStatusSchema: z.ZodType = z export const marshalDatabaseCredentialSchema: z.ZodType = z .object({ token: z.string().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ token: d.token, expire_time: d.expireTime, })); -export const marshalDatabaseOperationMetadataSchema: z.ZodType = z.object({}); +export const marshalDatabaseOperationMetadataSchema: z.ZodType = z + .object({ + }); -export const marshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = - z - .object({ - errorCode: z.enum(ErrorCode).optional(), - message: z.string().optional(), - stackTrace: z.string().optional(), - details: z.array(z.record(z.string(), z.unknown())).optional(), - }) - .transform(d => ({ - error_code: d.errorCode, - message: d.message, - stack_trace: d.stackTrace, - details: d.details, - })); +export const marshalDatabricksServiceExceptionWithDetailsProtoSchema: z.ZodType = z + .object({ + errorCode: z.enum(ErrorCode).optional(), + message: z.string().optional(), + stackTrace: z.string().optional(), + details: z.array(z.record(z.string(), z.unknown())).optional(), + }) + .transform(d => ({ + error_code: d.errorCode, + message: d.message, + stack_trace: d.stackTrace, + details: d.details, + })); export const marshalDeleteBranchRequestSchema: z.ZodType = z .object({ @@ -4189,9 +3947,11 @@ export const marshalDeleteEndpointRequestSchema: z.ZodType = z export const marshalDeleteProjectRequestSchema: z.ZodType = z .object({ name: z.string().optional(), + purge: z.boolean().optional(), }) .transform(d => ({ name: d.name, + purge: d.purge, })); export const marshalDeleteRoleRequestSchema: z.ZodType = z @@ -4223,10 +3983,7 @@ export const marshalDeleteTableRequestSchema: z.ZodType = z export const marshalDeltaTableSyncInfoSchema: z.ZodType = z .object({ deltaCommitVersion: z.number().optional(), - deltaCommitTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + deltaCommitTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ delta_commit_version: d.deltaCommitVersion, @@ -4262,14 +4019,8 @@ export const marshalEndpointSchema: z.ZodType = z name: z.string().optional(), uid: z.string().optional(), parent: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), spec: z.lazy(() => marshalEndpointSpecSchema).optional(), status: z.lazy(() => marshalEndpointStatusSchema).optional(), }) @@ -4321,7 +4072,9 @@ export const marshalEndpointHostsSchema: z.ZodType = z read_only_pooled_host: d.readOnlyPooledHost, })); -export const marshalEndpointOperationMetadataSchema: z.ZodType = z.object({}); +export const marshalEndpointOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalEndpointSettingsSchema: z.ZodType = z .object({ @@ -4348,10 +4101,7 @@ export const marshalEndpointSpecSchema: z.ZodType = z autoscalingLimitMinCu: z.number().optional(), autoscalingLimitMaxCu: z.number().optional(), disabled: z.boolean().optional(), - suspendTimeoutDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + suspendTimeoutDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), noSuspension: z.boolean().optional(), settings: z.lazy(() => marshalEndpointSettingsSchema).optional(), group: z.lazy(() => marshalEndpointGroupSpecSchema).optional(), @@ -4371,19 +4121,13 @@ export const marshalEndpointStatusSchema: z.ZodType = z .object({ endpointType: z.enum(EndpointType).optional(), hosts: z.lazy(() => marshalEndpointHostsSchema).optional(), - lastActiveTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + lastActiveTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), autoscalingLimitMinCu: z.number().optional(), autoscalingLimitMaxCu: z.number().optional(), currentState: z.enum(EndpointStatus_State).optional(), pendingState: z.enum(EndpointStatus_State).optional(), disabled: z.boolean().optional(), - suspendTimeoutDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + suspendTimeoutDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), settings: z.lazy(() => marshalEndpointSettingsSchema).optional(), group: z.lazy(() => marshalEndpointGroupStatusSchema).optional(), endpointId: z.string().optional(), @@ -4441,9 +4185,7 @@ export const marshalForwardEtlDatabaseSchema: z.ZodType = z export const marshalForwardEtlMetadataSchema: z.ZodType = z .object({ - databases: z - .array(z.lazy(() => marshalForwardEtlDatabaseSchema)) - .optional(), + databases: z.array(z.lazy(() => marshalForwardEtlDatabaseSchema)).optional(), schemas: z.array(z.lazy(() => marshalForwardEtlSchemaSchema)).optional(), }) .transform(d => ({ @@ -4463,12 +4205,8 @@ export const marshalForwardEtlSchemaSchema: z.ZodType = z export const marshalForwardEtlStatusSchema: z.ZodType = z .object({ - configurations: z - .array(z.lazy(() => marshalForwardEtlConfigSchema)) - .optional(), - tableMappings: z - .array(z.lazy(() => marshalForwardEtlTableMappingSchema)) - .optional(), + configurations: z.array(z.lazy(() => marshalForwardEtlConfigSchema)).optional(), + tableMappings: z.array(z.lazy(() => marshalForwardEtlTableMappingSchema)).optional(), }) .transform(d => ({ configurations: d.configurations, @@ -4498,14 +4236,8 @@ export const marshalGenerateDatabaseCredentialRequestSchema: z.ZodType = z claims: z.array(z.lazy(() => marshalRequestedClaimsSchema)).optional(), endpoint: z.string().optional(), groupName: z.string().optional(), - ttl: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + ttl: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ claims: d.claims, @@ -4665,9 +4397,7 @@ export const marshalListComputeInstancesRequestSchema: z.ZodType = z export const marshalListComputeInstancesResponseSchema: z.ZodType = z .object({ - computeInstances: z - .array(z.lazy(() => marshalComputeInstanceSchema)) - .optional(), + computeInstances: z.array(z.lazy(() => marshalComputeInstanceSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -4780,9 +4510,7 @@ export const marshalOperationSchema: z.ZodType = z name: z.string().optional(), metadata: z.record(z.string(), z.unknown()).optional(), done: z.boolean().optional(), - error: z - .lazy(() => marshalDatabricksServiceExceptionWithDetailsProtoSchema) - .optional(), + error: z.lazy(() => marshalDatabricksServiceExceptionWithDetailsProtoSchema).optional(), response: z.record(z.string(), z.unknown()).optional(), }) .transform(d => ({ @@ -4797,27 +4525,13 @@ export const marshalProjectSchema: z.ZodType = z .object({ name: z.string().optional(), uid: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), spec: z.lazy(() => marshalProjectSpecSchema).optional(), status: z.lazy(() => marshalProjectStatusSchema).optional(), - initialEndpointSpec: z - .lazy(() => marshalInitialEndpointSpecSchema) - .optional(), - deleteTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - purgeTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + initialEndpointSpec: z.lazy(() => marshalInitialEndpointSpecSchema).optional(), + deleteTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + purgeTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ name: d.name, @@ -4845,10 +4559,7 @@ export const marshalProjectDefaultEndpointSettingsSchema: z.ZodType = z .object({ autoscalingLimitMinCu: z.number().optional(), autoscalingLimitMaxCu: z.number().optional(), - suspendTimeoutDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + suspendTimeoutDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), noSuspension: z.boolean().optional(), pgSettings: z.record(z.string(), z.string()).optional(), }) @@ -4861,30 +4572,26 @@ export const marshalProjectDefaultEndpointSettingsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalProjectDefaultEndpointSettings_PgSettingsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -export const marshalProjectOperationMetadataSchema: z.ZodType = z.object({}); +export const marshalProjectDefaultEndpointSettings_PgSettingsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const marshalProjectOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalProjectSpecSchema: z.ZodType = z .object({ displayName: z.string().optional(), pgVersion: z.number().optional(), - historyRetentionDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), - defaultEndpointSettings: z - .lazy(() => marshalProjectDefaultEndpointSettingsSchema) - .optional(), + historyRetentionDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), + defaultEndpointSettings: z.lazy(() => marshalProjectDefaultEndpointSettingsSchema).optional(), budgetPolicyId: z.string().optional(), customTags: z.array(z.lazy(() => marshalProjectCustomTagSchema)).optional(), workspaceKeyEncrypted: z.boolean().optional(), @@ -4907,19 +4614,11 @@ export const marshalProjectStatusSchema: z.ZodType = z .object({ displayName: z.string().optional(), pgVersion: z.number().optional(), - historyRetentionDuration: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), - defaultEndpointSettings: z - .lazy(() => marshalProjectDefaultEndpointSettingsSchema) - .optional(), + historyRetentionDuration: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), + defaultEndpointSettings: z.lazy(() => marshalProjectDefaultEndpointSettingsSchema).optional(), branchLogicalSizeLimitBytes: z.number().optional(), syntheticStorageSizeBytes: z.number().optional(), - computeLastActiveTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + computeLastActiveTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), budgetPolicyId: z.string().optional(), customTags: z.array(z.lazy(() => marshalProjectCustomTagSchema)).optional(), owner: z.string().optional(), @@ -4943,7 +4642,9 @@ export const marshalProjectStatusSchema: z.ZodType = z project_id: d.projectId, })); -export const marshalProvisioningInfoSchema: z.ZodType = z.object({}); +export const marshalProvisioningInfoSchema: z.ZodType = z + .object({ + }); export const marshalRequestedClaimsSchema: z.ZodType = z .object({ @@ -4969,14 +4670,8 @@ export const marshalRoleSchema: z.ZodType = z .object({ name: z.string().optional(), parent: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), spec: z.lazy(() => marshalRole_RoleSpecSchema).optional(), status: z.lazy(() => marshalRole_RoleStatusSchema).optional(), }) @@ -5038,7 +4733,9 @@ export const marshalRole_RoleStatusSchema: z.ZodType = z role_id: d.roleId, })); -export const marshalRoleOperationMetadataSchema: z.ZodType = z.object({}); +export const marshalRoleOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalSyncedTableSchema: z.ZodType = z .object({ @@ -5046,10 +4743,7 @@ export const marshalSyncedTableSchema: z.ZodType = z uid: z.string().optional(), spec: z.lazy(() => marshalSyncedTable_SyncedTableSpecSchema).optional(), status: z.lazy(() => marshalSyncedTable_SyncedTableStatusSchema).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ name: d.name, @@ -5064,9 +4758,7 @@ export const marshalSyncedTable_SyncedTableSpecSchema: z.ZodType = z .object({ postgresDatabase: z.string().optional(), branch: z.string().optional(), - schedulingPolicy: z - .enum(SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy) - .optional(), + schedulingPolicy: z.enum(SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy).optional(), sourceTableFullName: z.string().optional(), primaryKeyColumns: z.array(z.string()).optional(), timeseriesKey: z.string().optional(), @@ -5094,15 +4786,10 @@ export const marshalSyncedTable_SyncedTableStatusSchema: z.ZodType = z message: z.string().optional(), detailedState: z.enum(SyncedTableState).optional(), lastSync: z.lazy(() => marshalSyncedTablePositionSchema).optional(), - ongoingSyncProgress: z - .lazy(() => marshalSyncedTablePipelineProgressSchema) - .optional(), + ongoingSyncProgress: z.lazy(() => marshalSyncedTablePipelineProgressSchema).optional(), provisioningPhase: z.enum(ProvisioningPhase).optional(), lastProcessedCommitVersion: z.number().optional(), - lastSyncTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + lastSyncTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), pipelineId: z.string().optional(), unityCatalogProvisioningState: z.enum(ProvisioningInfo_State).optional(), project: z.string().optional(), @@ -5120,9 +4807,9 @@ export const marshalSyncedTable_SyncedTableStatusSchema: z.ZodType = z project: d.project, })); -export const marshalSyncedTableOperationMetadataSchema: z.ZodType = z.object( - {} -); +export const marshalSyncedTableOperationMetadataSchema: z.ZodType = z + .object({ + }); export const marshalSyncedTablePipelineProgressSchema: z.ZodType = z .object({ @@ -5142,17 +4829,9 @@ export const marshalSyncedTablePipelineProgressSchema: z.ZodType = z export const marshalSyncedTablePositionSchema: z.ZodType = z .object({ - syncStartTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - syncEndTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - deltaTableSyncInfo: z - .lazy(() => marshalDeltaTableSyncInfoSchema) - .optional(), + syncStartTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + syncEndTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + deltaTableSyncInfo: z.lazy(() => marshalDeltaTableSyncInfoSchema).optional(), }) .transform(d => ({ sync_start_time: d.syncStartTime, @@ -5187,7 +4866,7 @@ export const marshalUndeleteBranchRequestSchema: z.ZodType = z export const marshalUpdateBranchRequestSchema: z.ZodType = z .object({ branch: z.lazy(() => marshalBranchSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ branch: d.branch, @@ -5197,7 +4876,7 @@ export const marshalUpdateBranchRequestSchema: z.ZodType = z export const marshalUpdateDatabaseRequestSchema: z.ZodType = z .object({ database: z.lazy(() => marshalDatabaseSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ database: d.database, @@ -5207,7 +4886,7 @@ export const marshalUpdateDatabaseRequestSchema: z.ZodType = z export const marshalUpdateEndpointRequestSchema: z.ZodType = z .object({ endpoint: z.lazy(() => marshalEndpointSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ endpoint: d.endpoint, @@ -5217,7 +4896,7 @@ export const marshalUpdateEndpointRequestSchema: z.ZodType = z export const marshalUpdateProjectRequestSchema: z.ZodType = z .object({ project: z.lazy(() => marshalProjectSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ project: d.project, @@ -5227,7 +4906,7 @@ export const marshalUpdateProjectRequestSchema: z.ZodType = z export const marshalUpdateRoleRequestSchema: z.ZodType = z .object({ role: z.lazy(() => marshalRoleSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ role: d.role, diff --git a/packages/postgres/src/v1/utils.ts b/packages/postgres/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/postgres/src/v1/utils.ts +++ b/packages/postgres/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/postgres/tsconfig.json b/packages/postgres/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/postgres/tsconfig.json +++ b/packages/postgres/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/qualitymonitor/package.json b/packages/qualitymonitor/package.json index ed583d2b..8dff7e3c 100644 --- a/packages/qualitymonitor/package.json +++ b/packages/qualitymonitor/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/qualitymonitor/src/v2/client.ts b/packages/qualitymonitor/src/v2/client.ts index d684ee56..4b7cc664 100644 --- a/packages/qualitymonitor/src/v2/client.ts +++ b/packages/qualitymonitor/src/v2/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateQualityMonitorRequest, DeleteQualityMonitorRequest, @@ -46,24 +41,13 @@ export class Client { * Deprecated: Use Data Quality Monitoring API instead (/api/data-quality/v1/monitors). * Create a quality monitor on UC object. */ - async createQualityMonitor( - signal: AbortSignal | undefined, - req: CreateQualityMonitorRequest, - options?: Options - ): Promise { + async createQualityMonitor(signal: AbortSignal | undefined, req: CreateQualityMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/quality-monitors`; - const body = marshalRequest( - req.qualityMonitor, - marshalQualityMonitorSchema - ); + const body = marshalRequest(req.qualityMonitor, marshalQualityMonitorSchema); let resp: QualityMonitor | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalQualityMonitorSchema); }; await execute(signal, call, options); @@ -77,19 +61,11 @@ export class Client { * Deprecated: Use Data Quality Monitoring API instead (/api/data-quality/v1/monitors). * Delete a quality monitor on UC object. */ - async deleteQualityMonitor( - signal: AbortSignal | undefined, - req: DeleteQualityMonitorRequest, - options?: Options - ): Promise { + async deleteQualityMonitor(signal: AbortSignal | undefined, req: DeleteQualityMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/quality-monitors/${req.objectType ?? ''}/${req.objectId ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } @@ -98,20 +74,12 @@ export class Client { * Deprecated: Use Data Quality Monitoring API instead (/api/data-quality/v1/monitors). * Read a quality monitor on UC object. */ - async getQualityMonitor( - signal: AbortSignal | undefined, - req: GetQualityMonitorRequest, - options?: Options - ): Promise { + async getQualityMonitor(signal: AbortSignal | undefined, req: GetQualityMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/quality-monitors/${req.objectType ?? ''}/${req.objectId ?? ''}`; let resp: QualityMonitor | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalQualityMonitorSchema); }; await execute(signal, call, options); @@ -125,11 +93,7 @@ export class Client { * Deprecated: Use Data Quality Monitoring API instead (/api/data-quality/v1/monitors). * (Unimplemented) List quality monitors. */ - async listQualityMonitor( - signal: AbortSignal | undefined, - req: ListQualityMonitorRequest, - options?: Options - ): Promise { + async listQualityMonitor(signal: AbortSignal | undefined, req: ListQualityMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/quality-monitors`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -143,11 +107,7 @@ export class Client { let resp: ListQualityMonitorResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListQualityMonitorResponseSchema); }; await execute(signal, call, options); @@ -157,11 +117,8 @@ export class Client { return resp; } - async *listQualityMonitorIter( - signal: AbortSignal | undefined, - req: ListQualityMonitorRequest, - options?: Options - ): AsyncGenerator { + + async *listQualityMonitorIter(signal: AbortSignal | undefined, req: ListQualityMonitorRequest, options?: Options): AsyncGenerator { const pageReq: ListQualityMonitorRequest = {...req}; for (;;) { const resp = await this.listQualityMonitor(signal, pageReq, options); @@ -175,28 +132,18 @@ export class Client { } } + /** * Deprecated: Use Data Quality Monitoring API instead (/api/data-quality/v1/monitors). * (Unimplemented) Update a quality monitor on UC object. */ - async updateQualityMonitor( - signal: AbortSignal | undefined, - req: UpdateQualityMonitorRequest, - options?: Options - ): Promise { + async updateQualityMonitor(signal: AbortSignal | undefined, req: UpdateQualityMonitorRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/quality-monitors/${req.objectType ?? ''}/${req.objectId ?? ''}`; - const body = marshalRequest( - req.qualityMonitor, - marshalQualityMonitorSchema - ); + const body = marshalRequest(req.qualityMonitor, marshalQualityMonitorSchema); let resp: QualityMonitor | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalQualityMonitorSchema); }; await execute(signal, call, options); diff --git a/packages/qualitymonitor/src/v2/index.ts b/packages/qualitymonitor/src/v2/index.ts index 3559eb0e..6c929d93 100644 --- a/packages/qualitymonitor/src/v2/index.ts +++ b/packages/qualitymonitor/src/v2/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/qualitymonitor/src/v2/model.ts b/packages/qualitymonitor/src/v2/model.ts index 1e3c572e..0d932d89 100644 --- a/packages/qualitymonitor/src/v2/model.ts +++ b/packages/qualitymonitor/src/v2/model.ts @@ -150,28 +150,23 @@ export interface ValidityCheckConfiguration { uniquenessValidityCheck?: UniquenessValidityCheck | undefined; } -export const unmarshalAnomalyDetectionConfigSchema: z.ZodType = - z - .object({ - last_run_id: z.string().optional(), - latest_run_status: z.enum(AnomalyDetectionRunStatus).optional(), - job_type: z.enum(AnomalyDetectionJobType).optional(), - excluded_table_full_names: z.array(z.string()).optional(), - custom_check_configurations: z - .array(z.lazy(() => unmarshalCustomCheckConfigurationSchema)) - .optional(), - validity_check_configurations: z - .array(z.lazy(() => unmarshalValidityCheckConfigurationSchema)) - .optional(), - }) - .transform(d => ({ - lastRunId: d.last_run_id, - latestRunStatus: d.latest_run_status, - jobType: d.job_type, - excludedTableFullNames: d.excluded_table_full_names, - customCheckConfigurations: d.custom_check_configurations, - validityCheckConfigurations: d.validity_check_configurations, - })); +export const unmarshalAnomalyDetectionConfigSchema: z.ZodType = z + .object({ + last_run_id: z.string().optional(), + latest_run_status: z.enum(AnomalyDetectionRunStatus).optional(), + job_type: z.enum(AnomalyDetectionJobType).optional(), + excluded_table_full_names: z.array(z.string()).optional(), + custom_check_configurations: z.array(z.lazy(() => unmarshalCustomCheckConfigurationSchema)).optional(), + validity_check_configurations: z.array(z.lazy(() => unmarshalValidityCheckConfigurationSchema)).optional(), + }) + .transform(d => ({ + lastRunId: d.last_run_id, + latestRunStatus: d.latest_run_status, + jobType: d.job_type, + excludedTableFullNames: d.excluded_table_full_names, + customCheckConfigurations: d.custom_check_configurations, + validityCheckConfigurations: d.validity_check_configurations, + })); export const unmarshalColumnMatcherSchema: z.ZodType = z .object({ @@ -183,42 +178,37 @@ export const unmarshalColumnMatcherSchema: z.ZodType = z columnNames: d.column_names, })); -export const unmarshalCreateQualityMonitorRequestSchema: z.ZodType = - z - .object({ - quality_monitor: z.lazy(() => unmarshalQualityMonitorSchema).optional(), - }) - .transform(d => ({ - qualityMonitor: d.quality_monitor, - })); - -export const unmarshalCustomCheckConfigurationSchema: z.ZodType = - z - .object({ - scalar_check: z.lazy(() => unmarshalCustomScalarCheckSchema).optional(), - }) - .transform(d => ({ - scalarCheck: d.scalar_check, - })); - -export const unmarshalCustomCheckThresholdsSchema: z.ZodType = - z - .object({ - lower_bound: z.lazy(() => unmarshalThresholdSchema).optional(), - upper_bound: z.lazy(() => unmarshalThresholdSchema).optional(), - }) - .transform(d => ({ - lowerBound: d.lower_bound, - upperBound: d.upper_bound, - })); +export const unmarshalCreateQualityMonitorRequestSchema: z.ZodType = z + .object({ + quality_monitor: z.lazy(() => unmarshalQualityMonitorSchema).optional(), + }) + .transform(d => ({ + qualityMonitor: d.quality_monitor, + })); + +export const unmarshalCustomCheckConfigurationSchema: z.ZodType = z + .object({ + scalar_check: z.lazy(() => unmarshalCustomScalarCheckSchema).optional(), + }) + .transform(d => ({ + scalarCheck: d.scalar_check, + })); + +export const unmarshalCustomCheckThresholdsSchema: z.ZodType = z + .object({ + lower_bound: z.lazy(() => unmarshalThresholdSchema).optional(), + upper_bound: z.lazy(() => unmarshalThresholdSchema).optional(), + }) + .transform(d => ({ + lowerBound: d.lower_bound, + upperBound: d.upper_bound, + })); export const unmarshalCustomScalarCheckSchema: z.ZodType = z .object({ check_name: z.string().optional(), sql_query: z.string().optional(), - column_matchers: z - .array(z.lazy(() => unmarshalColumnMatcherSchema)) - .optional(), + column_matchers: z.array(z.lazy(() => unmarshalColumnMatcherSchema)).optional(), thresholds: z.lazy(() => unmarshalCustomCheckThresholdsSchema).optional(), }) .transform(d => ({ @@ -228,73 +218,62 @@ export const unmarshalCustomScalarCheckSchema: z.ZodType = z thresholds: d.thresholds, })); -export const unmarshalDeleteQualityMonitorRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - })); - -export const unmarshalGetQualityMonitorRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - })); - -export const unmarshalListQualityMonitorRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListQualityMonitorResponseSchema: z.ZodType = - z - .object({ - quality_monitors: z - .array(z.lazy(() => unmarshalQualityMonitorSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - qualityMonitors: d.quality_monitors, - nextPageToken: d.next_page_token, - })); - -export const unmarshalPercentNullValidityCheckSchema: z.ZodType = - z - .object({ - column_names: z.array(z.string()).optional(), - upper_bound: z.number().optional(), - }) - .transform(d => ({ - columnNames: d.column_names, - upperBound: d.upper_bound, - })); +export const unmarshalDeleteQualityMonitorRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + })); + +export const unmarshalGetQualityMonitorRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + })); + +export const unmarshalListQualityMonitorRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListQualityMonitorResponseSchema: z.ZodType = z + .object({ + quality_monitors: z.array(z.lazy(() => unmarshalQualityMonitorSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + qualityMonitors: d.quality_monitors, + nextPageToken: d.next_page_token, + })); + +export const unmarshalPercentNullValidityCheckSchema: z.ZodType = z + .object({ + column_names: z.array(z.string()).optional(), + upper_bound: z.number().optional(), + }) + .transform(d => ({ + columnNames: d.column_names, + upperBound: d.upper_bound, + })); export const unmarshalQualityMonitorSchema: z.ZodType = z .object({ object_type: z.string().optional(), object_id: z.string().optional(), - anomaly_detection_config: z - .lazy(() => unmarshalAnomalyDetectionConfigSchema) - .optional(), - validity_check_configurations: z - .array(z.lazy(() => unmarshalValidityCheckConfigurationSchema)) - .optional(), + anomaly_detection_config: z.lazy(() => unmarshalAnomalyDetectionConfigSchema).optional(), + validity_check_configurations: z.array(z.lazy(() => unmarshalValidityCheckConfigurationSchema)).optional(), }) .transform(d => ({ objectType: d.object_type, @@ -303,18 +282,17 @@ export const unmarshalQualityMonitorSchema: z.ZodType = z validityCheckConfigurations: d.validity_check_configurations, })); -export const unmarshalRangeValidityCheckSchema: z.ZodType = - z - .object({ - column_names: z.array(z.string()).optional(), - lower_bound: z.number().optional(), - upper_bound: z.number().optional(), - }) - .transform(d => ({ - columnNames: d.column_names, - lowerBound: d.lower_bound, - upperBound: d.upper_bound, - })); +export const unmarshalRangeValidityCheckSchema: z.ZodType = z + .object({ + column_names: z.array(z.string()).optional(), + lower_bound: z.number().optional(), + upper_bound: z.number().optional(), + }) + .transform(d => ({ + columnNames: d.column_names, + lowerBound: d.lower_bound, + upperBound: d.upper_bound, + })); export const unmarshalThresholdSchema: z.ZodType = z .object({ @@ -326,48 +304,39 @@ export const unmarshalThresholdSchema: z.ZodType = z thresholdType: d.threshold_type, })); -export const unmarshalUniquenessValidityCheckSchema: z.ZodType = - z - .object({ - column_names: z.array(z.string()).optional(), - }) - .transform(d => ({ - columnNames: d.column_names, - })); - -export const unmarshalUpdateQualityMonitorRequestSchema: z.ZodType = - z - .object({ - object_type: z.string().optional(), - object_id: z.string().optional(), - quality_monitor: z.lazy(() => unmarshalQualityMonitorSchema).optional(), - }) - .transform(d => ({ - objectType: d.object_type, - objectId: d.object_id, - qualityMonitor: d.quality_monitor, - })); - -export const unmarshalValidityCheckConfigurationSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - percent_null_validity_check: z - .lazy(() => unmarshalPercentNullValidityCheckSchema) - .optional(), - range_validity_check: z - .lazy(() => unmarshalRangeValidityCheckSchema) - .optional(), - uniqueness_validity_check: z - .lazy(() => unmarshalUniquenessValidityCheckSchema) - .optional(), - }) - .transform(d => ({ - name: d.name, - percentNullValidityCheck: d.percent_null_validity_check, - rangeValidityCheck: d.range_validity_check, - uniquenessValidityCheck: d.uniqueness_validity_check, - })); +export const unmarshalUniquenessValidityCheckSchema: z.ZodType = z + .object({ + column_names: z.array(z.string()).optional(), + }) + .transform(d => ({ + columnNames: d.column_names, + })); + +export const unmarshalUpdateQualityMonitorRequestSchema: z.ZodType = z + .object({ + object_type: z.string().optional(), + object_id: z.string().optional(), + quality_monitor: z.lazy(() => unmarshalQualityMonitorSchema).optional(), + }) + .transform(d => ({ + objectType: d.object_type, + objectId: d.object_id, + qualityMonitor: d.quality_monitor, + })); + +export const unmarshalValidityCheckConfigurationSchema: z.ZodType = z + .object({ + name: z.string().optional(), + percent_null_validity_check: z.lazy(() => unmarshalPercentNullValidityCheckSchema).optional(), + range_validity_check: z.lazy(() => unmarshalRangeValidityCheckSchema).optional(), + uniqueness_validity_check: z.lazy(() => unmarshalUniquenessValidityCheckSchema).optional(), + }) + .transform(d => ({ + name: d.name, + percentNullValidityCheck: d.percent_null_validity_check, + rangeValidityCheck: d.range_validity_check, + uniquenessValidityCheck: d.uniqueness_validity_check, + })); export const marshalAnomalyDetectionConfigSchema: z.ZodType = z .object({ @@ -375,12 +344,8 @@ export const marshalAnomalyDetectionConfigSchema: z.ZodType = z latestRunStatus: z.enum(AnomalyDetectionRunStatus).optional(), jobType: z.enum(AnomalyDetectionJobType).optional(), excludedTableFullNames: z.array(z.string()).optional(), - customCheckConfigurations: z - .array(z.lazy(() => marshalCustomCheckConfigurationSchema)) - .optional(), - validityCheckConfigurations: z - .array(z.lazy(() => marshalValidityCheckConfigurationSchema)) - .optional(), + customCheckConfigurations: z.array(z.lazy(() => marshalCustomCheckConfigurationSchema)).optional(), + validityCheckConfigurations: z.array(z.lazy(() => marshalValidityCheckConfigurationSchema)).optional(), }) .transform(d => ({ last_run_id: d.lastRunId, @@ -431,9 +396,7 @@ export const marshalCustomScalarCheckSchema: z.ZodType = z .object({ checkName: z.string().optional(), sqlQuery: z.string().optional(), - columnMatchers: z - .array(z.lazy(() => marshalColumnMatcherSchema)) - .optional(), + columnMatchers: z.array(z.lazy(() => marshalColumnMatcherSchema)).optional(), thresholds: z.lazy(() => marshalCustomCheckThresholdsSchema).optional(), }) .transform(d => ({ @@ -475,9 +438,7 @@ export const marshalListQualityMonitorRequestSchema: z.ZodType = z export const marshalListQualityMonitorResponseSchema: z.ZodType = z .object({ - qualityMonitors: z - .array(z.lazy(() => marshalQualityMonitorSchema)) - .optional(), + qualityMonitors: z.array(z.lazy(() => marshalQualityMonitorSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -499,12 +460,8 @@ export const marshalQualityMonitorSchema: z.ZodType = z .object({ objectType: z.string().optional(), objectId: z.string().optional(), - anomalyDetectionConfig: z - .lazy(() => marshalAnomalyDetectionConfigSchema) - .optional(), - validityCheckConfigurations: z - .array(z.lazy(() => marshalValidityCheckConfigurationSchema)) - .optional(), + anomalyDetectionConfig: z.lazy(() => marshalAnomalyDetectionConfigSchema).optional(), + validityCheckConfigurations: z.array(z.lazy(() => marshalValidityCheckConfigurationSchema)).optional(), }) .transform(d => ({ object_type: d.objectType, @@ -558,15 +515,9 @@ export const marshalUpdateQualityMonitorRequestSchema: z.ZodType = z export const marshalValidityCheckConfigurationSchema: z.ZodType = z .object({ name: z.string().optional(), - percentNullValidityCheck: z - .lazy(() => marshalPercentNullValidityCheckSchema) - .optional(), - rangeValidityCheck: z - .lazy(() => marshalRangeValidityCheckSchema) - .optional(), - uniquenessValidityCheck: z - .lazy(() => marshalUniquenessValidityCheckSchema) - .optional(), + percentNullValidityCheck: z.lazy(() => marshalPercentNullValidityCheckSchema).optional(), + rangeValidityCheck: z.lazy(() => marshalRangeValidityCheckSchema).optional(), + uniquenessValidityCheck: z.lazy(() => marshalUniquenessValidityCheckSchema).optional(), }) .transform(d => ({ name: d.name, diff --git a/packages/qualitymonitor/src/v2/utils.ts b/packages/qualitymonitor/src/v2/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/qualitymonitor/src/v2/utils.ts +++ b/packages/qualitymonitor/src/v2/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/qualitymonitor/tsconfig.json b/packages/qualitymonitor/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/qualitymonitor/tsconfig.json +++ b/packages/qualitymonitor/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/qualitymonitors/package.json b/packages/qualitymonitors/package.json index 78708b91..5a1fb353 100644 --- a/packages/qualitymonitors/package.json +++ b/packages/qualitymonitors/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/qualitymonitors/src/v1/client.ts b/packages/qualitymonitors/src/v1/client.ts index 12c67773..8b17a1d5 100644 --- a/packages/qualitymonitors/src/v1/client.ts +++ b/packages/qualitymonitors/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CancelRefresh, CancelRefresh_Response, @@ -62,21 +57,13 @@ export class Client { * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Cancels an already-initiated refresh job. */ - async cancelRefresh( - signal: AbortSignal | undefined, - req: CancelRefresh, - options?: Options - ): Promise { + async cancelRefresh(signal: AbortSignal | undefined, req: CancelRefresh, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor/refreshes/${String(req.refreshId ?? '')}/cancel`; const body = marshalRequest(req, marshalCancelRefreshSchema); let resp: CancelRefresh_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCancelRefresh_ResponseSchema); }; await execute(signal, call, options); @@ -89,7 +76,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Creates a new monitor for the specified table. - * + * * The caller must either: * 1. be an owner of the table's parent catalog, have **USE_SCHEMA** on the table's parent schema, and have **SELECT** access on the table * 2. have **USE_CATALOG** on the table's parent catalog, be an owner of the table's parent schema, and have **SELECT** access on the table. @@ -97,25 +84,17 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - be an owner of the table. - * + * * Workspace assets, such as the dashboard, will be created in the workspace where * this call was made. */ - async createMonitor( - signal: AbortSignal | undefined, - req: CreateMonitor, - options?: Options - ): Promise { + async createMonitor(signal: AbortSignal | undefined, req: CreateMonitor, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor`; const body = marshalRequest(req, marshalCreateMonitorSchema); let resp: DataMonitorInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDataMonitorInfoSchema); }; await execute(signal, call, options); @@ -128,7 +107,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Deletes a monitor for the specified table. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema @@ -136,26 +115,18 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - be an owner of the table. - * + * * Additionally, the call must be made from the workspace where the monitor was created. - * + * * Note that the metric tables and dashboard will not be deleted as part of this call; those * assets must be manually cleaned up (if desired). */ - async deleteMonitor( - signal: AbortSignal | undefined, - req: DeleteMonitor, - options?: Options - ): Promise { + async deleteMonitor(signal: AbortSignal | undefined, req: DeleteMonitor, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor`; let resp: DeleteMonitor_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteMonitor_ResponseSchema); }; await execute(signal, call, options); @@ -168,7 +139,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Gets a monitor for the specified table. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema. @@ -176,25 +147,17 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - **SELECT** privilege on the table. - * + * * The returned information includes configuration values, as well as information on * assets created by the monitor. Some information (e.g., dashboard) may be filtered out * if the caller is in a different workspace than where the monitor was created. */ - async getMonitor( - signal: AbortSignal | undefined, - req: GetMonitor, - options?: Options - ): Promise { + async getMonitor(signal: AbortSignal | undefined, req: GetMonitor, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor`; let resp: DataMonitorInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDataMonitorInfoSchema); }; await execute(signal, call, options); @@ -207,7 +170,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Gets info about a specific monitor refresh using the given refresh ID. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema @@ -215,23 +178,15 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - **SELECT** privilege on the table. - * + * * Additionally, the call must be made from the workspace where the monitor was created. */ - async getRefresh( - signal: AbortSignal | undefined, - req: GetRefresh, - options?: Options - ): Promise { + async getRefresh(signal: AbortSignal | undefined, req: GetRefresh, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor/refreshes/${String(req.refreshId ?? '')}`; let resp: RefreshInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRefreshInfoSchema); }; await execute(signal, call, options); @@ -244,7 +199,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Gets an array containing the history of the most recent refreshes (up to 25) for this table. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema @@ -252,23 +207,15 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - **SELECT** privilege on the table. - * + * * Additionally, the call must be made from the workspace where the monitor was created. */ - async listRefreshes( - signal: AbortSignal | undefined, - req: ListRefreshes, - options?: Options - ): Promise { + async listRefreshes(signal: AbortSignal | undefined, req: ListRefreshes, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor/refreshes`; let resp: ListRefreshes_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListRefreshes_ResponseSchema); }; await execute(signal, call, options); @@ -281,7 +228,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Regenerates the monitoring dashboard for the specified table. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema @@ -289,29 +236,18 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - be an owner of the table - * + * * The call must be made from the workspace where the monitor was created. The dashboard will be regenerated in * the assets directory that was specified when the monitor was created. */ - async regenerateDashboard( - signal: AbortSignal | undefined, - req: RegenerateDashboard, - options?: Options - ): Promise { + async regenerateDashboard(signal: AbortSignal | undefined, req: RegenerateDashboard, options?: Options): Promise { const url = `${this.host}/api/2.1/quality-monitoring/tables/${req.fullTableNameArg ?? ''}/monitor/dashboard`; const body = marshalRequest(req, marshalRegenerateDashboardSchema); let resp: RegenerateDashboard_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalRegenerateDashboard_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalRegenerateDashboard_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -324,7 +260,7 @@ export class Client { * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Queues a metric refresh on the monitor for the specified table. * The refresh will execute in the background. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema @@ -332,24 +268,16 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - be an owner of the table - * + * * Additionally, the call must be made from the workspace where the monitor was created. */ - async runRefresh( - signal: AbortSignal | undefined, - req: RunRefresh, - options?: Options - ): Promise { + async runRefresh(signal: AbortSignal | undefined, req: RunRefresh, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor/refreshes`; const body = marshalRequest(req, marshalRunRefreshSchema); let resp: RefreshInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRefreshInfoSchema); }; await execute(signal, call, options); @@ -362,7 +290,7 @@ export class Client { /** * Deprecated: Use Data Quality Monitors API instead (/api/data-quality/v1/monitors). * Updates a monitor for the specified table. - * + * * The caller must either: * 1. be an owner of the table's parent catalog * 2. have **USE_CATALOG** on the table's parent catalog and be an owner of the table's parent schema @@ -370,27 +298,19 @@ export class Client { * - **USE_CATALOG** on the table's parent catalog * - **USE_SCHEMA** on the table's parent schema * - be an owner of the table. - * + * * Additionally, the call must be made from the workspace where the monitor was created, and the caller must be * the original creator of the monitor. - * + * * Certain configuration fields, such as output asset identifiers, cannot be updated. */ - async updateMonitor( - signal: AbortSignal | undefined, - req: UpdateMonitor, - options?: Options - ): Promise { + async updateMonitor(signal: AbortSignal | undefined, req: UpdateMonitor, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullTableNameArg ?? ''}/monitor`; const body = marshalRequest(req, marshalUpdateMonitorSchema); let resp: DataMonitorInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDataMonitorInfoSchema); }; await execute(signal, call, options); diff --git a/packages/qualitymonitors/src/v1/index.ts b/packages/qualitymonitors/src/v1/index.ts index e6b8f668..991e2ee2 100644 --- a/packages/qualitymonitors/src/v1/index.ts +++ b/packages/qualitymonitors/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/qualitymonitors/src/v1/model.ts b/packages/qualitymonitors/src/v1/model.ts index 9b8fdd8f..b246e3ca 100644 --- a/packages/qualitymonitors/src/v1/model.ts +++ b/packages/qualitymonitors/src/v1/model.ts @@ -472,8 +472,9 @@ export const unmarshalCancelRefreshSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCancelRefresh_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalCancelRefresh_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalCreateMonitorSchema: z.ZodType = z .object({ @@ -482,23 +483,15 @@ export const unmarshalCreateMonitorSchema: z.ZodType = z warehouse_id: z.string().optional(), output_schema_name: z.string().optional(), assets_dir: z.string().optional(), - inference_log: z - .lazy(() => unmarshalInferenceLogAnalysisConfigSchema) - .optional(), - time_series: z - .lazy(() => unmarshalTimeSeriesAnalysisConfigSchema) - .optional(), + inference_log: z.lazy(() => unmarshalInferenceLogAnalysisConfigSchema).optional(), + time_series: z.lazy(() => unmarshalTimeSeriesAnalysisConfigSchema).optional(), snapshot: z.lazy(() => unmarshalSnapshotAnalysisConfigSchema).optional(), slicing_exprs: z.array(z.string()).optional(), - custom_metrics: z - .array(z.lazy(() => unmarshalCustomMetricSchema)) - .optional(), + custom_metrics: z.array(z.lazy(() => unmarshalCustomMetricSchema)).optional(), baseline_table_name: z.string().optional(), schedule: z.lazy(() => unmarshalMonitorCronScheduleSchema).optional(), notifications: z.lazy(() => unmarshalNotificationsSchema).optional(), - data_classification_config: z - .lazy(() => unmarshalDataClassificationConfigSchema) - .optional(), + data_classification_config: z.lazy(() => unmarshalDataClassificationConfigSchema).optional(), table_name: z.string().optional(), status: z.enum(MonitorStatus).optional(), latest_monitor_failure_msg: z.string().optional(), @@ -547,36 +540,27 @@ export const unmarshalCustomMetricSchema: z.ZodType = z type: d.type, })); -export const unmarshalDataClassificationConfigSchema: z.ZodType = - z - .object({ - enabled: z.boolean().optional(), - }) - .transform(d => ({ - enabled: d.enabled, - })); +export const unmarshalDataClassificationConfigSchema: z.ZodType = z + .object({ + enabled: z.boolean().optional(), + }) + .transform(d => ({ + enabled: d.enabled, + })); export const unmarshalDataMonitorInfoSchema: z.ZodType = z .object({ output_schema_name: z.string().optional(), assets_dir: z.string().optional(), - inference_log: z - .lazy(() => unmarshalInferenceLogAnalysisConfigSchema) - .optional(), - time_series: z - .lazy(() => unmarshalTimeSeriesAnalysisConfigSchema) - .optional(), + inference_log: z.lazy(() => unmarshalInferenceLogAnalysisConfigSchema).optional(), + time_series: z.lazy(() => unmarshalTimeSeriesAnalysisConfigSchema).optional(), snapshot: z.lazy(() => unmarshalSnapshotAnalysisConfigSchema).optional(), slicing_exprs: z.array(z.string()).optional(), - custom_metrics: z - .array(z.lazy(() => unmarshalCustomMetricSchema)) - .optional(), + custom_metrics: z.array(z.lazy(() => unmarshalCustomMetricSchema)).optional(), baseline_table_name: z.string().optional(), schedule: z.lazy(() => unmarshalMonitorCronScheduleSchema).optional(), notifications: z.lazy(() => unmarshalNotificationsSchema).optional(), - data_classification_config: z - .lazy(() => unmarshalDataClassificationConfigSchema) - .optional(), + data_classification_config: z.lazy(() => unmarshalDataClassificationConfigSchema).optional(), table_name: z.string().optional(), status: z.enum(MonitorStatus).optional(), latest_monitor_failure_msg: z.string().optional(), @@ -615,8 +599,9 @@ export const unmarshalDeleteMonitorSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteMonitor_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteMonitor_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalDestinationSchema: z.ZodType = z .object({ @@ -644,26 +629,25 @@ export const unmarshalGetRefreshSchema: z.ZodType = z refreshId: d.refresh_id, })); -export const unmarshalInferenceLogAnalysisConfigSchema: z.ZodType = - z - .object({ - problem_type: z.enum(ProblemType).optional(), - timestamp_col: z.string().optional(), - granularities: z.array(z.string()).optional(), - prediction_col: z.string().optional(), - label_col: z.string().optional(), - model_id_col: z.string().optional(), - prediction_proba_col: z.string().optional(), - }) - .transform(d => ({ - problemType: d.problem_type, - timestampCol: d.timestamp_col, - granularities: d.granularities, - predictionCol: d.prediction_col, - labelCol: d.label_col, - modelIdCol: d.model_id_col, - predictionProbaCol: d.prediction_proba_col, - })); +export const unmarshalInferenceLogAnalysisConfigSchema: z.ZodType = z + .object({ + problem_type: z.enum(ProblemType).optional(), + timestamp_col: z.string().optional(), + granularities: z.array(z.string()).optional(), + prediction_col: z.string().optional(), + label_col: z.string().optional(), + model_id_col: z.string().optional(), + prediction_proba_col: z.string().optional(), + }) + .transform(d => ({ + problemType: d.problem_type, + timestampCol: d.timestamp_col, + granularities: d.granularities, + predictionCol: d.prediction_col, + labelCol: d.label_col, + modelIdCol: d.model_id_col, + predictionProbaCol: d.prediction_proba_col, + })); export const unmarshalListRefreshesSchema: z.ZodType = z .object({ @@ -674,34 +658,30 @@ export const unmarshalListRefreshesSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListRefreshes_ResponseSchema: z.ZodType = - z - .object({ - refreshes: z.array(z.lazy(() => unmarshalRefreshInfoSchema)).optional(), - }) - .transform(d => ({ - refreshes: d.refreshes, - })); - -export const unmarshalMonitorCronScheduleSchema: z.ZodType = - z - .object({ - quartz_cron_expression: z.string().optional(), - timezone_id: z.string().optional(), - pause_status: z.enum(SchedulePauseStatus).optional(), - }) - .transform(d => ({ - quartzCronExpression: d.quartz_cron_expression, - timezoneId: d.timezone_id, - pauseStatus: d.pause_status, - })); +export const unmarshalListRefreshes_ResponseSchema: z.ZodType = z + .object({ + refreshes: z.array(z.lazy(() => unmarshalRefreshInfoSchema)).optional(), + }) + .transform(d => ({ + refreshes: d.refreshes, + })); + +export const unmarshalMonitorCronScheduleSchema: z.ZodType = z + .object({ + quartz_cron_expression: z.string().optional(), + timezone_id: z.string().optional(), + pause_status: z.enum(SchedulePauseStatus).optional(), + }) + .transform(d => ({ + quartzCronExpression: d.quartz_cron_expression, + timezoneId: d.timezone_id, + pauseStatus: d.pause_status, + })); export const unmarshalNotificationsSchema: z.ZodType = z .object({ on_failure: z.lazy(() => unmarshalDestinationSchema).optional(), - on_new_classification_tag_detected: z - .lazy(() => unmarshalDestinationSchema) - .optional(), + on_new_classification_tag_detected: z.lazy(() => unmarshalDestinationSchema).optional(), }) .transform(d => ({ onFailure: d.on_failure, @@ -726,28 +706,26 @@ export const unmarshalRefreshInfoSchema: z.ZodType = z trigger: d.trigger, })); -export const unmarshalRegenerateDashboardSchema: z.ZodType = - z - .object({ - full_table_name_arg: z.string().optional(), - warehouse_id: z.string().optional(), - }) - .transform(d => ({ - fullTableNameArg: d.full_table_name_arg, - warehouseId: d.warehouse_id, - })); +export const unmarshalRegenerateDashboardSchema: z.ZodType = z + .object({ + full_table_name_arg: z.string().optional(), + warehouse_id: z.string().optional(), + }) + .transform(d => ({ + fullTableNameArg: d.full_table_name_arg, + warehouseId: d.warehouse_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalRegenerateDashboard_ResponseSchema: z.ZodType = - z - .object({ - dashboard_id: z.string().optional(), - parent_folder: z.string().optional(), - }) - .transform(d => ({ - dashboardId: d.dashboard_id, - parentFolder: d.parent_folder, - })); +export const unmarshalRegenerateDashboard_ResponseSchema: z.ZodType = z + .object({ + dashboard_id: z.string().optional(), + parent_folder: z.string().optional(), + }) + .transform(d => ({ + dashboardId: d.dashboard_id, + parentFolder: d.parent_folder, + })); export const unmarshalRunRefreshSchema: z.ZodType = z .object({ @@ -757,42 +735,34 @@ export const unmarshalRunRefreshSchema: z.ZodType = z fullTableNameArg: d.full_table_name_arg, })); -export const unmarshalSnapshotAnalysisConfigSchema: z.ZodType = - z.object({}); +export const unmarshalSnapshotAnalysisConfigSchema: z.ZodType = z + .object({ + }); -export const unmarshalTimeSeriesAnalysisConfigSchema: z.ZodType = - z - .object({ - timestamp_col: z.string().optional(), - granularities: z.array(z.string()).optional(), - }) - .transform(d => ({ - timestampCol: d.timestamp_col, - granularities: d.granularities, - })); +export const unmarshalTimeSeriesAnalysisConfigSchema: z.ZodType = z + .object({ + timestamp_col: z.string().optional(), + granularities: z.array(z.string()).optional(), + }) + .transform(d => ({ + timestampCol: d.timestamp_col, + granularities: d.granularities, + })); export const unmarshalUpdateMonitorSchema: z.ZodType = z .object({ full_table_name_arg: z.string().optional(), output_schema_name: z.string().optional(), assets_dir: z.string().optional(), - inference_log: z - .lazy(() => unmarshalInferenceLogAnalysisConfigSchema) - .optional(), - time_series: z - .lazy(() => unmarshalTimeSeriesAnalysisConfigSchema) - .optional(), + inference_log: z.lazy(() => unmarshalInferenceLogAnalysisConfigSchema).optional(), + time_series: z.lazy(() => unmarshalTimeSeriesAnalysisConfigSchema).optional(), snapshot: z.lazy(() => unmarshalSnapshotAnalysisConfigSchema).optional(), slicing_exprs: z.array(z.string()).optional(), - custom_metrics: z - .array(z.lazy(() => unmarshalCustomMetricSchema)) - .optional(), + custom_metrics: z.array(z.lazy(() => unmarshalCustomMetricSchema)).optional(), baseline_table_name: z.string().optional(), schedule: z.lazy(() => unmarshalMonitorCronScheduleSchema).optional(), notifications: z.lazy(() => unmarshalNotificationsSchema).optional(), - data_classification_config: z - .lazy(() => unmarshalDataClassificationConfigSchema) - .optional(), + data_classification_config: z.lazy(() => unmarshalDataClassificationConfigSchema).optional(), table_name: z.string().optional(), status: z.enum(MonitorStatus).optional(), latest_monitor_failure_msg: z.string().optional(), @@ -834,7 +804,9 @@ export const marshalCancelRefreshSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalCancelRefresh_ResponseSchema: z.ZodType = z.object({}); +export const marshalCancelRefresh_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalCreateMonitorSchema: z.ZodType = z .object({ @@ -843,9 +815,7 @@ export const marshalCreateMonitorSchema: z.ZodType = z warehouseId: z.string().optional(), outputSchemaName: z.string().optional(), assetsDir: z.string().optional(), - inferenceLog: z - .lazy(() => marshalInferenceLogAnalysisConfigSchema) - .optional(), + inferenceLog: z.lazy(() => marshalInferenceLogAnalysisConfigSchema).optional(), timeSeries: z.lazy(() => marshalTimeSeriesAnalysisConfigSchema).optional(), snapshot: z.lazy(() => marshalSnapshotAnalysisConfigSchema).optional(), slicingExprs: z.array(z.string()).optional(), @@ -853,9 +823,7 @@ export const marshalCreateMonitorSchema: z.ZodType = z baselineTableName: z.string().optional(), schedule: z.lazy(() => marshalMonitorCronScheduleSchema).optional(), notifications: z.lazy(() => marshalNotificationsSchema).optional(), - dataClassificationConfig: z - .lazy(() => marshalDataClassificationConfigSchema) - .optional(), + dataClassificationConfig: z.lazy(() => marshalDataClassificationConfigSchema).optional(), tableName: z.string().optional(), status: z.enum(MonitorStatus).optional(), latestMonitorFailureMsg: z.string().optional(), @@ -916,9 +884,7 @@ export const marshalDataMonitorInfoSchema: z.ZodType = z .object({ outputSchemaName: z.string().optional(), assetsDir: z.string().optional(), - inferenceLog: z - .lazy(() => marshalInferenceLogAnalysisConfigSchema) - .optional(), + inferenceLog: z.lazy(() => marshalInferenceLogAnalysisConfigSchema).optional(), timeSeries: z.lazy(() => marshalTimeSeriesAnalysisConfigSchema).optional(), snapshot: z.lazy(() => marshalSnapshotAnalysisConfigSchema).optional(), slicingExprs: z.array(z.string()).optional(), @@ -926,9 +892,7 @@ export const marshalDataMonitorInfoSchema: z.ZodType = z baselineTableName: z.string().optional(), schedule: z.lazy(() => marshalMonitorCronScheduleSchema).optional(), notifications: z.lazy(() => marshalNotificationsSchema).optional(), - dataClassificationConfig: z - .lazy(() => marshalDataClassificationConfigSchema) - .optional(), + dataClassificationConfig: z.lazy(() => marshalDataClassificationConfigSchema).optional(), tableName: z.string().optional(), status: z.enum(MonitorStatus).optional(), latestMonitorFailureMsg: z.string().optional(), @@ -967,7 +931,9 @@ export const marshalDeleteMonitorSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteMonitor_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteMonitor_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDestinationSchema: z.ZodType = z .object({ @@ -1047,9 +1013,7 @@ export const marshalMonitorCronScheduleSchema: z.ZodType = z export const marshalNotificationsSchema: z.ZodType = z .object({ onFailure: z.lazy(() => marshalDestinationSchema).optional(), - onNewClassificationTagDetected: z - .lazy(() => marshalDestinationSchema) - .optional(), + onNewClassificationTagDetected: z.lazy(() => marshalDestinationSchema).optional(), }) .transform(d => ({ on_failure: d.onFailure, @@ -1103,7 +1067,9 @@ export const marshalRunRefreshSchema: z.ZodType = z full_table_name_arg: d.fullTableNameArg, })); -export const marshalSnapshotAnalysisConfigSchema: z.ZodType = z.object({}); +export const marshalSnapshotAnalysisConfigSchema: z.ZodType = z + .object({ + }); export const marshalTimeSeriesAnalysisConfigSchema: z.ZodType = z .object({ @@ -1120,9 +1086,7 @@ export const marshalUpdateMonitorSchema: z.ZodType = z fullTableNameArg: z.string().optional(), outputSchemaName: z.string().optional(), assetsDir: z.string().optional(), - inferenceLog: z - .lazy(() => marshalInferenceLogAnalysisConfigSchema) - .optional(), + inferenceLog: z.lazy(() => marshalInferenceLogAnalysisConfigSchema).optional(), timeSeries: z.lazy(() => marshalTimeSeriesAnalysisConfigSchema).optional(), snapshot: z.lazy(() => marshalSnapshotAnalysisConfigSchema).optional(), slicingExprs: z.array(z.string()).optional(), @@ -1130,9 +1094,7 @@ export const marshalUpdateMonitorSchema: z.ZodType = z baselineTableName: z.string().optional(), schedule: z.lazy(() => marshalMonitorCronScheduleSchema).optional(), notifications: z.lazy(() => marshalNotificationsSchema).optional(), - dataClassificationConfig: z - .lazy(() => marshalDataClassificationConfigSchema) - .optional(), + dataClassificationConfig: z.lazy(() => marshalDataClassificationConfigSchema).optional(), tableName: z.string().optional(), status: z.enum(MonitorStatus).optional(), latestMonitorFailureMsg: z.string().optional(), diff --git a/packages/qualitymonitors/src/v1/utils.ts b/packages/qualitymonitors/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/qualitymonitors/src/v1/utils.ts +++ b/packages/qualitymonitors/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/qualitymonitors/tsconfig.json b/packages/qualitymonitors/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/qualitymonitors/tsconfig.json +++ b/packages/qualitymonitors/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/queries/package.json b/packages/queries/package.json index bcae9dc5..7ab2b948 100644 --- a/packages/queries/package.json +++ b/packages/queries/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/queries/src/v1/client.ts b/packages/queries/src/v1/client.ts index a053eefb..4b6cd9bc 100644 --- a/packages/queries/src/v1/client.ts +++ b/packages/queries/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateQueryRequest, Empty, @@ -51,21 +46,13 @@ export class Client { } /** Creates a query. */ - async createQuery( - signal: AbortSignal | undefined, - req: CreateQueryRequest, - options?: Options - ): Promise { + async createQuery(signal: AbortSignal | undefined, req: CreateQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/queries`; const body = marshalRequest(req, marshalCreateQueryRequestSchema); let resp: Query | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalQuerySchema); }; await execute(signal, call, options); @@ -76,20 +63,12 @@ export class Client { } /** Gets a query. */ - async getQuery( - signal: AbortSignal | undefined, - req: GetQueryRequest, - options?: Options - ): Promise { + async getQuery(signal: AbortSignal | undefined, req: GetQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}`; let resp: Query | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalQuerySchema); }; await execute(signal, call, options); @@ -100,11 +79,7 @@ export class Client { } /** Gets a list of queries accessible to the user, ordered by creation time. **Warning:** Calling this API concurrently 10 or more times could result in throttling, service degradation, or a temporary ban. */ - async listQueries( - signal: AbortSignal | undefined, - req: ListQueriesRequest, - options?: Options - ): Promise { + async listQueries(signal: AbortSignal | undefined, req: ListQueriesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/queries`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -118,11 +93,7 @@ export class Client { let resp: ListQueriesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListQueriesResponseSchema); }; await execute(signal, call, options); @@ -132,11 +103,8 @@ export class Client { return resp; } - async *listQueriesIter( - signal: AbortSignal | undefined, - req: ListQueriesRequest, - options?: Options - ): AsyncGenerator { + + async *listQueriesIter(signal: AbortSignal | undefined, req: ListQueriesRequest, options?: Options): AsyncGenerator { const pageReq: ListQueriesRequest = {...req}; for (;;) { const resp = await this.listQueries(signal, pageReq, options); @@ -150,12 +118,9 @@ export class Client { } } + /** Gets a list of visualizations on a query. */ - async listVisualizationsForQuery( - signal: AbortSignal | undefined, - req: ListVisualizationsForQueryRequest, - options?: Options - ): Promise { + async listVisualizationsForQuery(signal: AbortSignal | undefined, req: ListVisualizationsForQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}/visualizations`; const params = new URLSearchParams(); if (req.pageToken !== undefined) { @@ -169,15 +134,8 @@ export class Client { let resp: ListVisualizationsForQueryResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListVisualizationsForQueryResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListVisualizationsForQueryResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -186,18 +144,11 @@ export class Client { return resp; } - async *listVisualizationsForQueryIter( - signal: AbortSignal | undefined, - req: ListVisualizationsForQueryRequest, - options?: Options - ): AsyncGenerator { + + async *listVisualizationsForQueryIter(signal: AbortSignal | undefined, req: ListVisualizationsForQueryRequest, options?: Options): AsyncGenerator { const pageReq: ListVisualizationsForQueryRequest = {...req}; for (;;) { - const resp = await this.listVisualizationsForQuery( - signal, - pageReq, - options - ); + const resp = await this.listVisualizationsForQuery(signal, pageReq, options); for (const item of resp.results ?? []) { yield item; } @@ -208,21 +159,14 @@ export class Client { } } + /** Moves a query to the trash. Trashed queries immediately disappear from searches and list views, and cannot be used for alerts. You can restore a trashed query through the UI. A trashed query is permanently deleted after 30 days. */ - async trashQuery( - signal: AbortSignal | undefined, - req: TrashQueryRequest, - options?: Options - ): Promise { + async trashQuery(signal: AbortSignal | undefined, req: TrashQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}`; let resp: Empty | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalEmptySchema); }; await execute(signal, call, options); @@ -233,21 +177,13 @@ export class Client { } /** Updates a query. */ - async updateQuery( - signal: AbortSignal | undefined, - req: UpdateQueryRequest, - options?: Options - ): Promise { + async updateQuery(signal: AbortSignal | undefined, req: UpdateQueryRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}`; const body = marshalRequest(req, marshalUpdateQueryRequestSchema); let resp: Query | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalQuerySchema); }; await execute(signal, call, options); diff --git a/packages/queries/src/v1/index.ts b/packages/queries/src/v1/index.ts index 9057dcd7..d2613d56 100644 --- a/packages/queries/src/v1/index.ts +++ b/packages/queries/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/queries/src/v1/model.ts b/packages/queries/src/v1/model.ts index ea0fadc5..df1dcc45 100644 --- a/packages/queries/src/v1/model.ts +++ b/packages/queries/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export enum DatePrecision { @@ -276,7 +278,7 @@ export interface TrashQueryRequest { export interface UpdateQueryRequest { query?: UpdateQueryRequestQuery | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; id?: string | undefined; /** 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?: boolean | undefined; @@ -337,65 +339,55 @@ export interface Visualization { queryId?: string | undefined; } -export const unmarshalCreateQueryRequestSchema: z.ZodType = - z - .object({ - query: z.lazy(() => unmarshalCreateQueryRequestQuerySchema).optional(), - auto_resolve_display_name: z.boolean().optional(), - }) - .transform(d => ({ - query: d.query, - autoResolveDisplayName: d.auto_resolve_display_name, - })); - -export const unmarshalCreateQueryRequestQuerySchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - description: z.string().optional(), - owner_user_name: z.string().optional(), - warehouse_id: z.string().optional(), - query_text: z.string().optional(), - run_as_mode: z.enum(RunAsMode).optional(), - lifecycle_state: z.enum(LifecycleState).optional(), - last_modifier_user_name: z.string().optional(), - parent_path: z.string().optional(), - tags: z.array(z.string()).optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - parameters: z - .array(z.lazy(() => unmarshalQueryParameterSchema)) - .optional(), - apply_auto_limit: z.boolean().optional(), - catalog: z.string().optional(), - schema: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - description: d.description, - ownerUserName: d.owner_user_name, - warehouseId: d.warehouse_id, - queryText: d.query_text, - runAsMode: d.run_as_mode, - lifecycleState: d.lifecycle_state, - lastModifierUserName: d.last_modifier_user_name, - parentPath: d.parent_path, - tags: d.tags, - createTime: d.create_time, - updateTime: d.update_time, - parameters: d.parameters, - applyAutoLimit: d.apply_auto_limit, - catalog: d.catalog, - schema: d.schema, - })); +export const unmarshalCreateQueryRequestSchema: z.ZodType = z + .object({ + query: z.lazy(() => unmarshalCreateQueryRequestQuerySchema).optional(), + auto_resolve_display_name: z.boolean().optional(), + }) + .transform(d => ({ + query: d.query, + autoResolveDisplayName: d.auto_resolve_display_name, + })); + +export const unmarshalCreateQueryRequestQuerySchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + description: z.string().optional(), + owner_user_name: z.string().optional(), + warehouse_id: z.string().optional(), + query_text: z.string().optional(), + run_as_mode: z.enum(RunAsMode).optional(), + lifecycle_state: z.enum(LifecycleState).optional(), + last_modifier_user_name: z.string().optional(), + parent_path: z.string().optional(), + tags: z.array(z.string()).optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + parameters: z.array(z.lazy(() => unmarshalQueryParameterSchema)).optional(), + apply_auto_limit: z.boolean().optional(), + catalog: z.string().optional(), + schema: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + description: d.description, + ownerUserName: d.owner_user_name, + warehouseId: d.warehouse_id, + queryText: d.query_text, + runAsMode: d.run_as_mode, + lifecycleState: d.lifecycle_state, + lastModifierUserName: d.last_modifier_user_name, + parentPath: d.parent_path, + tags: d.tags, + createTime: d.create_time, + updateTime: d.update_time, + parameters: d.parameters, + applyAutoLimit: d.apply_auto_limit, + catalog: d.catalog, + schema: d.schema, + })); export const unmarshalDateRangeSchema: z.ZodType = z .object({ @@ -409,9 +401,7 @@ export const unmarshalDateRangeSchema: z.ZodType = z export const unmarshalDateRangeValueSchema: z.ZodType = z .object({ - dynamic_date_range_value: z - .enum(DateRangeValue_DynamicDateRange) - .optional(), + dynamic_date_range_value: z.enum(DateRangeValue_DynamicDateRange).optional(), date_range_value: z.lazy(() => unmarshalDateRangeSchema).optional(), precision: z.enum(DatePrecision).optional(), start_day_of_week: z.number().optional(), @@ -435,15 +425,15 @@ export const unmarshalDateValueSchema: z.ZodType = z precision: d.precision, })); -export const unmarshalEmptySchema: z.ZodType = z.object({}); +export const unmarshalEmptySchema: z.ZodType = z + .object({ + }); export const unmarshalEnumValueSchema: z.ZodType = z .object({ values: z.array(z.string()).optional(), enum_options: z.string().optional(), - multi_values_options: z - .lazy(() => unmarshalMultiValuesOptionsSchema) - .optional(), + multi_values_options: z.lazy(() => unmarshalMultiValuesOptionsSchema).optional(), }) .transform(d => ({ values: d.values, @@ -459,115 +449,99 @@ export const unmarshalGetQueryRequestSchema: z.ZodType = z id: d.id, })); -export const unmarshalListQueriesRequestSchema: z.ZodType = - z - .object({ - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListQueriesResponseSchema: z.ZodType = - z - .object({ - results: z - .array(z.lazy(() => unmarshalListQueryObjectsResponseQuerySchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - results: d.results, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListQueryObjectsResponseQuerySchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - description: z.string().optional(), - owner_user_name: z.string().optional(), - warehouse_id: z.string().optional(), - query_text: z.string().optional(), - run_as_mode: z.enum(RunAsMode).optional(), - lifecycle_state: z.enum(LifecycleState).optional(), - last_modifier_user_name: z.string().optional(), - parent_path: z.string().optional(), - tags: z.array(z.string()).optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - parameters: z - .array(z.lazy(() => unmarshalQueryParameterSchema)) - .optional(), - apply_auto_limit: z.boolean().optional(), - catalog: z.string().optional(), - schema: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - description: d.description, - ownerUserName: d.owner_user_name, - warehouseId: d.warehouse_id, - queryText: d.query_text, - runAsMode: d.run_as_mode, - lifecycleState: d.lifecycle_state, - lastModifierUserName: d.last_modifier_user_name, - parentPath: d.parent_path, - tags: d.tags, - createTime: d.create_time, - updateTime: d.update_time, - parameters: d.parameters, - applyAutoLimit: d.apply_auto_limit, - catalog: d.catalog, - schema: d.schema, - })); - -export const unmarshalListVisualizationsForQueryRequestSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - id: d.id, - pageToken: d.page_token, - pageSize: d.page_size, - })); - -export const unmarshalListVisualizationsForQueryResponseSchema: z.ZodType = - z - .object({ - results: z.array(z.lazy(() => unmarshalVisualizationSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - results: d.results, - nextPageToken: d.next_page_token, - })); - -export const unmarshalMultiValuesOptionsSchema: z.ZodType = - z - .object({ - prefix: z.string().optional(), - separator: z.string().optional(), - suffix: z.string().optional(), - }) - .transform(d => ({ - prefix: d.prefix, - separator: d.separator, - suffix: d.suffix, - })); +export const unmarshalListQueriesRequestSchema: z.ZodType = z + .object({ + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListQueriesResponseSchema: z.ZodType = z + .object({ + results: z.array(z.lazy(() => unmarshalListQueryObjectsResponseQuerySchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + results: d.results, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListQueryObjectsResponseQuerySchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + description: z.string().optional(), + owner_user_name: z.string().optional(), + warehouse_id: z.string().optional(), + query_text: z.string().optional(), + run_as_mode: z.enum(RunAsMode).optional(), + lifecycle_state: z.enum(LifecycleState).optional(), + last_modifier_user_name: z.string().optional(), + parent_path: z.string().optional(), + tags: z.array(z.string()).optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + parameters: z.array(z.lazy(() => unmarshalQueryParameterSchema)).optional(), + apply_auto_limit: z.boolean().optional(), + catalog: z.string().optional(), + schema: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + description: d.description, + ownerUserName: d.owner_user_name, + warehouseId: d.warehouse_id, + queryText: d.query_text, + runAsMode: d.run_as_mode, + lifecycleState: d.lifecycle_state, + lastModifierUserName: d.last_modifier_user_name, + parentPath: d.parent_path, + tags: d.tags, + createTime: d.create_time, + updateTime: d.update_time, + parameters: d.parameters, + applyAutoLimit: d.apply_auto_limit, + catalog: d.catalog, + schema: d.schema, + })); + +export const unmarshalListVisualizationsForQueryRequestSchema: z.ZodType = z + .object({ + id: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + id: d.id, + pageToken: d.page_token, + pageSize: d.page_size, + })); + +export const unmarshalListVisualizationsForQueryResponseSchema: z.ZodType = z + .object({ + results: z.array(z.lazy(() => unmarshalVisualizationSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + results: d.results, + nextPageToken: d.next_page_token, + })); + +export const unmarshalMultiValuesOptionsSchema: z.ZodType = z + .object({ + prefix: z.string().optional(), + separator: z.string().optional(), + suffix: z.string().optional(), + }) + .transform(d => ({ + prefix: d.prefix, + separator: d.separator, + suffix: d.suffix, + })); export const unmarshalNumericValueSchema: z.ZodType = z .object({ @@ -590,14 +564,8 @@ export const unmarshalQuerySchema: z.ZodType = z last_modifier_user_name: z.string().optional(), parent_path: z.string().optional(), tags: z.array(z.string()).optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), parameters: z.array(z.lazy(() => unmarshalQueryParameterSchema)).optional(), apply_auto_limit: z.boolean().optional(), catalog: z.string().optional(), @@ -627,9 +595,7 @@ export const unmarshalQueryBackedValueSchema: z.ZodType = z .object({ values: z.array(z.string()).optional(), query_id: z.string().optional(), - multi_values_options: z - .lazy(() => unmarshalMultiValuesOptionsSchema) - .optional(), + multi_values_options: z.lazy(() => unmarshalMultiValuesOptionsSchema).optional(), }) .transform(d => ({ values: d.values, @@ -646,9 +612,7 @@ export const unmarshalQueryParameterSchema: z.ZodType = z enum_value: z.lazy(() => unmarshalEnumValueSchema).optional(), date_value: z.lazy(() => unmarshalDateValueSchema).optional(), date_range_value: z.lazy(() => unmarshalDateRangeValueSchema).optional(), - query_backed_value: z - .lazy(() => unmarshalQueryBackedValueSchema) - .optional(), + query_backed_value: z.lazy(() => unmarshalQueryBackedValueSchema).optional(), }) .transform(d => ({ title: d.title, @@ -677,83 +641,67 @@ export const unmarshalTrashQueryRequestSchema: z.ZodType = z id: d.id, })); -export const unmarshalUpdateQueryRequestSchema: z.ZodType = - z - .object({ - query: z.lazy(() => unmarshalUpdateQueryRequestQuerySchema).optional(), - update_mask: z.string().optional(), - id: z.string().optional(), - auto_resolve_display_name: z.boolean().optional(), - }) - .transform(d => ({ - query: d.query, - updateMask: d.update_mask, - id: d.id, - autoResolveDisplayName: d.auto_resolve_display_name, - })); - -export const unmarshalUpdateQueryRequestQuerySchema: z.ZodType = - z - .object({ - id: z.string().optional(), - display_name: z.string().optional(), - description: z.string().optional(), - owner_user_name: z.string().optional(), - warehouse_id: z.string().optional(), - query_text: z.string().optional(), - run_as_mode: z.enum(RunAsMode).optional(), - lifecycle_state: z.enum(LifecycleState).optional(), - last_modifier_user_name: z.string().optional(), - parent_path: z.string().optional(), - tags: z.array(z.string()).optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - parameters: z - .array(z.lazy(() => unmarshalQueryParameterSchema)) - .optional(), - apply_auto_limit: z.boolean().optional(), - catalog: z.string().optional(), - schema: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - displayName: d.display_name, - description: d.description, - ownerUserName: d.owner_user_name, - warehouseId: d.warehouse_id, - queryText: d.query_text, - runAsMode: d.run_as_mode, - lifecycleState: d.lifecycle_state, - lastModifierUserName: d.last_modifier_user_name, - parentPath: d.parent_path, - tags: d.tags, - createTime: d.create_time, - updateTime: d.update_time, - parameters: d.parameters, - applyAutoLimit: d.apply_auto_limit, - catalog: d.catalog, - schema: d.schema, - })); +export const unmarshalUpdateQueryRequestSchema: z.ZodType = z + .object({ + query: z.lazy(() => unmarshalUpdateQueryRequestQuerySchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + id: z.string().optional(), + auto_resolve_display_name: z.boolean().optional(), + }) + .transform(d => ({ + query: d.query, + updateMask: d.update_mask, + id: d.id, + autoResolveDisplayName: d.auto_resolve_display_name, + })); + +export const unmarshalUpdateQueryRequestQuerySchema: z.ZodType = z + .object({ + id: z.string().optional(), + display_name: z.string().optional(), + description: z.string().optional(), + owner_user_name: z.string().optional(), + warehouse_id: z.string().optional(), + query_text: z.string().optional(), + run_as_mode: z.enum(RunAsMode).optional(), + lifecycle_state: z.enum(LifecycleState).optional(), + last_modifier_user_name: z.string().optional(), + parent_path: z.string().optional(), + tags: z.array(z.string()).optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + parameters: z.array(z.lazy(() => unmarshalQueryParameterSchema)).optional(), + apply_auto_limit: z.boolean().optional(), + catalog: z.string().optional(), + schema: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + displayName: d.display_name, + description: d.description, + ownerUserName: d.owner_user_name, + warehouseId: d.warehouse_id, + queryText: d.query_text, + runAsMode: d.run_as_mode, + lifecycleState: d.lifecycle_state, + lastModifierUserName: d.last_modifier_user_name, + parentPath: d.parent_path, + tags: d.tags, + createTime: d.create_time, + updateTime: d.update_time, + parameters: d.parameters, + applyAutoLimit: d.apply_auto_limit, + catalog: d.catalog, + schema: d.schema, + })); export const unmarshalVisualizationSchema: z.ZodType = z .object({ id: z.string().optional(), display_name: z.string().optional(), type: z.string().optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), serialized_query_plan: z.string().optional(), serialized_options: z.string().optional(), query_id: z.string().optional(), @@ -792,14 +740,8 @@ export const marshalCreateQueryRequestQuerySchema: z.ZodType = z lastModifierUserName: z.string().optional(), parentPath: z.string().optional(), tags: z.array(z.string()).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), parameters: z.array(z.lazy(() => marshalQueryParameterSchema)).optional(), applyAutoLimit: z.boolean().optional(), catalog: z.string().optional(), @@ -861,15 +803,15 @@ export const marshalDateValueSchema: z.ZodType = z precision: d.precision, })); -export const marshalEmptySchema: z.ZodType = z.object({}); +export const marshalEmptySchema: z.ZodType = z + .object({ + }); export const marshalEnumValueSchema: z.ZodType = z .object({ values: z.array(z.string()).optional(), enumOptions: z.string().optional(), - multiValuesOptions: z - .lazy(() => marshalMultiValuesOptionsSchema) - .optional(), + multiValuesOptions: z.lazy(() => marshalMultiValuesOptionsSchema).optional(), }) .transform(d => ({ values: d.values, @@ -897,9 +839,7 @@ export const marshalListQueriesRequestSchema: z.ZodType = z export const marshalListQueriesResponseSchema: z.ZodType = z .object({ - results: z - .array(z.lazy(() => marshalListQueryObjectsResponseQuerySchema)) - .optional(), + results: z.array(z.lazy(() => marshalListQueryObjectsResponseQuerySchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -920,14 +860,8 @@ export const marshalListQueryObjectsResponseQuerySchema: z.ZodType = z lastModifierUserName: z.string().optional(), parentPath: z.string().optional(), tags: z.array(z.string()).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), parameters: z.array(z.lazy(() => marshalQueryParameterSchema)).optional(), applyAutoLimit: z.boolean().optional(), catalog: z.string().optional(), @@ -1008,14 +942,8 @@ export const marshalQuerySchema: z.ZodType = z lastModifierUserName: z.string().optional(), parentPath: z.string().optional(), tags: z.array(z.string()).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), parameters: z.array(z.lazy(() => marshalQueryParameterSchema)).optional(), applyAutoLimit: z.boolean().optional(), catalog: z.string().optional(), @@ -1045,9 +973,7 @@ export const marshalQueryBackedValueSchema: z.ZodType = z .object({ values: z.array(z.string()).optional(), queryId: z.string().optional(), - multiValuesOptions: z - .lazy(() => marshalMultiValuesOptionsSchema) - .optional(), + multiValuesOptions: z.lazy(() => marshalMultiValuesOptionsSchema).optional(), }) .transform(d => ({ values: d.values, @@ -1096,7 +1022,7 @@ export const marshalTrashQueryRequestSchema: z.ZodType = z export const marshalUpdateQueryRequestSchema: z.ZodType = z .object({ query: z.lazy(() => marshalUpdateQueryRequestQuerySchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), id: z.string().optional(), autoResolveDisplayName: z.boolean().optional(), }) @@ -1120,14 +1046,8 @@ export const marshalUpdateQueryRequestQuerySchema: z.ZodType = z lastModifierUserName: z.string().optional(), parentPath: z.string().optional(), tags: z.array(z.string()).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), parameters: z.array(z.lazy(() => marshalQueryParameterSchema)).optional(), applyAutoLimit: z.boolean().optional(), catalog: z.string().optional(), @@ -1158,14 +1078,8 @@ export const marshalVisualizationSchema: z.ZodType = z id: z.string().optional(), displayName: z.string().optional(), type: z.string().optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), serializedQueryPlan: z.string().optional(), serializedOptions: z.string().optional(), queryId: z.string().optional(), diff --git a/packages/queries/src/v1/utils.ts b/packages/queries/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/queries/src/v1/utils.ts +++ b/packages/queries/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/queries/tsconfig.json b/packages/queries/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/queries/tsconfig.json +++ b/packages/queries/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/queryhistory/package.json b/packages/queryhistory/package.json index 43669b6c..d69cc99f 100644 --- a/packages/queryhistory/package.json +++ b/packages/queryhistory/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/queryhistory/src/v1/client.ts b/packages/queryhistory/src/v1/client.ts index b8399c1c..a41cdb24 100644 --- a/packages/queryhistory/src/v1/client.ts +++ b/packages/queryhistory/src/v1/client.ts @@ -7,13 +7,11 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - parseResponse, - flattenQueryParams, -} from './utils'; -import type {ListQueries, ListQueries_Response} from './model'; +import {buildHttpRequest, executeHttpCall, parseResponse, flattenQueryParams} from './utils'; +import type { + ListQueries, + ListQueries_Response, +} from './model'; import { marshalQueryFilterSchema, unmarshalListQueries_ResponseSchema, @@ -35,24 +33,16 @@ export class Client { /** * List the history of queries through SQL warehouses, and serverless compute. - * + * * You can filter by user ID, warehouse ID, status, and time range. * Most recently started queries are returned first (up to max_results in request). * The pagination token returned in response can be used to list subsequent query statuses. */ - async listQueries( - signal: AbortSignal | undefined, - req: ListQueries, - options?: Options - ): Promise { + async listQueries(signal: AbortSignal | undefined, req: ListQueries, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/history/queries`; const params = new URLSearchParams(); if (req.filterBy !== undefined) { - flattenQueryParams( - 'filter_by', - marshalQueryFilterSchema.parse(req.filterBy), - params - ); + flattenQueryParams('filter_by', marshalQueryFilterSchema.parse(req.filterBy), params); } if (req.maxResults !== undefined) { params.append('max_results', String(req.maxResults)); @@ -68,11 +58,7 @@ export class Client { let resp: ListQueries_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListQueries_ResponseSchema); }; await execute(signal, call, options); diff --git a/packages/queryhistory/src/v1/index.ts b/packages/queryhistory/src/v1/index.ts index 66d0968c..38a5ae91 100644 --- a/packages/queryhistory/src/v1/index.ts +++ b/packages/queryhistory/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/queryhistory/src/v1/model.ts b/packages/queryhistory/src/v1/model.ts index ec287f13..ab0e2d80 100644 --- a/packages/queryhistory/src/v1/model.ts +++ b/packages/queryhistory/src/v1/model.ts @@ -124,7 +124,7 @@ export interface ExternalQuerySource_JobInfo { /** * Fetches a list of queries conforming to the provided set of query filters. - * + * * If the 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. */ @@ -181,7 +181,7 @@ export interface QueryInfo { queryId?: string | undefined; /** * 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. @@ -379,42 +379,38 @@ export const unmarshalChannelInfoSchema: z.ZodType = z dbsqlVersion: d.dbsql_version, })); -export const unmarshalExternalQuerySourceSchema: z.ZodType = - z - .object({ - dashboard_id: z.string().optional(), - legacy_dashboard_id: z.string().optional(), - alert_id: z.string().optional(), - notebook_id: z.string().optional(), - sql_query_id: z.string().optional(), - job_info: z - .lazy(() => unmarshalExternalQuerySource_JobInfoSchema) - .optional(), - genie_space_id: z.string().optional(), - }) - .transform(d => ({ - dashboardId: d.dashboard_id, - legacyDashboardId: d.legacy_dashboard_id, - alertId: d.alert_id, - notebookId: d.notebook_id, - sqlQueryId: d.sql_query_id, - jobInfo: d.job_info, - genieSpaceId: d.genie_space_id, - })); +export const unmarshalExternalQuerySourceSchema: z.ZodType = z + .object({ + dashboard_id: z.string().optional(), + legacy_dashboard_id: z.string().optional(), + alert_id: z.string().optional(), + notebook_id: z.string().optional(), + sql_query_id: z.string().optional(), + job_info: z.lazy(() => unmarshalExternalQuerySource_JobInfoSchema).optional(), + genie_space_id: z.string().optional(), + }) + .transform(d => ({ + dashboardId: d.dashboard_id, + legacyDashboardId: d.legacy_dashboard_id, + alertId: d.alert_id, + notebookId: d.notebook_id, + sqlQueryId: d.sql_query_id, + jobInfo: d.job_info, + genieSpaceId: d.genie_space_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalExternalQuerySource_JobInfoSchema: z.ZodType = - z - .object({ - job_id: z.string().optional(), - job_run_id: z.string().optional(), - job_task_run_id: z.string().optional(), - }) - .transform(d => ({ - jobId: d.job_id, - jobRunId: d.job_run_id, - jobTaskRunId: d.job_task_run_id, - })); +export const unmarshalExternalQuerySource_JobInfoSchema: z.ZodType = z + .object({ + job_id: z.string().optional(), + job_run_id: z.string().optional(), + job_task_run_id: z.string().optional(), + }) + .transform(d => ({ + jobId: d.job_id, + jobRunId: d.job_run_id, + jobTaskRunId: d.job_task_run_id, + })); export const unmarshalListQueriesSchema: z.ZodType = z .object({ @@ -431,18 +427,17 @@ export const unmarshalListQueriesSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListQueries_ResponseSchema: z.ZodType = - z - .object({ - next_page_token: z.string().optional(), - has_next_page: z.boolean().optional(), - res: z.array(z.lazy(() => unmarshalQueryInfoSchema)).optional(), - }) - .transform(d => ({ - nextPageToken: d.next_page_token, - hasNextPage: d.has_next_page, - res: d.res, - })); +export const unmarshalListQueries_ResponseSchema: z.ZodType = z + .object({ + next_page_token: z.string().optional(), + has_next_page: z.boolean().optional(), + res: z.array(z.lazy(() => unmarshalQueryInfoSchema)).optional(), + }) + .transform(d => ({ + nextPageToken: d.next_page_token, + hasNextPage: d.has_next_page, + res: d.res, + })); export const unmarshalQueryFilterSchema: z.ZodType = z .object({ @@ -544,9 +539,7 @@ export const unmarshalQueryMetricsSchema: z.ZodType = z provisioning_queue_start_timestamp: z.number().optional(), overloading_queue_start_timestamp: z.number().optional(), query_compilation_start_timestamp: z.number().optional(), - task_time_over_time_range: z - .lazy(() => unmarshalTaskTimeOverRangeSchema) - .optional(), + task_time_over_time_range: z.lazy(() => unmarshalTaskTimeOverRangeSchema).optional(), work_to_be_done: z.number().optional(), runnable_tasks: z.number().optional(), projected_remaining_task_total_time_ms: z.number().optional(), @@ -598,9 +591,7 @@ export const unmarshalQueryTagSchema: z.ZodType = z export const unmarshalTaskTimeOverRangeSchema: z.ZodType = z .object({ - entries: z - .array(z.lazy(() => unmarshalTaskTimeOverRangeEntrySchema)) - .optional(), + entries: z.array(z.lazy(() => unmarshalTaskTimeOverRangeEntrySchema)).optional(), interval: z.number().optional(), }) .transform(d => ({ @@ -608,14 +599,13 @@ export const unmarshalTaskTimeOverRangeSchema: z.ZodType = z interval: d.interval, })); -export const unmarshalTaskTimeOverRangeEntrySchema: z.ZodType = - z - .object({ - task_completed_time_ms: z.number().optional(), - }) - .transform(d => ({ - taskCompletedTimeMs: d.task_completed_time_ms, - })); +export const unmarshalTaskTimeOverRangeEntrySchema: z.ZodType = z + .object({ + task_completed_time_ms: z.number().optional(), + }) + .transform(d => ({ + taskCompletedTimeMs: d.task_completed_time_ms, + })); export const unmarshalTimeRangeSchema: z.ZodType = z .object({ @@ -797,9 +787,7 @@ export const marshalQueryMetricsSchema: z.ZodType = z provisioningQueueStartTimestamp: z.number().optional(), overloadingQueueStartTimestamp: z.number().optional(), queryCompilationStartTimestamp: z.number().optional(), - taskTimeOverTimeRange: z - .lazy(() => marshalTaskTimeOverRangeSchema) - .optional(), + taskTimeOverTimeRange: z.lazy(() => marshalTaskTimeOverRangeSchema).optional(), workToBeDone: z.number().optional(), runnableTasks: z.number().optional(), projectedRemainingTaskTotalTimeMs: z.number().optional(), @@ -851,9 +839,7 @@ export const marshalQueryTagSchema: z.ZodType = z export const marshalTaskTimeOverRangeSchema: z.ZodType = z .object({ - entries: z - .array(z.lazy(() => marshalTaskTimeOverRangeEntrySchema)) - .optional(), + entries: z.array(z.lazy(() => marshalTaskTimeOverRangeEntrySchema)).optional(), interval: z.number().optional(), }) .transform(d => ({ diff --git a/packages/queryhistory/src/v1/utils.ts b/packages/queryhistory/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/queryhistory/src/v1/utils.ts +++ b/packages/queryhistory/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/queryhistory/tsconfig.json b/packages/queryhistory/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/queryhistory/tsconfig.json +++ b/packages/queryhistory/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/registeredmodels/package.json b/packages/registeredmodels/package.json index 62dc840e..3b371f38 100644 --- a/packages/registeredmodels/package.json +++ b/packages/registeredmodels/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/registeredmodels/src/v1/client.ts b/packages/registeredmodels/src/v1/client.ts index b58f620c..f5be73f1 100644 --- a/packages/registeredmodels/src/v1/client.ts +++ b/packages/registeredmodels/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateRegisteredModel, DeleteModelVersion, @@ -66,32 +61,24 @@ export class Client { /** * Creates a new registered model in Unity Catalog. - * + * * File storage for model versions in the registered model * will be located in the default location which is specified by the parent schema, * or the parent catalog, or the Metastore. - * + * * For registered model creation to succeed, the user must satisfy the following conditions: * - The caller must be a metastore admin, or be the owner of the parent catalog and schema, * or have the **USE_CATALOG** privilege on the parent catalog * and the **USE_SCHEMA** privilege on the parent schema. * - The caller must have the **CREATE MODEL** or **CREATE FUNCTION** privilege on the parent schema. */ - async createRegisteredModel( - signal: AbortSignal | undefined, - req: CreateRegisteredModel, - options?: Options - ): Promise { + async createRegisteredModel(signal: AbortSignal | undefined, req: CreateRegisteredModel, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models`; const body = marshalRequest(req, marshalCreateRegisteredModelSchema); let resp: RegisteredModelInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema); }; await execute(signal, call, options); @@ -104,29 +91,18 @@ export class Client { /** * Deletes a model version from the specified registered model. Any aliases assigned to the * model version will also be deleted. - * + * * The caller must be a metastore admin or an owner of the parent registered model. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async deleteModelVersion( - signal: AbortSignal | undefined, - req: DeleteModelVersion, - options?: Options - ): Promise { + async deleteModelVersion(signal: AbortSignal | undefined, req: DeleteModelVersion, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`; let resp: DeleteModelVersion_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteModelVersion_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteModelVersion_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -137,29 +113,18 @@ export class Client { /** * Deletes a registered model and all its model versions from the specified parent catalog and schema. - * + * * The caller must be a metastore admin or an owner of the registered model. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async deleteRegisteredModel( - signal: AbortSignal | undefined, - req: DeleteRegisteredModel, - options?: Options - ): Promise { + async deleteRegisteredModel(signal: AbortSignal | undefined, req: DeleteRegisteredModel, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`; let resp: DeleteRegisteredModel_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteRegisteredModel_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteRegisteredModel_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -170,29 +135,18 @@ export class Client { /** * Deletes a registered model alias. - * + * * The caller must be a metastore admin or an owner of the registered model. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async deleteRegisteredModelAlias( - signal: AbortSignal | undefined, - req: DeleteRegisteredModelAlias, - options?: Options - ): Promise { + async deleteRegisteredModelAlias(signal: AbortSignal | undefined, req: DeleteRegisteredModelAlias, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`; let resp: DeleteRegisteredModelAlias_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteRegisteredModelAlias_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteRegisteredModelAlias_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -203,17 +157,13 @@ export class Client { /** * Get a model version. - * + * * The caller must be a metastore admin or an owner of (or have the **EXECUTE** * privilege on) the parent registered model. For the latter case, the caller must also be the owner * or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege * on the parent schema. */ - async getModelVersion( - signal: AbortSignal | undefined, - req: GetModelVersion, - options?: Options - ): Promise { + async getModelVersion(signal: AbortSignal | undefined, req: GetModelVersion, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`; const params = new URLSearchParams(); if (req.includeAliases !== undefined) { @@ -227,11 +177,7 @@ export class Client { let resp: ModelVersionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalModelVersionInfoSchema); }; await execute(signal, call, options); @@ -243,17 +189,13 @@ export class Client { /** * Get a model version by alias. - * + * * The caller must be a metastore admin or an owner of (or have the **EXECUTE** * privilege on) the registered model. For the latter case, the caller must also be the owner * or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege * on the parent schema. */ - async getModelVersionByAlias( - signal: AbortSignal | undefined, - req: GetModelVersionByAlias, - options?: Options - ): Promise { + async getModelVersionByAlias(signal: AbortSignal | undefined, req: GetModelVersionByAlias, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`; const params = new URLSearchParams(); if (req.includeAliases !== undefined) { @@ -264,11 +206,7 @@ export class Client { let resp: ModelVersionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalModelVersionInfoSchema); }; await execute(signal, call, options); @@ -280,17 +218,13 @@ export class Client { /** * Get a registered model. - * + * * The caller must be a metastore admin or an owner of (or have the **EXECUTE** * privilege on) the registered model. For the latter case, the caller must also be the owner * or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege * on the parent schema. */ - async getRegisteredModel( - signal: AbortSignal | undefined, - req: GetRegisteredModel, - options?: Options - ): Promise { + async getRegisteredModel(signal: AbortSignal | undefined, req: GetRegisteredModel, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeAliases !== undefined) { @@ -304,11 +238,7 @@ export class Client { let resp: RegisteredModelInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema); }; await execute(signal, call, options); @@ -321,25 +251,21 @@ export class Client { /** * List model versions. You can list model versions under a particular schema, * or list all model versions in the current metastore. - * + * * The returned models are filtered based on the privileges of the calling user. * For example, the metastore admin is able to list all the model versions. * A regular user needs to be the owner or have the **EXECUTE** privilege * on the parent registered model to recieve the model versions in the response. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - * + * * There is no guarantee of a specific ordering of the elements in the response. The * elements in the response will not contain any aliases or tags. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listModelVersions( - signal: AbortSignal | undefined, - req: ListModelVersions, - options?: Options - ): Promise { + async listModelVersions(signal: AbortSignal | undefined, req: ListModelVersions, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -356,11 +282,7 @@ export class Client { let resp: ListModelVersions_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListModelVersions_ResponseSchema); }; await execute(signal, call, options); @@ -370,11 +292,8 @@ export class Client { return resp; } - async *listModelVersionsIter( - signal: AbortSignal | undefined, - req: ListModelVersions, - options?: Options - ): AsyncGenerator { + + async *listModelVersionsIter(signal: AbortSignal | undefined, req: ListModelVersions, options?: Options): AsyncGenerator { const pageReq: ListModelVersions = {...req}; for (;;) { const resp = await this.listModelVersions(signal, pageReq, options); @@ -388,27 +307,24 @@ export class Client { } } + /** * List registered models. You can list registered models under a particular schema, * or list all registered models in the current metastore. - * + * * The returned models are filtered based on the privileges of the calling user. * For example, the metastore admin is able to list all the registered models. * A regular user needs to be the owner or have the **EXECUTE** privilege * on the registered model to recieve the registered models in the response. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - * + * * There is no guarantee of a specific ordering of the elements in the response. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listRegisteredModels( - signal: AbortSignal | undefined, - req: ListRegisteredModels, - options?: Options - ): Promise { + async listRegisteredModels(signal: AbortSignal | undefined, req: ListRegisteredModels, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models`; const params = new URLSearchParams(); if (req.catalogName !== undefined) { @@ -431,15 +347,8 @@ export class Client { let resp: ListRegisteredModels_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListRegisteredModels_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListRegisteredModels_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -448,11 +357,8 @@ export class Client { return resp; } - async *listRegisteredModelsIter( - signal: AbortSignal | undefined, - req: ListRegisteredModels, - options?: Options - ): AsyncGenerator { + + async *listRegisteredModelsIter(signal: AbortSignal | undefined, req: ListRegisteredModels, options?: Options): AsyncGenerator { const pageReq: ListRegisteredModels = {...req}; for (;;) { const resp = await this.listRegisteredModels(signal, pageReq, options); @@ -466,28 +372,21 @@ export class Client { } } + /** * Set an alias on the specified registered model. - * + * * The caller must be a metastore admin or an owner of the registered model. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async setRegisteredModelAlias( - signal: AbortSignal | undefined, - req: SetRegisteredModelAlias, - options?: Options - ): Promise { + async setRegisteredModelAlias(signal: AbortSignal | undefined, req: SetRegisteredModelAlias, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/aliases/${req.aliasArg ?? ''}`; const body = marshalRequest(req, marshalSetRegisteredModelAliasSchema); let resp: RegisteredModelAliasInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRegisteredModelAliasInfoSchema); }; await execute(signal, call, options); @@ -499,28 +398,20 @@ export class Client { /** * Updates the specified model version. - * + * * The caller must be a metastore admin or an owner of the parent registered model. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - * + * * Currently only the comment of the model version can be updated. */ - async updateModelVersion( - signal: AbortSignal | undefined, - req: UpdateModelVersion, - options?: Options - ): Promise { + async updateModelVersion(signal: AbortSignal | undefined, req: UpdateModelVersion, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}/versions/${String(req.versionArg ?? '')}`; const body = marshalRequest(req, marshalUpdateModelVersionSchema); let resp: ModelVersionInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalModelVersionInfoSchema); }; await execute(signal, call, options); @@ -532,28 +423,20 @@ export class Client { /** * Updates the specified registered model. - * + * * The caller must be a metastore admin or an owner of the registered model. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - * + * * Currently only the name, the owner or the comment of the registered model can be updated. */ - async updateRegisteredModel( - signal: AbortSignal | undefined, - req: UpdateRegisteredModel, - options?: Options - ): Promise { + async updateRegisteredModel(signal: AbortSignal | undefined, req: UpdateRegisteredModel, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/models/${req.fullNameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateRegisteredModelSchema); let resp: RegisteredModelInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalRegisteredModelInfoSchema); }; await execute(signal, call, options); diff --git a/packages/registeredmodels/src/v1/index.ts b/packages/registeredmodels/src/v1/index.ts index 97da00a8..5e7d7232 100644 --- a/packages/registeredmodels/src/v1/index.ts +++ b/packages/registeredmodels/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {ModelVersionStatus} from './model'; +export { + ModelVersionStatus, +} from './model'; export type { ConnectionDependency, @@ -27,8 +30,10 @@ export type { ModelVersionInfo, RegisteredModelAliasInfo, RegisteredModelInfo, + SecretDependency, SetRegisteredModelAlias, TableDependency, UpdateModelVersion, UpdateRegisteredModel, + VolumeDependency, } from './model'; diff --git a/packages/registeredmodels/src/v1/model.ts b/packages/registeredmodels/src/v1/model.ts index e0427938..e9cb5b2c 100644 --- a/packages/registeredmodels/src/v1/model.ts +++ b/packages/registeredmodels/src/v1/model.ts @@ -85,13 +85,17 @@ export interface DeleteRegisteredModelAlias_Response {} /** * A dependency of a SQL object. One of the following fields must be defined: - * __table__, __function__, __connection__, or __credential__. + * __table__, __function__, __connection__, __credential__, __volume__, or __secret__. */ export interface Dependency { table?: TableDependency | undefined; function?: FunctionDependency | undefined; connection?: ConnectionDependency | undefined; credential?: CredentialDependency | undefined; + /** A dependency on a Unity Catalog volume. */ + volume?: VolumeDependency | undefined; + /** A dependency on a Unity Catalog secret. */ + secret?: SecretDependency | undefined; } /** A list of dependencies. */ @@ -177,13 +181,13 @@ export interface ListRegisteredModels { includeBrowse?: boolean | undefined; /** * 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); @@ -299,6 +303,12 @@ export interface RegisteredModelInfo { browseOnly?: boolean | undefined; } +/** A secret that is dependent on a SQL object. */ +export interface SecretDependency { + /** Full name of the dependent secret, in the form of __catalog_name__.__schema_name__.__secret_name__. */ + secretFullName?: string | undefined; +} + export interface SetRegisteredModelAlias { /** The three-level (fully qualified) name of the registered model */ fullNameArg?: string | undefined; @@ -401,103 +411,104 @@ export interface UpdateRegisteredModel { browseOnly?: boolean | undefined; } -export const unmarshalConnectionDependencySchema: z.ZodType = - z - .object({ - connection_name: z.string().optional(), - }) - .transform(d => ({ - connectionName: d.connection_name, - })); - -export const unmarshalCreateRegisteredModelSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - owner: z.string().optional(), - comment: z.string().optional(), - storage_location: z.string().optional(), - metastore_id: z.string().optional(), - full_name: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - aliases: z - .array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)) - .optional(), - browse_only: z.boolean().optional(), - }) - .transform(d => ({ - name: d.name, - catalogName: d.catalog_name, - schemaName: d.schema_name, - owner: d.owner, - comment: d.comment, - storageLocation: d.storage_location, - metastoreId: d.metastore_id, - fullName: d.full_name, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - aliases: d.aliases, - browseOnly: d.browse_only, - })); - -export const unmarshalCredentialDependencySchema: z.ZodType = - z - .object({ - credential_name: z.string().optional(), - }) - .transform(d => ({ - credentialName: d.credential_name, - })); - -export const unmarshalDeleteModelVersionSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - version_arg: z.number().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - versionArg: d.version_arg, - })); +/** A volume that is dependent on a SQL object. */ +export interface VolumeDependency { + /** Full name of the dependent volume, in the form of __catalog_name__.__schema_name__.__volume_name__. */ + volumeFullName?: string | undefined; +} + +export const unmarshalConnectionDependencySchema: z.ZodType = z + .object({ + connection_name: z.string().optional(), + }) + .transform(d => ({ + connectionName: d.connection_name, + })); + +export const unmarshalCreateRegisteredModelSchema: z.ZodType = z + .object({ + name: z.string().optional(), + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + owner: z.string().optional(), + comment: z.string().optional(), + storage_location: z.string().optional(), + metastore_id: z.string().optional(), + full_name: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + aliases: z.array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)).optional(), + browse_only: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + catalogName: d.catalog_name, + schemaName: d.schema_name, + owner: d.owner, + comment: d.comment, + storageLocation: d.storage_location, + metastoreId: d.metastore_id, + fullName: d.full_name, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + aliases: d.aliases, + browseOnly: d.browse_only, + })); + +export const unmarshalCredentialDependencySchema: z.ZodType = z + .object({ + credential_name: z.string().optional(), + }) + .transform(d => ({ + credentialName: d.credential_name, + })); + +export const unmarshalDeleteModelVersionSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + version_arg: z.number().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + versionArg: d.version_arg, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteModelVersion_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeleteRegisteredModelSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - })); +export const unmarshalDeleteModelVersion_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteRegisteredModelSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteRegisteredModel_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeleteRegisteredModelAliasSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - alias_arg: z.string().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - aliasArg: d.alias_arg, - })); +export const unmarshalDeleteRegisteredModel_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteRegisteredModelAliasSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + alias_arg: z.string().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + aliasArg: d.alias_arg, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteRegisteredModelAlias_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteRegisteredModelAlias_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalDependencySchema: z.ZodType = z .object({ @@ -505,12 +516,16 @@ export const unmarshalDependencySchema: z.ZodType = z function: z.lazy(() => unmarshalFunctionDependencySchema).optional(), connection: z.lazy(() => unmarshalConnectionDependencySchema).optional(), credential: z.lazy(() => unmarshalCredentialDependencySchema).optional(), + volume: z.lazy(() => unmarshalVolumeDependencySchema).optional(), + secret: z.lazy(() => unmarshalSecretDependencySchema).optional(), }) .transform(d => ({ table: d.table, function: d.function, connection: d.connection, credential: d.credential, + volume: d.volume, + secret: d.secret, })); export const unmarshalDependencyListSchema: z.ZodType = z @@ -521,14 +536,13 @@ export const unmarshalDependencyListSchema: z.ZodType = z dependencies: d.dependencies, })); -export const unmarshalFunctionDependencySchema: z.ZodType = - z - .object({ - function_full_name: z.string().optional(), - }) - .transform(d => ({ - functionFullName: d.function_full_name, - })); +export const unmarshalFunctionDependencySchema: z.ZodType = z + .object({ + function_full_name: z.string().optional(), + }) + .transform(d => ({ + functionFullName: d.function_full_name, + })); export const unmarshalGetModelVersionSchema: z.ZodType = z .object({ @@ -544,31 +558,29 @@ export const unmarshalGetModelVersionSchema: z.ZodType = z includeBrowse: d.include_browse, })); -export const unmarshalGetModelVersionByAliasSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - alias_arg: z.string().optional(), - include_aliases: z.boolean().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - aliasArg: d.alias_arg, - includeAliases: d.include_aliases, - })); - -export const unmarshalGetRegisteredModelSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - include_aliases: z.boolean().optional(), - include_browse: z.boolean().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - includeAliases: d.include_aliases, - includeBrowse: d.include_browse, - })); +export const unmarshalGetModelVersionByAliasSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + alias_arg: z.string().optional(), + include_aliases: z.boolean().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + aliasArg: d.alias_arg, + includeAliases: d.include_aliases, + })); + +export const unmarshalGetRegisteredModelSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + include_aliases: z.boolean().optional(), + include_browse: z.boolean().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + includeAliases: d.include_aliases, + includeBrowse: d.include_browse, + })); export const unmarshalListModelVersionsSchema: z.ZodType = z .object({ @@ -585,49 +597,42 @@ export const unmarshalListModelVersionsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListModelVersions_ResponseSchema: z.ZodType = - z - .object({ - model_versions: z - .array(z.lazy(() => unmarshalModelVersionInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - modelVersions: d.model_versions, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListRegisteredModelsSchema: z.ZodType = - z - .object({ - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - include_browse: z.boolean().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - catalogName: d.catalog_name, - schemaName: d.schema_name, - includeBrowse: d.include_browse, - maxResults: d.max_results, - pageToken: d.page_token, - })); +export const unmarshalListModelVersions_ResponseSchema: z.ZodType = z + .object({ + model_versions: z.array(z.lazy(() => unmarshalModelVersionInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + modelVersions: d.model_versions, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListRegisteredModelsSchema: z.ZodType = z + .object({ + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + include_browse: z.boolean().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + catalogName: d.catalog_name, + schemaName: d.schema_name, + includeBrowse: d.include_browse, + maxResults: d.max_results, + pageToken: d.page_token, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListRegisteredModels_ResponseSchema: z.ZodType = - z - .object({ - registered_models: z - .array(z.lazy(() => unmarshalRegisteredModelInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - registeredModels: d.registered_models, - nextPageToken: d.next_page_token, - })); +export const unmarshalListRegisteredModels_ResponseSchema: z.ZodType = z + .object({ + registered_models: z.array(z.lazy(() => unmarshalRegisteredModelInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + registeredModels: d.registered_models, + nextPageToken: d.next_page_token, + })); export const unmarshalModelVersionInfoSchema: z.ZodType = z .object({ @@ -638,9 +643,7 @@ export const unmarshalModelVersionInfoSchema: z.ZodType = z comment: z.string().optional(), run_id: z.string().optional(), run_workspace_id: z.number().optional(), - model_version_dependencies: z - .lazy(() => unmarshalDependencyListSchema) - .optional(), + model_version_dependencies: z.lazy(() => unmarshalDependencyListSchema).optional(), status: z.enum(ModelVersionStatus).optional(), version: z.number().optional(), storage_location: z.string().optional(), @@ -650,9 +653,7 @@ export const unmarshalModelVersionInfoSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), id: z.string().optional(), - aliases: z - .array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)) - .optional(), + aliases: z.array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)).optional(), }) .transform(d => ({ modelName: d.model_name, @@ -675,74 +676,77 @@ export const unmarshalModelVersionInfoSchema: z.ZodType = z aliases: d.aliases, })); -export const unmarshalRegisteredModelAliasInfoSchema: z.ZodType = - z - .object({ - alias_name: z.string().optional(), - version_num: z.number().optional(), - id: z.string().optional(), - model_name: z.string().optional(), - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - }) - .transform(d => ({ - aliasName: d.alias_name, - versionNum: d.version_num, - id: d.id, - modelName: d.model_name, - catalogName: d.catalog_name, - schemaName: d.schema_name, - })); - -export const unmarshalRegisteredModelInfoSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - owner: z.string().optional(), - comment: z.string().optional(), - storage_location: z.string().optional(), - metastore_id: z.string().optional(), - full_name: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - aliases: z - .array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)) - .optional(), - browse_only: z.boolean().optional(), - }) - .transform(d => ({ - name: d.name, - catalogName: d.catalog_name, - schemaName: d.schema_name, - owner: d.owner, - comment: d.comment, - storageLocation: d.storage_location, - metastoreId: d.metastore_id, - fullName: d.full_name, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - aliases: d.aliases, - browseOnly: d.browse_only, - })); - -export const unmarshalSetRegisteredModelAliasSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - alias_arg: z.string().optional(), - version_num: z.number().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - aliasArg: d.alias_arg, - versionNum: d.version_num, - })); +export const unmarshalRegisteredModelAliasInfoSchema: z.ZodType = z + .object({ + alias_name: z.string().optional(), + version_num: z.number().optional(), + id: z.string().optional(), + model_name: z.string().optional(), + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + }) + .transform(d => ({ + aliasName: d.alias_name, + versionNum: d.version_num, + id: d.id, + modelName: d.model_name, + catalogName: d.catalog_name, + schemaName: d.schema_name, + })); + +export const unmarshalRegisteredModelInfoSchema: z.ZodType = z + .object({ + name: z.string().optional(), + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + owner: z.string().optional(), + comment: z.string().optional(), + storage_location: z.string().optional(), + metastore_id: z.string().optional(), + full_name: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + aliases: z.array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)).optional(), + browse_only: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + catalogName: d.catalog_name, + schemaName: d.schema_name, + owner: d.owner, + comment: d.comment, + storageLocation: d.storage_location, + metastoreId: d.metastore_id, + fullName: d.full_name, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + aliases: d.aliases, + browseOnly: d.browse_only, + })); + +export const unmarshalSecretDependencySchema: z.ZodType = z + .object({ + secret_full_name: z.string().optional(), + }) + .transform(d => ({ + secretFullName: d.secret_full_name, + })); + +export const unmarshalSetRegisteredModelAliasSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + alias_arg: z.string().optional(), + version_num: z.number().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + aliasArg: d.alias_arg, + versionNum: d.version_num, + })); export const unmarshalTableDependencySchema: z.ZodType = z .object({ @@ -752,97 +756,97 @@ export const unmarshalTableDependencySchema: z.ZodType = z tableFullName: d.table_full_name, })); -export const unmarshalUpdateModelVersionSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - version_arg: z.number().optional(), - model_name: z.string().optional(), - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - source: z.string().optional(), - comment: z.string().optional(), - run_id: z.string().optional(), - run_workspace_id: z.number().optional(), - model_version_dependencies: z - .lazy(() => unmarshalDependencyListSchema) - .optional(), - status: z.enum(ModelVersionStatus).optional(), - version: z.number().optional(), - storage_location: z.string().optional(), - metastore_id: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - id: z.string().optional(), - aliases: z - .array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)) - .optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - versionArg: d.version_arg, - modelName: d.model_name, - catalogName: d.catalog_name, - schemaName: d.schema_name, - source: d.source, - comment: d.comment, - runId: d.run_id, - runWorkspaceId: d.run_workspace_id, - modelVersionDependencies: d.model_version_dependencies, - status: d.status, - version: d.version, - storageLocation: d.storage_location, - metastoreId: d.metastore_id, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - id: d.id, - aliases: d.aliases, - })); - -export const unmarshalUpdateRegisteredModelSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - new_name: z.string().optional(), - name: z.string().optional(), - catalog_name: z.string().optional(), - schema_name: z.string().optional(), - owner: z.string().optional(), - comment: z.string().optional(), - storage_location: z.string().optional(), - metastore_id: z.string().optional(), - full_name: z.string().optional(), - created_at: z.number().optional(), - created_by: z.string().optional(), - updated_at: z.number().optional(), - updated_by: z.string().optional(), - aliases: z - .array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)) - .optional(), - browse_only: z.boolean().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - newName: d.new_name, - name: d.name, - catalogName: d.catalog_name, - schemaName: d.schema_name, - owner: d.owner, - comment: d.comment, - storageLocation: d.storage_location, - metastoreId: d.metastore_id, - fullName: d.full_name, - createdAt: d.created_at, - createdBy: d.created_by, - updatedAt: d.updated_at, - updatedBy: d.updated_by, - aliases: d.aliases, - browseOnly: d.browse_only, - })); +export const unmarshalUpdateModelVersionSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + version_arg: z.number().optional(), + model_name: z.string().optional(), + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + source: z.string().optional(), + comment: z.string().optional(), + run_id: z.string().optional(), + run_workspace_id: z.number().optional(), + model_version_dependencies: z.lazy(() => unmarshalDependencyListSchema).optional(), + status: z.enum(ModelVersionStatus).optional(), + version: z.number().optional(), + storage_location: z.string().optional(), + metastore_id: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + id: z.string().optional(), + aliases: z.array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)).optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + versionArg: d.version_arg, + modelName: d.model_name, + catalogName: d.catalog_name, + schemaName: d.schema_name, + source: d.source, + comment: d.comment, + runId: d.run_id, + runWorkspaceId: d.run_workspace_id, + modelVersionDependencies: d.model_version_dependencies, + status: d.status, + version: d.version, + storageLocation: d.storage_location, + metastoreId: d.metastore_id, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + id: d.id, + aliases: d.aliases, + })); + +export const unmarshalUpdateRegisteredModelSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + new_name: z.string().optional(), + name: z.string().optional(), + catalog_name: z.string().optional(), + schema_name: z.string().optional(), + owner: z.string().optional(), + comment: z.string().optional(), + storage_location: z.string().optional(), + metastore_id: z.string().optional(), + full_name: z.string().optional(), + created_at: z.number().optional(), + created_by: z.string().optional(), + updated_at: z.number().optional(), + updated_by: z.string().optional(), + aliases: z.array(z.lazy(() => unmarshalRegisteredModelAliasInfoSchema)).optional(), + browse_only: z.boolean().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + newName: d.new_name, + name: d.name, + catalogName: d.catalog_name, + schemaName: d.schema_name, + owner: d.owner, + comment: d.comment, + storageLocation: d.storage_location, + metastoreId: d.metastore_id, + fullName: d.full_name, + createdAt: d.created_at, + createdBy: d.created_by, + updatedAt: d.updated_at, + updatedBy: d.updated_by, + aliases: d.aliases, + browseOnly: d.browse_only, + })); + +export const unmarshalVolumeDependencySchema: z.ZodType = z + .object({ + volume_full_name: z.string().optional(), + }) + .transform(d => ({ + volumeFullName: d.volume_full_name, + })); export const marshalConnectionDependencySchema: z.ZodType = z .object({ @@ -866,9 +870,7 @@ export const marshalCreateRegisteredModelSchema: z.ZodType = z createdBy: z.string().optional(), updatedAt: z.number().optional(), updatedBy: z.string().optional(), - aliases: z - .array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)) - .optional(), + aliases: z.array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)).optional(), browseOnly: z.boolean().optional(), }) .transform(d => ({ @@ -907,7 +909,9 @@ export const marshalDeleteModelVersionSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteModelVersion_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteModelVersion_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeleteRegisteredModelSchema: z.ZodType = z .object({ @@ -918,9 +922,9 @@ export const marshalDeleteRegisteredModelSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteRegisteredModel_ResponseSchema: z.ZodType = z.object( - {} -); +export const marshalDeleteRegisteredModel_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeleteRegisteredModelAliasSchema: z.ZodType = z .object({ @@ -933,8 +937,9 @@ export const marshalDeleteRegisteredModelAliasSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteRegisteredModelAlias_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeleteRegisteredModelAlias_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDependencySchema: z.ZodType = z .object({ @@ -942,12 +947,16 @@ export const marshalDependencySchema: z.ZodType = z function: z.lazy(() => marshalFunctionDependencySchema).optional(), connection: z.lazy(() => marshalConnectionDependencySchema).optional(), credential: z.lazy(() => marshalCredentialDependencySchema).optional(), + volume: z.lazy(() => marshalVolumeDependencySchema).optional(), + secret: z.lazy(() => marshalSecretDependencySchema).optional(), }) .transform(d => ({ table: d.table, function: d.function, connection: d.connection, credential: d.credential, + volume: d.volume, + secret: d.secret, })); export const marshalDependencyListSchema: z.ZodType = z @@ -1021,9 +1030,7 @@ export const marshalListModelVersionsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListModelVersions_ResponseSchema: z.ZodType = z .object({ - modelVersions: z - .array(z.lazy(() => marshalModelVersionInfoSchema)) - .optional(), + modelVersions: z.array(z.lazy(() => marshalModelVersionInfoSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -1050,9 +1057,7 @@ export const marshalListRegisteredModelsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListRegisteredModels_ResponseSchema: z.ZodType = z .object({ - registeredModels: z - .array(z.lazy(() => marshalRegisteredModelInfoSchema)) - .optional(), + registeredModels: z.array(z.lazy(() => marshalRegisteredModelInfoSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -1069,9 +1074,7 @@ export const marshalModelVersionInfoSchema: z.ZodType = z comment: z.string().optional(), runId: z.string().optional(), runWorkspaceId: z.number().optional(), - modelVersionDependencies: z - .lazy(() => marshalDependencyListSchema) - .optional(), + modelVersionDependencies: z.lazy(() => marshalDependencyListSchema).optional(), status: z.enum(ModelVersionStatus).optional(), version: z.number().optional(), storageLocation: z.string().optional(), @@ -1081,9 +1084,7 @@ export const marshalModelVersionInfoSchema: z.ZodType = z updatedAt: z.number().optional(), updatedBy: z.string().optional(), id: z.string().optional(), - aliases: z - .array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)) - .optional(), + aliases: z.array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)).optional(), }) .transform(d => ({ model_name: d.modelName, @@ -1138,9 +1139,7 @@ export const marshalRegisteredModelInfoSchema: z.ZodType = z createdBy: z.string().optional(), updatedAt: z.number().optional(), updatedBy: z.string().optional(), - aliases: z - .array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)) - .optional(), + aliases: z.array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)).optional(), browseOnly: z.boolean().optional(), }) .transform(d => ({ @@ -1160,6 +1159,14 @@ export const marshalRegisteredModelInfoSchema: z.ZodType = z browse_only: d.browseOnly, })); +export const marshalSecretDependencySchema: z.ZodType = z + .object({ + secretFullName: z.string().optional(), + }) + .transform(d => ({ + secret_full_name: d.secretFullName, + })); + export const marshalSetRegisteredModelAliasSchema: z.ZodType = z .object({ fullNameArg: z.string().optional(), @@ -1191,9 +1198,7 @@ export const marshalUpdateModelVersionSchema: z.ZodType = z comment: z.string().optional(), runId: z.string().optional(), runWorkspaceId: z.number().optional(), - modelVersionDependencies: z - .lazy(() => marshalDependencyListSchema) - .optional(), + modelVersionDependencies: z.lazy(() => marshalDependencyListSchema).optional(), status: z.enum(ModelVersionStatus).optional(), version: z.number().optional(), storageLocation: z.string().optional(), @@ -1203,9 +1208,7 @@ export const marshalUpdateModelVersionSchema: z.ZodType = z updatedAt: z.number().optional(), updatedBy: z.string().optional(), id: z.string().optional(), - aliases: z - .array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)) - .optional(), + aliases: z.array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)).optional(), }) .transform(d => ({ full_name_arg: d.fullNameArg, @@ -1246,9 +1249,7 @@ export const marshalUpdateRegisteredModelSchema: z.ZodType = z createdBy: z.string().optional(), updatedAt: z.number().optional(), updatedBy: z.string().optional(), - aliases: z - .array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)) - .optional(), + aliases: z.array(z.lazy(() => marshalRegisteredModelAliasInfoSchema)).optional(), browseOnly: z.boolean().optional(), }) .transform(d => ({ @@ -1269,3 +1270,11 @@ export const marshalUpdateRegisteredModelSchema: z.ZodType = z aliases: d.aliases, browse_only: d.browseOnly, })); + +export const marshalVolumeDependencySchema: z.ZodType = z + .object({ + volumeFullName: z.string().optional(), + }) + .transform(d => ({ + volume_full_name: d.volumeFullName, + })); diff --git a/packages/registeredmodels/src/v1/utils.ts b/packages/registeredmodels/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/registeredmodels/src/v1/utils.ts +++ b/packages/registeredmodels/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/registeredmodels/tsconfig.json b/packages/registeredmodels/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/registeredmodels/tsconfig.json +++ b/packages/registeredmodels/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/resourcequotas/package.json b/packages/resourcequotas/package.json index 52dc63df..126267ab 100644 --- a/packages/resourcequotas/package.json +++ b/packages/resourcequotas/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/resourcequotas/src/v1/client.ts b/packages/resourcequotas/src/v1/client.ts index 235ffe5e..e841e633 100644 --- a/packages/resourcequotas/src/v1/client.ts +++ b/packages/resourcequotas/src/v1/client.ts @@ -39,20 +39,12 @@ export class Client { * child-parent pair. This API also refreshes the quota count if it is out of date. * Refreshes are triggered asynchronously. The updated count might not be returned in the first call. */ - async getQuota( - signal: AbortSignal | undefined, - req: GetQuota, - options?: Options - ): Promise { + async getQuota(signal: AbortSignal | undefined, req: GetQuota, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/resource-quotas/${req.parentSecurableType ?? ''}/${req.parentFullName ?? ''}/${req.quotaName ?? ''}`; let resp: GetQuota_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGetQuota_ResponseSchema); }; await execute(signal, call, options); @@ -65,15 +57,11 @@ export class Client { /** * ListQuotas returns all quota values under the metastore. There are no SLAs on the freshness of the counts * returned. This API does not trigger a refresh of quota counts. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listQuota( - signal: AbortSignal | undefined, - req: ListQuotas, - options?: Options - ): Promise { + async listQuota(signal: AbortSignal | undefined, req: ListQuotas, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/resource-quotas/all-resource-quotas`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -87,11 +75,7 @@ export class Client { let resp: ListQuotas_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListQuotas_ResponseSchema); }; await execute(signal, call, options); @@ -101,11 +85,8 @@ export class Client { return resp; } - async *listQuotaIter( - signal: AbortSignal | undefined, - req: ListQuotas, - options?: Options - ): AsyncGenerator { + + async *listQuotaIter(signal: AbortSignal | undefined, req: ListQuotas, options?: Options): AsyncGenerator { const pageReq: ListQuotas = {...req}; for (;;) { const resp = await this.listQuota(signal, pageReq, options); @@ -118,4 +99,5 @@ export class Client { pageReq.pageToken = resp.nextPageToken; } } + } diff --git a/packages/resourcequotas/src/v1/index.ts b/packages/resourcequotas/src/v1/index.ts index 050b327c..28bf468f 100644 --- a/packages/resourcequotas/src/v1/index.ts +++ b/packages/resourcequotas/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {SecurableType} from './model'; +export { + SecurableType, +} from './model'; export type { GetQuota, diff --git a/packages/resourcequotas/src/v1/model.ts b/packages/resourcequotas/src/v1/model.ts index e313877e..434780a5 100644 --- a/packages/resourcequotas/src/v1/model.ts +++ b/packages/resourcequotas/src/v1/model.ts @@ -104,16 +104,15 @@ export const unmarshalListQuotasSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListQuotas_ResponseSchema: z.ZodType = - z - .object({ - quotas: z.array(z.lazy(() => unmarshalQuotaInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - quotas: d.quotas, - nextPageToken: d.next_page_token, - })); +export const unmarshalListQuotas_ResponseSchema: z.ZodType = z + .object({ + quotas: z.array(z.lazy(() => unmarshalQuotaInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + quotas: d.quotas, + nextPageToken: d.next_page_token, + })); export const unmarshalQuotaInfoSchema: z.ZodType = z .object({ diff --git a/packages/resourcequotas/src/v1/utils.ts b/packages/resourcequotas/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/resourcequotas/src/v1/utils.ts +++ b/packages/resourcequotas/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/resourcequotas/tsconfig.json b/packages/resourcequotas/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/resourcequotas/tsconfig.json +++ b/packages/resourcequotas/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/rfa/package.json b/packages/rfa/package.json index 9703d9e3..f621dd6a 100644 --- a/packages/rfa/package.json +++ b/packages/rfa/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/rfa/src/v1/client.ts b/packages/rfa/src/v1/client.ts index 87d27737..f0c96831 100644 --- a/packages/rfa/src/v1/client.ts +++ b/packages/rfa/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { AccessRequestDestinations, BatchCreateAccessRequestsRequest, @@ -46,32 +41,18 @@ export class Client { * This Batch API can take in multiple principals, securable objects, * and permissions as the input and returns the access request destinations for each. * Principals must be unique across the API call. - * + * * The supported securable types are: "metastore", "catalog", "schema", "table", * "external_location", "connection", "credential", "function", "registered_model", and "volume". */ - async batchCreateAccessRequests( - signal: AbortSignal | undefined, - req: BatchCreateAccessRequestsRequest, - options?: Options - ): Promise { + async batchCreateAccessRequests(signal: AbortSignal | undefined, req: BatchCreateAccessRequestsRequest, options?: Options): Promise { const url = `${this.host}/api/3.0/rfa/requests`; - const body = marshalRequest( - req, - marshalBatchCreateAccessRequestsRequestSchema - ); + const body = marshalRequest(req, marshalBatchCreateAccessRequestsRequestSchema); let resp: BatchCreateAccessRequestsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalBatchCreateAccessRequestsResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalBatchCreateAccessRequestsResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -84,24 +65,16 @@ export class Client { * Gets an array of access request destinations for the specified securable. * Any caller can see URL destinations or the destinations on the metastore. * Otherwise, only those with **BROWSE** permissions on the securable can see destinations. - * + * * The supported securable types are: "metastore", "catalog", "schema", "table", * "external_location", "connection", "credential", "function", "registered_model", and "volume". */ - async getAccessRequestDestinations( - signal: AbortSignal | undefined, - req: GetAccessRequestDestinationsRequest, - options?: Options - ): Promise { + async getAccessRequestDestinations(signal: AbortSignal | undefined, req: GetAccessRequestDestinationsRequest, options?: Options): Promise { const url = `${this.host}/api/3.0/rfa/destinations/${req.securableType ?? ''}/${req.fullName ?? ''}`; let resp: AccessRequestDestinations | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAccessRequestDestinationsSchema); }; await execute(signal, call, options); @@ -117,34 +90,23 @@ export class Client { * Destinations cannot be updated for securables underneath schemas (tables, volumes, functions, and models). For these securable types, destinations are inherited from the parent securable. * A maximum of 5 emails and 5 external notification destinations (Slack, Microsoft Teams, and Generic Webhook destinations) can be assigned to a securable. * If a URL destination is assigned, no other destinations can be set. - * + * * The supported securable types are: "metastore", "catalog", "schema", "table", * "external_location", "connection", "credential", "function", "registered_model", and "volume". */ - async updateAccessRequestDestinations( - signal: AbortSignal | undefined, - req: UpdateAccessRequestDestinationsRequest, - options?: Options - ): Promise { + async updateAccessRequestDestinations(signal: AbortSignal | undefined, req: UpdateAccessRequestDestinationsRequest, options?: Options): Promise { const url = `${this.host}/api/3.0/rfa/destinations`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.accessRequestDestinations, - marshalAccessRequestDestinationsSchema - ); + const body = marshalRequest(req.accessRequestDestinations, marshalAccessRequestDestinationsSchema); let resp: AccessRequestDestinations | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalAccessRequestDestinationsSchema); }; await execute(signal, call, options); diff --git a/packages/rfa/src/v1/index.ts b/packages/rfa/src/v1/index.ts index 6212bd94..92e82423 100644 --- a/packages/rfa/src/v1/index.ts +++ b/packages/rfa/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/rfa/src/v1/model.ts b/packages/rfa/src/v1/model.ts index 74a09a74..d2d484b8 100644 --- a/packages/rfa/src/v1/model.ts +++ b/packages/rfa/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export enum DestinationType { @@ -74,7 +75,7 @@ export interface BatchCreateAccessRequestsRequest { /** * 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[] | undefined; @@ -89,20 +90,20 @@ export interface CreateAccessRequest { /** * 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 | undefined; /** * 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 | undefined; /** * 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. */ @@ -181,105 +182,86 @@ export interface UpdateAccessRequestDestinationsRequest { * For each destination, a **destination_id** and **destination_type** must be defined. */ accessRequestDestinations?: AccessRequestDestinations | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } -export const unmarshalAccessRequestDestinationsSchema: z.ZodType = - z - .object({ - destinations: z - .array(z.lazy(() => unmarshalNotificationDestinationSchema)) - .optional(), - securable: z.lazy(() => unmarshalSecurableSchema).optional(), - are_any_destinations_hidden: z.boolean().optional(), - destination_source_securable: z - .lazy(() => unmarshalSecurableSchema) - .optional(), - securable_type: z.string().optional(), - full_name: z.string().optional(), - }) - .transform(d => ({ - destinations: d.destinations, - securable: d.securable, - areAnyDestinationsHidden: d.are_any_destinations_hidden, - destinationSourceSecurable: d.destination_source_securable, - securableType: d.securable_type, - fullName: d.full_name, - })); - -export const unmarshalBatchCreateAccessRequestsRequestSchema: z.ZodType = - z - .object({ - requests: z - .array(z.lazy(() => unmarshalCreateAccessRequestSchema)) - .optional(), - }) - .transform(d => ({ - requests: d.requests, - })); - -export const unmarshalBatchCreateAccessRequestsResponseSchema: z.ZodType = - z - .object({ - responses: z - .array(z.lazy(() => unmarshalCreateAccessRequestResponseSchema)) - .optional(), - }) - .transform(d => ({ - responses: d.responses, - })); - -export const unmarshalCreateAccessRequestSchema: z.ZodType = - z - .object({ - behalf_of: z.lazy(() => unmarshalPrincipalSchema).optional(), - comment: z.string().optional(), - securable_permissions: z - .array(z.lazy(() => unmarshalSecurablePermissionsSchema)) - .optional(), - }) - .transform(d => ({ - behalfOf: d.behalf_of, - comment: d.comment, - securablePermissions: d.securable_permissions, - })); - -export const unmarshalCreateAccessRequestResponseSchema: z.ZodType = - z - .object({ - behalf_of: z.lazy(() => unmarshalPrincipalSchema).optional(), - request_destinations: z - .array(z.lazy(() => unmarshalAccessRequestDestinationsSchema)) - .optional(), - }) - .transform(d => ({ - behalfOf: d.behalf_of, - requestDestinations: d.request_destinations, - })); - -export const unmarshalGetAccessRequestDestinationsRequestSchema: z.ZodType = - z - .object({ - securable_type: z.string().optional(), - full_name: z.string().optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - fullName: d.full_name, - })); - -export const unmarshalNotificationDestinationSchema: z.ZodType = - z - .object({ - destination_id: z.string().optional(), - destination_type: z.enum(DestinationType).optional(), - special_destination: z.enum(SpecialDestination).optional(), - }) - .transform(d => ({ - destinationId: d.destination_id, - destinationType: d.destination_type, - specialDestination: d.special_destination, - })); +export const unmarshalAccessRequestDestinationsSchema: z.ZodType = z + .object({ + destinations: z.array(z.lazy(() => unmarshalNotificationDestinationSchema)).optional(), + securable: z.lazy(() => unmarshalSecurableSchema).optional(), + are_any_destinations_hidden: z.boolean().optional(), + destination_source_securable: z.lazy(() => unmarshalSecurableSchema).optional(), + securable_type: z.string().optional(), + full_name: z.string().optional(), + }) + .transform(d => ({ + destinations: d.destinations, + securable: d.securable, + areAnyDestinationsHidden: d.are_any_destinations_hidden, + destinationSourceSecurable: d.destination_source_securable, + securableType: d.securable_type, + fullName: d.full_name, + })); + +export const unmarshalBatchCreateAccessRequestsRequestSchema: z.ZodType = z + .object({ + requests: z.array(z.lazy(() => unmarshalCreateAccessRequestSchema)).optional(), + }) + .transform(d => ({ + requests: d.requests, + })); + +export const unmarshalBatchCreateAccessRequestsResponseSchema: z.ZodType = z + .object({ + responses: z.array(z.lazy(() => unmarshalCreateAccessRequestResponseSchema)).optional(), + }) + .transform(d => ({ + responses: d.responses, + })); + +export const unmarshalCreateAccessRequestSchema: z.ZodType = z + .object({ + behalf_of: z.lazy(() => unmarshalPrincipalSchema).optional(), + comment: z.string().optional(), + securable_permissions: z.array(z.lazy(() => unmarshalSecurablePermissionsSchema)).optional(), + }) + .transform(d => ({ + behalfOf: d.behalf_of, + comment: d.comment, + securablePermissions: d.securable_permissions, + })); + +export const unmarshalCreateAccessRequestResponseSchema: z.ZodType = z + .object({ + behalf_of: z.lazy(() => unmarshalPrincipalSchema).optional(), + request_destinations: z.array(z.lazy(() => unmarshalAccessRequestDestinationsSchema)).optional(), + }) + .transform(d => ({ + behalfOf: d.behalf_of, + requestDestinations: d.request_destinations, + })); + +export const unmarshalGetAccessRequestDestinationsRequestSchema: z.ZodType = z + .object({ + securable_type: z.string().optional(), + full_name: z.string().optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + fullName: d.full_name, + })); + +export const unmarshalNotificationDestinationSchema: z.ZodType = z + .object({ + destination_id: z.string().optional(), + destination_type: z.enum(DestinationType).optional(), + special_destination: z.enum(SpecialDestination).optional(), + }) + .transform(d => ({ + destinationId: d.destination_id, + destinationType: d.destination_type, + specialDestination: d.special_destination, + })); export const unmarshalPrincipalSchema: z.ZodType = z .object({ @@ -303,35 +285,29 @@ export const unmarshalSecurableSchema: z.ZodType = z providerShare: d.provider_share, })); -export const unmarshalSecurablePermissionsSchema: z.ZodType = - z - .object({ - securable: z.lazy(() => unmarshalSecurableSchema).optional(), - permissions: z.array(z.string()).optional(), - }) - .transform(d => ({ - securable: d.securable, - permissions: d.permissions, - })); - -export const unmarshalUpdateAccessRequestDestinationsRequestSchema: z.ZodType = - z - .object({ - access_request_destinations: z - .lazy(() => unmarshalAccessRequestDestinationsSchema) - .optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - accessRequestDestinations: d.access_request_destinations, - updateMask: d.update_mask, - })); +export const unmarshalSecurablePermissionsSchema: z.ZodType = z + .object({ + securable: z.lazy(() => unmarshalSecurableSchema).optional(), + permissions: z.array(z.string()).optional(), + }) + .transform(d => ({ + securable: d.securable, + permissions: d.permissions, + })); + +export const unmarshalUpdateAccessRequestDestinationsRequestSchema: z.ZodType = z + .object({ + access_request_destinations: z.lazy(() => unmarshalAccessRequestDestinationsSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + accessRequestDestinations: d.access_request_destinations, + updateMask: d.update_mask, + })); export const marshalAccessRequestDestinationsSchema: z.ZodType = z .object({ - destinations: z - .array(z.lazy(() => marshalNotificationDestinationSchema)) - .optional(), + destinations: z.array(z.lazy(() => marshalNotificationDestinationSchema)).optional(), securable: z.lazy(() => marshalSecurableSchema).optional(), areAnyDestinationsHidden: z.boolean().optional(), destinationSourceSecurable: z.lazy(() => marshalSecurableSchema).optional(), @@ -349,9 +325,7 @@ export const marshalAccessRequestDestinationsSchema: z.ZodType = z export const marshalBatchCreateAccessRequestsRequestSchema: z.ZodType = z .object({ - requests: z - .array(z.lazy(() => marshalCreateAccessRequestSchema)) - .optional(), + requests: z.array(z.lazy(() => marshalCreateAccessRequestSchema)).optional(), }) .transform(d => ({ requests: d.requests, @@ -359,9 +333,7 @@ export const marshalBatchCreateAccessRequestsRequestSchema: z.ZodType = z export const marshalBatchCreateAccessRequestsResponseSchema: z.ZodType = z .object({ - responses: z - .array(z.lazy(() => marshalCreateAccessRequestResponseSchema)) - .optional(), + responses: z.array(z.lazy(() => marshalCreateAccessRequestResponseSchema)).optional(), }) .transform(d => ({ responses: d.responses, @@ -371,9 +343,7 @@ export const marshalCreateAccessRequestSchema: z.ZodType = z .object({ behalfOf: z.lazy(() => marshalPrincipalSchema).optional(), comment: z.string().optional(), - securablePermissions: z - .array(z.lazy(() => marshalSecurablePermissionsSchema)) - .optional(), + securablePermissions: z.array(z.lazy(() => marshalSecurablePermissionsSchema)).optional(), }) .transform(d => ({ behalf_of: d.behalfOf, @@ -384,9 +354,7 @@ export const marshalCreateAccessRequestSchema: z.ZodType = z export const marshalCreateAccessRequestResponseSchema: z.ZodType = z .object({ behalfOf: z.lazy(() => marshalPrincipalSchema).optional(), - requestDestinations: z - .array(z.lazy(() => marshalAccessRequestDestinationsSchema)) - .optional(), + requestDestinations: z.array(z.lazy(() => marshalAccessRequestDestinationsSchema)).optional(), }) .transform(d => ({ behalf_of: d.behalfOf, @@ -449,10 +417,8 @@ export const marshalSecurablePermissionsSchema: z.ZodType = z export const marshalUpdateAccessRequestDestinationsRequestSchema: z.ZodType = z .object({ - accessRequestDestinations: z - .lazy(() => marshalAccessRequestDestinationsSchema) - .optional(), - updateMask: z.string().optional(), + accessRequestDestinations: z.lazy(() => marshalAccessRequestDestinationsSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ access_request_destinations: d.accessRequestDestinations, diff --git a/packages/rfa/src/v1/utils.ts b/packages/rfa/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/rfa/src/v1/utils.ts +++ b/packages/rfa/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/rfa/tsconfig.json b/packages/rfa/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/rfa/tsconfig.json +++ b/packages/rfa/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/schemas/package.json b/packages/schemas/package.json index fb300b49..1d0b568e 100644 --- a/packages/schemas/package.json +++ b/packages/schemas/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/schemas/src/v1/client.ts b/packages/schemas/src/v1/client.ts index d01bab72..72295a8f 100644 --- a/packages/schemas/src/v1/client.ts +++ b/packages/schemas/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateSchema, DeleteSchema, @@ -49,21 +44,13 @@ export class Client { * Creates a new schema for catalog in the Metastore. * The caller must be a metastore admin, or have the **CREATE_SCHEMA** privilege in the parent catalog. */ - async createSchema( - signal: AbortSignal | undefined, - req: CreateSchema, - options?: Options - ): Promise { + async createSchema(signal: AbortSignal | undefined, req: CreateSchema, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/schemas`; const body = marshalRequest(req, marshalCreateSchemaSchema); let resp: SchemaInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSchemaInfoSchema); }; await execute(signal, call, options); @@ -77,11 +64,7 @@ export class Client { * Deletes the specified schema from the parent catalog. * The caller must be the owner of the schema or an owner of the parent catalog. */ - async deleteSchema( - signal: AbortSignal | undefined, - req: DeleteSchema, - options?: Options - ): Promise { + async deleteSchema(signal: AbortSignal | undefined, req: DeleteSchema, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/schemas/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.force !== undefined) { @@ -92,11 +75,7 @@ export class Client { let resp: DeleteSchema_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteSchema_ResponseSchema); }; await execute(signal, call, options); @@ -110,11 +89,7 @@ export class Client { * Gets the specified schema within the metastore. * The caller must be a metastore admin, the owner of the schema, or a user that has the **USE_SCHEMA** privilege on the schema. */ - async getSchema( - signal: AbortSignal | undefined, - req: GetSchema, - options?: Options - ): Promise { + async getSchema(signal: AbortSignal | undefined, req: GetSchema, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/schemas/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -125,11 +100,7 @@ export class Client { let resp: SchemaInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSchemaInfoSchema); }; await execute(signal, call, options); @@ -144,17 +115,13 @@ export class Client { * If the caller is the metastore admin or the owner of the parent catalog, all schemas for the catalog will be retrieved. * Otherwise, only schemas owned by the caller (or for which the caller has the **USE_SCHEMA** privilege) will be retrieved. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listSchemas( - signal: AbortSignal | undefined, - req: ListSchemas, - options?: Options - ): Promise { + async listSchemas(signal: AbortSignal | undefined, req: ListSchemas, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/schemas`; const params = new URLSearchParams(); if (req.catalogName !== undefined) { @@ -174,11 +141,7 @@ export class Client { let resp: ListSchemas_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListSchemas_ResponseSchema); }; await execute(signal, call, options); @@ -188,11 +151,8 @@ export class Client { return resp; } - async *listSchemasIter( - signal: AbortSignal | undefined, - req: ListSchemas, - options?: Options - ): AsyncGenerator { + + async *listSchemasIter(signal: AbortSignal | undefined, req: ListSchemas, options?: Options): AsyncGenerator { const pageReq: ListSchemas = {...req}; for (;;) { const resp = await this.listSchemas(signal, pageReq, options); @@ -206,26 +166,19 @@ export class Client { } } + /** * Updates a schema for a catalog. The caller must be the owner of the schema or a metastore admin. * If the caller is a metastore admin, only the __owner__ field can be changed in the update. * If the __name__ field must be updated, the caller must be a metastore admin or have the **CREATE_SCHEMA** privilege on the parent catalog. */ - async updateSchema( - signal: AbortSignal | undefined, - req: UpdateSchema, - options?: Options - ): Promise { + async updateSchema(signal: AbortSignal | undefined, req: UpdateSchema, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/schemas/${req.fullNameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateSchemaSchema); let resp: SchemaInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSchemaInfoSchema); }; await execute(signal, call, options); diff --git a/packages/schemas/src/v1/index.ts b/packages/schemas/src/v1/index.ts index 5cf621b3..1a738ac2 100644 --- a/packages/schemas/src/v1/index.ts +++ b/packages/schemas/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {CatalogType} from './model'; +export { + CatalogType, +} from './model'; export type { CreateSchema, diff --git a/packages/schemas/src/v1/model.ts b/packages/schemas/src/v1/model.ts index cb5c96a7..2d763388 100644 --- a/packages/schemas/src/v1/model.ts +++ b/packages/schemas/src/v1/model.ts @@ -41,9 +41,7 @@ export interface CreateSchema { catalogType?: CatalogType | undefined; /** Storage location for managed tables within schema. */ storageLocation?: string | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** The unique identifier of the schema. */ schemaId?: string | undefined; /** 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. */ @@ -150,9 +148,7 @@ export interface SchemaInfo { catalogType?: CatalogType | undefined; /** Storage location for managed tables within schema. */ storageLocation?: string | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** The unique identifier of the schema. */ schemaId?: string | undefined; /** 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. */ @@ -208,9 +204,7 @@ export interface UpdateSchema { catalogType?: CatalogType | undefined; /** Storage location for managed tables within schema. */ storageLocation?: string | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** The unique identifier of the schema. */ schemaId?: string | undefined; /** 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. */ @@ -249,9 +243,7 @@ export const unmarshalCreateSchemaSchema: z.ZodType = z updated_by: z.string().optional(), catalog_type: z.enum(CatalogType).optional(), storage_location: z.string().optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), schema_id: z.string().optional(), browse_only: z.boolean().optional(), properties: z.record(z.string(), z.string()).optional(), @@ -272,8 +264,7 @@ export const unmarshalCreateSchemaSchema: z.ZodType = z updatedBy: d.updated_by, catalogType: d.catalog_type, storageLocation: d.storage_location, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, schemaId: d.schema_id, browseOnly: d.browse_only, properties: d.properties, @@ -281,28 +272,26 @@ export const unmarshalCreateSchemaSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateSchema_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCreateSchema_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateSchema_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalCreateSchema_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalDeleteSchemaSchema: z.ZodType = z .object({ @@ -315,21 +304,21 @@ export const unmarshalDeleteSchemaSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteSchema_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = - z - .object({ - value: z.string().optional(), - inherited_from_type: z.string().optional(), - inherited_from_name: z.string().optional(), - }) - .transform(d => ({ - value: d.value, - inheritedFromType: d.inherited_from_type, - inheritedFromName: d.inherited_from_name, - })); +export const unmarshalDeleteSchema_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = z + .object({ + value: z.string().optional(), + inherited_from_type: z.string().optional(), + inherited_from_name: z.string().optional(), + }) + .transform(d => ({ + value: d.value, + inheritedFromType: d.inherited_from_type, + inheritedFromName: d.inherited_from_name, + })); export const unmarshalGetSchemaSchema: z.ZodType = z .object({ @@ -356,16 +345,15 @@ export const unmarshalListSchemasSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListSchemas_ResponseSchema: z.ZodType = - z - .object({ - schemas: z.array(z.lazy(() => unmarshalSchemaInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - schemas: d.schemas, - nextPageToken: d.next_page_token, - })); +export const unmarshalListSchemas_ResponseSchema: z.ZodType = z + .object({ + schemas: z.array(z.lazy(() => unmarshalSchemaInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + schemas: d.schemas, + nextPageToken: d.next_page_token, + })); export const unmarshalSchemaInfoSchema: z.ZodType = z .object({ @@ -383,9 +371,7 @@ export const unmarshalSchemaInfoSchema: z.ZodType = z updated_by: z.string().optional(), catalog_type: z.enum(CatalogType).optional(), storage_location: z.string().optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), schema_id: z.string().optional(), browse_only: z.boolean().optional(), properties: z.record(z.string(), z.string()).optional(), @@ -406,8 +392,7 @@ export const unmarshalSchemaInfoSchema: z.ZodType = z updatedBy: d.updated_by, catalogType: d.catalog_type, storageLocation: d.storage_location, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, schemaId: d.schema_id, browseOnly: d.browse_only, properties: d.properties, @@ -415,28 +400,26 @@ export const unmarshalSchemaInfoSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalSchemaInfo_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalSchemaInfo_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalSchemaInfo_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalSchemaInfo_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalUpdateSchemaSchema: z.ZodType = z .object({ @@ -456,9 +439,7 @@ export const unmarshalUpdateSchemaSchema: z.ZodType = z updated_by: z.string().optional(), catalog_type: z.enum(CatalogType).optional(), storage_location: z.string().optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), schema_id: z.string().optional(), browse_only: z.boolean().optional(), properties: z.record(z.string(), z.string()).optional(), @@ -481,8 +462,7 @@ export const unmarshalUpdateSchemaSchema: z.ZodType = z updatedBy: d.updated_by, catalogType: d.catalog_type, storageLocation: d.storage_location, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, schemaId: d.schema_id, browseOnly: d.browse_only, properties: d.properties, @@ -490,28 +470,26 @@ export const unmarshalUpdateSchemaSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateSchema_OptionsEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalUpdateSchema_OptionsEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateSchema_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalUpdateSchema_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const marshalCreateSchemaSchema: z.ZodType = z .object({ @@ -529,9 +507,7 @@ export const marshalCreateSchemaSchema: z.ZodType = z updatedBy: z.string().optional(), catalogType: z.enum(CatalogType).optional(), storageLocation: z.string().optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), schemaId: z.string().optional(), browseOnly: z.boolean().optional(), properties: z.record(z.string(), z.string()).optional(), @@ -552,8 +528,7 @@ export const marshalCreateSchemaSchema: z.ZodType = z updated_by: d.updatedBy, catalog_type: d.catalogType, storage_location: d.storageLocation, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, schema_id: d.schemaId, browse_only: d.browseOnly, properties: d.properties, @@ -593,7 +568,9 @@ export const marshalDeleteSchemaSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteSchema_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteSchema_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = z .object({ @@ -658,9 +635,7 @@ export const marshalSchemaInfoSchema: z.ZodType = z updatedBy: z.string().optional(), catalogType: z.enum(CatalogType).optional(), storageLocation: z.string().optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), schemaId: z.string().optional(), browseOnly: z.boolean().optional(), properties: z.record(z.string(), z.string()).optional(), @@ -681,8 +656,7 @@ export const marshalSchemaInfoSchema: z.ZodType = z updated_by: d.updatedBy, catalog_type: d.catalogType, storage_location: d.storageLocation, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, schema_id: d.schemaId, browse_only: d.browseOnly, properties: d.properties, @@ -729,9 +703,7 @@ export const marshalUpdateSchemaSchema: z.ZodType = z updatedBy: z.string().optional(), catalogType: z.enum(CatalogType).optional(), storageLocation: z.string().optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), schemaId: z.string().optional(), browseOnly: z.boolean().optional(), properties: z.record(z.string(), z.string()).optional(), @@ -754,8 +726,7 @@ export const marshalUpdateSchemaSchema: z.ZodType = z updated_by: d.updatedBy, catalog_type: d.catalogType, storage_location: d.storageLocation, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, schema_id: d.schemaId, browse_only: d.browseOnly, properties: d.properties, diff --git a/packages/schemas/src/v1/utils.ts b/packages/schemas/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/schemas/src/v1/utils.ts +++ b/packages/schemas/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/schemas/tsconfig.json b/packages/schemas/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/schemas/tsconfig.json +++ b/packages/schemas/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 60afb666..64ec9a4b 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -29,6 +29,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index bf88fbac..968d194e 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -1,6 +1,9 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. -export {LaunchStage} from './model'; + +export { + LaunchStage, +} from './model'; export type { FieldMetadata, diff --git a/packages/sdk/src/model.ts b/packages/sdk/src/model.ts index e21d935b..11564b84 100644 --- a/packages/sdk/src/model.ts +++ b/packages/sdk/src/model.ts @@ -11,10 +11,10 @@ export enum LaunchStage { /** * LAUNCH_STAGE_UNSPECIFIED indicates that the launch stage is inherited * from the parent component(s). - * + * * If the component has multiple parents, it inherits the parent launch stage that * is the further along in the DEVELOPMENT -> PRIVATE_PREVIEW -> PUBLIC_PREVIEW -> GA order. - * + * * Example: A message without an explicit launch stage, used by a GA method * and a PRIVATE_PREVIEW method, will inherit the GA launch stage. */ @@ -22,7 +22,7 @@ export enum LaunchStage { /** * DEVELOPMENT represents the initial stage for API components. This stage is * intended for internal testing and early validation. - * + * * - API documentation: disabled * - Ecosystem tools: disabled * - Breaking changes: allowed @@ -31,7 +31,7 @@ export enum LaunchStage { /** * PRIVATE_PREVIEW indicates a stage where the API is available for selected * customers and early feedback. - * + * * - API documentation: disabled * - Ecosystem tools: enabled * - Breaking changes: allowed @@ -40,7 +40,7 @@ export enum LaunchStage { /** * PUBLIC_BETA indicates a stage where the API is available for all customers * but stability is not guaranteed. - * + * * - API documentation: enabled * - Ecosystem tools: enabled * - Breaking changes: allowed @@ -49,7 +49,7 @@ export enum LaunchStage { /** * PUBLIC_PREVIEW signifies a stage where the API is stable and ready for * production use. - * + * * - API documentation: enabled * - Ecosystem tools: enabled * - Breaking changes: forbidden @@ -58,7 +58,7 @@ export enum LaunchStage { /** * GA (General Availability) indicates that the API is stable and ready * for production use. - * + * * - API documentation: enabled * - Ecosystem tools: enabled * - Breaking changes: forbidden @@ -68,7 +68,7 @@ export enum LaunchStage { /** * SDK generation hints for a proto field. - * + * * These annotations guide SDK code generators in producing correct * client code. They do not affect wire format or server behavior. */ @@ -79,14 +79,21 @@ export interface FieldMetadata { * single path segment. */ isMultiSegment?: boolean | undefined; + /** + * When true, the field carries a raw byte stream (e.g., file contents) + * rather than a small binary blob. SDK generators use this to send/receive + * the data as a streaming body (application/octet-stream) instead of + * base64-encoding it into JSON. + */ + isStream?: boolean | undefined; } /** * Long-Running Operation (LRO) configuration for API methods. - * + * * This annotation is used to mark methods that return a long-running operation * and specify the associated operation management methods and types. - * + * * Long-running operations are asynchronous operations that may take an * extended period of time to complete. Instead of blocking until completion, * these methods immediately return an operation handle that can be used to @@ -95,13 +102,13 @@ export interface FieldMetadata { export interface LongRunningOperation { /** * Type information for the operation. - * + * * Specifies what response and metadata types are used by this operation. */ operationInfo?: LongRunningOperation_OperationInfo | undefined; /** * Operation management methods. - * + * * References to the methods that clients can use to interact with * the long-running operation after it has been initiated. */ @@ -113,19 +120,19 @@ export interface LongRunningOperation { export interface LongRunningOperation_OperationInfo { /** * The message type name for the operation's final response. - * + * * This is the type that will be returned when the operation completes * successfully. Use the simple message name (not fully-qualified). - * + * * Example: "CreateClusterResponse" */ responseType?: string | undefined; /** * The message type name for the operation's metadata. - * + * * This type contains intermediate status and progress information * during operation execution. Use the simple message name (not fully-qualified). - * + * * Example: "CreateClusterMetadata" */ metadataType?: string | undefined; @@ -133,7 +140,7 @@ export interface LongRunningOperation_OperationInfo { /** * References to methods that manage the long-running operation. - * + * * These methods allow clients to check status, wait for completion, * list operations, and cancel or delete operations. */ @@ -141,47 +148,47 @@ export interface LongRunningOperation_OperationInfo { export interface LongRunningOperation_OperationMethods { /** * Method name to retrieve the current status of an operation. - * + * * This method is required and should accept an operation ID and * return the current operation state. - * + * * Example: "GetOperation" */ get?: string | undefined; /** * Method name to list all operations (optional). - * + * * This method allows clients to enumerate operations, typically * filtered by resource or other criteria. - * + * * Example: "ListOperations" */ list?: string | undefined; /** * Method name to wait for operation completion (optional). - * + * * This method blocks until the operation finishes or a timeout * is reached, then returns the final operation state. - * + * * Example: "WaitForOperation" */ wait?: string | undefined; /** * Method name to delete an operation (optional). - * + * * This method removes the operation record. It does not cancel * the underlying work if it's still running. - * + * * Example: "DeleteOperation" */ delete?: string | undefined; /** * Method name to cancel a running operation (optional). - * + * * This method attempts to stop the operation's execution. * The operation may still complete or may transition to a * cancelled state. - * + * * Example: "CancelOperation" */ cancel?: string | undefined; @@ -189,7 +196,7 @@ export interface LongRunningOperation_OperationMethods { /** * SDK generation hints for an RPC method. - * + * * These annotations guide SDK code generators in producing correct * client code. They do not affect wire format or server behavior. */ @@ -212,7 +219,7 @@ export interface MethodMetadata { /** * Indicates that an API method returns paginated results. - * + * * Methods annotated with this option may not return all results in a single * call. Multiple requests are required to retrieve the complete dataset. */ @@ -230,12 +237,12 @@ export interface Pagination { /** * Offset-based pagination. - * + * * To retrieve results: * 1. Set the offset field to 0 (or omit it) for the first page. * 2. Set max_results to control how many items per page. * 3. For subsequent pages, increment offset by the page size. - * + * * Example: To get items 0-99, set offset=0 and max_results=100. * To get items 100-199, set offset=100 and max_results=100. */ @@ -243,21 +250,21 @@ export interface Pagination { export interface Pagination_OffsetInfo { /** * Specifies the request field name for the starting offset. - * + * * This field skips the first N items in the result set. * For the first page, this should be 0 or unset. */ offset?: string | undefined; /** * Specifies the request field name for the page size. - * + * * The API may return fewer items than requested (for example, on the * last page, or due to access permissions). */ maxResults?: string | undefined; /** * A server-recommended page size for optimal performance. - * + * * Clients should use this value if they don't have a specific * page size requirement. */ @@ -266,13 +273,13 @@ export interface Pagination_OffsetInfo { /** * Token-based pagination. - * + * * To retrieve results: * 1. Make the first request without a page token (or with an empty token). * 2. Check the response for a next page token. * 3. If present, include that token in the next request. * 4. Repeat until the response contains no next page token. - * + * * Note: Page tokens are opaque strings and should not be parsed or * constructed by clients. Always use the exact token returned by the API. */ @@ -280,27 +287,27 @@ export interface Pagination_OffsetInfo { export interface Pagination_PageTokenInfo { /** * Specifies the request field name for the page token. - * + * * This field should be empty or unset for the first page. * For subsequent pages, it should contain the token from the previous response. */ request?: string | undefined; /** * Specifies the response field name for the next page token. - * + * * When this field is empty or absent in the response, there are no * more pages to fetch. */ response?: string | undefined; /** * Specifies the request field name for the page size. - * + * * The API may return fewer items than requested. */ maxResults?: string | undefined; /** * A server-recommended page size for optimal performance. - * + * * Clients should use this value if they don't have a specific * page size requirement. */ @@ -313,9 +320,9 @@ export interface Pagination_PageTokenInfo { * * method_to_poll: the method which returns the status of the operations. * * binding: a mapping of fields used to construct the request to such method. * * state_info: a message describing how to find and interpret the operation's state. - * + * * The following example demonstrates how to annotate an RPC, `Create`, which initiates a long-running operation. - * + * * 1. A client calls `Create(CreateRequest)`, which returns an `Object` response immediately. * 2. The `wait_for_state` annotation tells the client generator that this operation isn't finished and must be polled. * 3. To check the status, the client will poll the `Get` method (specified by `method_to_poll: "Get"`). @@ -324,7 +331,7 @@ export interface Pagination_PageTokenInfo { * 6. If the `state` field's value is `"RUNNING"`, the operation is complete and successful (per `state_info.success_states: "RUNNING"`). * 7. If the `state` is `"STOPPED"` or `"FAILED"`, the operation is complete and has failed (per `state_info.failure_states: ["STOPPED", "FAILED"]`). * 8. If the state is anything else, the client continues to poll the `Get` method until the timeout is reached. - * + * * rpc Create(CreateRequest) returns Object { * option (databricks.sdk.wait_for_state) = { * method_to_poll: "Get" @@ -343,7 +350,7 @@ export interface Pagination_PageTokenInfo { * } * rpc Get(GetRequest) returns Object { * } - * + * * message Object { * optional string object_id = 1; * optional State state = 2; @@ -413,55 +420,50 @@ export interface WaitForState_StateInfo { export const unmarshalFieldMetadataSchema: z.ZodType = z .object({ is_multi_segment: z.boolean().optional(), + is_stream: z.boolean().optional(), }) .transform(d => ({ isMultiSegment: d.is_multi_segment, + isStream: d.is_stream, })); -export const unmarshalLongRunningOperationSchema: z.ZodType = - z - .object({ - operation_info: z - .lazy(() => unmarshalLongRunningOperation_OperationInfoSchema) - .optional(), - operation_methods: z - .lazy(() => unmarshalLongRunningOperation_OperationMethodsSchema) - .optional(), - }) - .transform(d => ({ - operationInfo: d.operation_info, - operationMethods: d.operation_methods, - })); +export const unmarshalLongRunningOperationSchema: z.ZodType = z + .object({ + operation_info: z.lazy(() => unmarshalLongRunningOperation_OperationInfoSchema).optional(), + operation_methods: z.lazy(() => unmarshalLongRunningOperation_OperationMethodsSchema).optional(), + }) + .transform(d => ({ + operationInfo: d.operation_info, + operationMethods: d.operation_methods, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalLongRunningOperation_OperationInfoSchema: z.ZodType = - z - .object({ - response_type: z.string().optional(), - metadata_type: z.string().optional(), - }) - .transform(d => ({ - responseType: d.response_type, - metadataType: d.metadata_type, - })); +export const unmarshalLongRunningOperation_OperationInfoSchema: z.ZodType = z + .object({ + response_type: z.string().optional(), + metadata_type: z.string().optional(), + }) + .transform(d => ({ + responseType: d.response_type, + metadataType: d.metadata_type, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalLongRunningOperation_OperationMethodsSchema: z.ZodType = - z - .object({ - get: z.string().optional(), - list: z.string().optional(), - wait: z.string().optional(), - delete: z.string().optional(), - cancel: z.string().optional(), - }) - .transform(d => ({ - get: d.get, - list: d.list, - wait: d.wait, - delete: d.delete, - cancel: d.cancel, - })); +export const unmarshalLongRunningOperation_OperationMethodsSchema: z.ZodType = z + .object({ + get: z.string().optional(), + list: z.string().optional(), + wait: z.string().optional(), + delete: z.string().optional(), + cancel: z.string().optional(), + }) + .transform(d => ({ + get: d.get, + list: d.list, + wait: d.wait, + delete: d.delete, + cancel: d.cancel, + })); export const unmarshalMethodMetadataSchema: z.ZodType = z .object({ @@ -476,9 +478,7 @@ export const unmarshalMethodMetadataSchema: z.ZodType = z export const unmarshalPaginationSchema: z.ZodType = z .object({ offset_info: z.lazy(() => unmarshalPagination_OffsetInfoSchema).optional(), - token_info: z - .lazy(() => unmarshalPagination_PageTokenInfoSchema) - .optional(), + token_info: z.lazy(() => unmarshalPagination_PageTokenInfoSchema).optional(), results: z.string().optional(), }) .transform(d => ({ @@ -488,34 +488,32 @@ export const unmarshalPaginationSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalPagination_OffsetInfoSchema: z.ZodType = - z - .object({ - offset: z.string().optional(), - max_results: z.string().optional(), - default_max_results: z.number().optional(), - }) - .transform(d => ({ - offset: d.offset, - maxResults: d.max_results, - defaultMaxResults: d.default_max_results, - })); +export const unmarshalPagination_OffsetInfoSchema: z.ZodType = z + .object({ + offset: z.string().optional(), + max_results: z.string().optional(), + default_max_results: z.number().optional(), + }) + .transform(d => ({ + offset: d.offset, + maxResults: d.max_results, + defaultMaxResults: d.default_max_results, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalPagination_PageTokenInfoSchema: z.ZodType = - z - .object({ - request: z.string().optional(), - response: z.string().optional(), - max_results: z.string().optional(), - default_max_results: z.number().optional(), - }) - .transform(d => ({ - request: d.request, - response: d.response, - maxResults: d.max_results, - defaultMaxResults: d.default_max_results, - })); +export const unmarshalPagination_PageTokenInfoSchema: z.ZodType = z + .object({ + request: z.string().optional(), + response: z.string().optional(), + max_results: z.string().optional(), + default_max_results: z.number().optional(), + }) + .transform(d => ({ + request: d.request, + response: d.response, + maxResults: d.max_results, + defaultMaxResults: d.default_max_results, + })); export const unmarshalWaitForStateSchema: z.ZodType = z .object({ @@ -530,63 +528,56 @@ export const unmarshalWaitForStateSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalWaitForState_BindingSchema: z.ZodType = - z - .object({ - pairs: z - .array(z.lazy(() => unmarshalWaitForState_Binding_BindingPairSchema)) - .optional(), - }) - .transform(d => ({ - pairs: d.pairs, - })); +export const unmarshalWaitForState_BindingSchema: z.ZodType = z + .object({ + pairs: z.array(z.lazy(() => unmarshalWaitForState_Binding_BindingPairSchema)).optional(), + }) + .transform(d => ({ + pairs: d.pairs, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalWaitForState_Binding_BindingPairSchema: z.ZodType = - z - .object({ - poll_method_field: z.string().optional(), - request_field: z.string().optional(), - response_field: z.string().optional(), - }) - .transform(d => ({ - pollMethodField: d.poll_method_field, - requestField: d.request_field, - responseField: d.response_field, - })); +export const unmarshalWaitForState_Binding_BindingPairSchema: z.ZodType = z + .object({ + poll_method_field: z.string().optional(), + request_field: z.string().optional(), + response_field: z.string().optional(), + }) + .transform(d => ({ + pollMethodField: d.poll_method_field, + requestField: d.request_field, + responseField: d.response_field, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalWaitForState_StateInfoSchema: z.ZodType = - z - .object({ - state_path: z.array(z.string()).optional(), - success_states: z.array(z.string()).optional(), - failure_states: z.array(z.string()).optional(), - message_path: z.array(z.string()).optional(), - }) - .transform(d => ({ - statePath: d.state_path, - successStates: d.success_states, - failureStates: d.failure_states, - messagePath: d.message_path, - })); +export const unmarshalWaitForState_StateInfoSchema: z.ZodType = z + .object({ + state_path: z.array(z.string()).optional(), + success_states: z.array(z.string()).optional(), + failure_states: z.array(z.string()).optional(), + message_path: z.array(z.string()).optional(), + }) + .transform(d => ({ + statePath: d.state_path, + successStates: d.success_states, + failureStates: d.failure_states, + messagePath: d.message_path, + })); export const marshalFieldMetadataSchema: z.ZodType = z .object({ isMultiSegment: z.boolean().optional(), + isStream: z.boolean().optional(), }) .transform(d => ({ is_multi_segment: d.isMultiSegment, + is_stream: d.isStream, })); export const marshalLongRunningOperationSchema: z.ZodType = z .object({ - operationInfo: z - .lazy(() => marshalLongRunningOperation_OperationInfoSchema) - .optional(), - operationMethods: z - .lazy(() => marshalLongRunningOperation_OperationMethodsSchema) - .optional(), + operationInfo: z.lazy(() => marshalLongRunningOperation_OperationInfoSchema).optional(), + operationMethods: z.lazy(() => marshalLongRunningOperation_OperationMethodsSchema).optional(), }) .transform(d => ({ operation_info: d.operationInfo, @@ -686,9 +677,7 @@ export const marshalWaitForStateSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalWaitForState_BindingSchema: z.ZodType = z .object({ - pairs: z - .array(z.lazy(() => marshalWaitForState_Binding_BindingPairSchema)) - .optional(), + pairs: z.array(z.lazy(() => marshalWaitForState_Binding_BindingPairSchema)).optional(), }) .transform(d => ({ pairs: d.pairs, diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/secrets/package.json b/packages/secrets/package.json new file mode 100644 index 00000000..a5e53a0c --- /dev/null +++ b/packages/secrets/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-secrets", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v1": { + "types": "./dist/v1/index.d.ts", + "import": "./dist/v1/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/secrets/src/v1/client.ts b/packages/secrets/src/v1/client.ts new file mode 100644 index 00000000..3dad5f6c --- /dev/null +++ b/packages/secrets/src/v1/client.ts @@ -0,0 +1,543 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + AclItem, + CreateScope, + CreateScope_Response, + DeleteAcl, + DeleteAcl_Response, + DeleteScope, + DeleteScope_Response, + DeleteSecret, + DeleteSecret_Response, + GetAcl, + GetSecret, + GetSecret_Response, + ListAcls, + ListAcls_Response, + ListScopes, + ListScopes_Response, + ListSecrets, + ListSecrets_Response, + PutAcl, + PutAcl_Response, + PutSecret, + PutSecret_Response, +} from './model'; +import { + marshalCreateScopeSchema, + marshalDeleteAclSchema, + marshalDeleteScopeSchema, + marshalDeleteSecretSchema, + marshalPutAclSchema, + marshalPutSecretSchema, + unmarshalAclItemSchema, + unmarshalCreateScope_ResponseSchema, + unmarshalDeleteAcl_ResponseSchema, + unmarshalDeleteScope_ResponseSchema, + unmarshalDeleteSecret_ResponseSchema, + unmarshalGetSecret_ResponseSchema, + unmarshalListAcls_ResponseSchema, + unmarshalListScopes_ResponseSchema, + unmarshalListSecrets_ResponseSchema, + unmarshalPutAcl_ResponseSchema, + unmarshalPutSecret_ResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** + * Creates a new secret scope. + * + * The scope name must consist of alphanumeric characters, dashes, underscores, and + * periods, and may not exceed 128 characters. + * + * Example request: + * + * .. code:: + * + * { + * "scope": "my-simple-databricks-scope", + * "initial_manage_principal": "users" + * "scope_backend_type": "databricks|azure_keyvault", + * # below is only required if scope type is azure_keyvault + * "backend_azure_keyvault": { + * "resource_id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.KeyVault/vaults/xxxx", + * "tenant_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + * "dns_name": "https://xxxx.vault.azure.net/", + * } + * } + * + * If ``initial_manage_principal`` is specified, the initial ACL applied to the scope is + * applied to the supplied principal (user or group) with ``MANAGE`` permissions. + * The only supported principal for this option is the group ``users``, which + * contains all users in the workspace. If ``initial_manage_principal`` is not specified, + * the initial ACL with ``MANAGE`` permission applied to the scope is assigned to the + * API request issuer's user identity. + * + * If ``scope_backend_type`` is ``azure_keyvault``, a secret scope is created with secrets + * from a given Azure KeyVault. The caller must provide the keyvault_resource_id and the tenant_id + * for the key vault. If ``scope_backend_type`` is ``databricks`` or is unspecified, an empty + * secret scope is created and stored in 's own storage. + * + * + * Throws ``RESOURCE_ALREADY_EXISTS`` if a scope with the given name already exists. + * Throws ``RESOURCE_LIMIT_EXCEEDED`` if maximum number of scopes in the workspace is exceeded. + * Throws ``INVALID_PARAMETER_VALUE`` if the scope name is invalid. + * Throws ``BAD_REQUEST`` if request violated constraints. + * Throws ``CUSTOMER_UNAUTHORIZED`` if normal user attempts to create a scope with name reserved for databricks internal usage. + * Throws ``UNAUTHENTICATED`` if unable to verify user access permission on Azure KeyVault + */ + async createScope(signal: AbortSignal | undefined, req: CreateScope, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/scopes/create`; + const body = marshalRequest(req, marshalCreateScopeSchema); + let resp: CreateScope_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateScope_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Deletes the given ACL on the given scope. + * + * Users must have the ``MANAGE`` permission to invoke this API. + * + * Example request: + * + * .. code:: + * + * { + * "scope": "my-secret-scope", + * "principal": "data-scientists" + * } + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope, principal, or ACL exists. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + * Throws ``INVALID_PARAMETER_VALUE`` if the permission or principal is invalid. + */ + async deleteAcl(signal: AbortSignal | undefined, req: DeleteAcl, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/acls/delete`; + const body = marshalRequest(req, marshalDeleteAclSchema); + let resp: DeleteAcl_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteAcl_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Deletes a secret scope. + * + * Example request: + * + * .. code:: + * + * { + * "scope": "my-secret-scope" + * } + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if the scope does not exist. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + * Throws ``BAD_REQUEST`` if system user attempts to delete internal secret scope. + */ + async deleteScope(signal: AbortSignal | undefined, req: DeleteScope, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/scopes/delete`; + const body = marshalRequest(req, marshalDeleteScopeSchema); + let resp: DeleteScope_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteScope_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Deletes the secret stored in this secret scope. You must have ``WRITE`` or ``MANAGE`` + * permission on the Secret Scope. + * + * Example request: + * + * .. code:: + * + * { + * "scope": "my-secret-scope", + * "key": "my-secret-key" + * } + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope or secret exists. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + * Throws ``BAD_REQUEST`` if system user attempts to delete an internal secret, or request is made against Azure KeyVault backed scope. + */ + async deleteSecret(signal: AbortSignal | undefined, req: DeleteSecret, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/delete`; + const body = marshalRequest(req, marshalDeleteSecretSchema); + let resp: DeleteSecret_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteSecret_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Describes the details about the given ACL, such as the group and permission. + * + * Users must have the ``MANAGE`` permission to invoke this API. + * + * Example response: + * + * .. code:: + * + * { + * "principal": "data-scientists", + * "permission": "READ" + * } + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope exists. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + * Throws ``INVALID_PARAMETER_VALUE`` if the permission or principal is invalid. + */ + async getAcl(signal: AbortSignal | undefined, req: GetAcl, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/acls/get`; + const params = new URLSearchParams(); + if (req.scope !== undefined) { + params.append('scope', req.scope); + } + if (req.principal !== undefined) { + params.append('principal', req.principal); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: AclItem | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalAclItemSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Gets a secret for a given key and scope. This API can only be called from the DBUtils + * interface. Users need the READ permission to make this call. + * + * Example response: + * + * .. code:: + * + * { + * "key": "my-string-key", + * "value": + * } + * + * Note that the secret value returned is in bytes. The interpretation of the bytes + * is determined by the caller in DBUtils and the type the data is decoded into. + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret or secret scope exists. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + * + * Note: This is explicitly an undocumented API. It also doesn't need to be supported + * for the /preview prefix, because it's not a customer-facing API (i.e. only used + * for DBUtils SecretUtils to fetch secrets). + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope or secret exists. + * Throws ``BAD_REQUEST`` if normal user calls get secret outside of a notebook. + * AKV specific errors: + * Throws ``INVALID_PARAMETER_VALUE`` if secret name is not alphanumeric or too long. + * Throws ``PERMISSION_DENIED`` if secret manager cannot access AKV with 403 error + * Throws ``MALFORMED_REQUEST`` if secret manager cannot access AKV with any other 4xx error + */ + async getSecret(signal: AbortSignal | undefined, req: GetSecret, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/get`; + const params = new URLSearchParams(); + if (req.scope !== undefined) { + params.append('scope', req.scope); + } + if (req.key !== undefined) { + params.append('key', req.key); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: GetSecret_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetSecret_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Lists the ACLs set on the given scope. + * + * Users must have the ``MANAGE`` permission to invoke this API. + * + * Example response: + * + * .. code:: + * + * { + * "acls": [{ + * "principal": "admins", + * "permission": "MANAGE" + * },{ + * "principal": "data-scientists", + * "permission": "READ" + * }] + * } + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope exists. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + */ + async listAcls(signal: AbortSignal | undefined, req: ListAcls, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/acls/list`; + const params = new URLSearchParams(); + if (req.scope !== undefined) { + params.append('scope', req.scope); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListAcls_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListAcls_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Lists all secret scopes available in the workspace. + * + * Example response: + * + * .. code:: + * + * { + * "scopes": [{ + * "name": "my-databricks-scope", + * "backend_type": "DATABRICKS" + * },{ + * "name": "mount-points", + * "backend_type": "DATABRICKS" + * }] + * } + * + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + */ + async listScopes(signal: AbortSignal | undefined, _req: ListScopes, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/scopes/list`; + let resp: ListScopes_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListScopes_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Lists the secret keys that are stored at this scope. This is a metadata-only + * operation; secret data cannot be retrieved using this API. Users need the READ + * permission to make this call. + * + * Example response: + * + * .. code:: + * + * { + * "secrets": [ + * { + * "key": "my-string-key"", + * "last_updated_timestamp": "1520467595000" + * }, + * { + * "key": "my-byte-key", + * "last_updated_timestamp": "1520467595000" + * }, + * ] + * } + * + * The lastUpdatedTimestamp returned is in milliseconds since epoch. + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope exists. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + */ + async listSecrets(signal: AbortSignal | undefined, req: ListSecrets, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/list`; + const params = new URLSearchParams(); + if (req.scope !== undefined) { + params.append('scope', req.scope); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListSecrets_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListSecrets_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Creates or overwrites the ACL associated with the given principal (user or group) on the + * specified scope point. In general, a user or group will use the most powerful + * permission available to them, and permissions are ordered as follows: + * + * * ``MANAGE`` - Allowed to change ACLs, and read and write to this secret scope. + * * ``WRITE`` - Allowed to read and write to this secret scope. + * * ``READ`` - Allowed to read this secret scope and list what secrets are available. + * + * Note that in general, secret values can only be read from within a command + * on a cluster (for example, through a notebook). There is no API to read the actual + * secret value material outside of a cluster. However, the user's permission will be + * applied based on who is executing the command, and they must have at least READ permission. + * + * Users must have the ``MANAGE`` permission to invoke this API. + * + * Example request: + * + * .. code:: + * + * { + * "scope": "my-secret-scope", + * "principal": "data-scientists", + * "permission": "READ" + * } + * + * The principal is a user or group name corresponding to an existing + * principal to be granted or revoked access. + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope exists. + * Throws ``RESOURCE_ALREADY_EXISTS`` if a permission for the principal already exists. + * Throws ``INVALID_PARAMETER_VALUE`` if the permission or principal is invalid. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + */ + async putAcl(signal: AbortSignal | undefined, req: PutAcl, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/acls/put`; + const body = marshalRequest(req, marshalPutAclSchema); + let resp: PutAcl_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalPutAcl_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Inserts a secret under the provided scope with the given name. If a secret already + * exists with the same name, this command overwrites the existing secret's value. + * The server encrypts the secret using the secret scope's encryption settings before + * storing it. You must have ``WRITE`` or ``MANAGE`` permission on the secret scope. + * + * The secret key must consist of alphanumeric characters, dashes, underscores, + * and periods, and cannot exceed 128 characters. The maximum allowed secret + * value size is 128 KB. The maximum number of secrets in a given scope is + * 1000. + * + * Example request: + * + * .. code:: + * + * { + * "scope": "my-databricks-scope", + * "key": "my-string-key", + * "string_value": "foobar" + * } + * + * The input fields "string_value" or "bytes_value" + * specify the type of the secret, which will determine the value returned when + * the secret value is requested. Exactly one must be specified. + * + * Throws ``RESOURCE_DOES_NOT_EXIST`` if no such secret scope exists. + * Throws ``RESOURCE_LIMIT_EXCEEDED`` if maximum number of secrets in scope is exceeded. + * Throws ``INVALID_PARAMETER_VALUE`` if the request parameters are invalid. + * Throws ``PERMISSION_DENIED`` if the user does not have permission to make this API call. + * Throws ``MALFORMED_REQUEST`` if request is incorrectly formatted or conflicting. + * Throws ``BAD_REQUEST`` if request is made against Azure KeyVault backed scope. + */ + async putSecret(signal: AbortSignal | undefined, req: PutSecret, options?: Options): Promise { + const url = `${this.host}/api/2.0/secrets/put`; + const body = marshalRequest(req, marshalPutSecretSchema); + let resp: PutSecret_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalPutSecret_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/secrets/src/v1/index.ts b/packages/secrets/src/v1/index.ts new file mode 100644 index 00000000..42d9855b --- /dev/null +++ b/packages/secrets/src/v1/index.ts @@ -0,0 +1,37 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { + AclPermission, + ScopeBackendType, +} from './model'; + +export type { + AclItem, + AzureKeyVaultSecretScopeMetadata, + CreateScope, + CreateScope_Response, + DeleteAcl, + DeleteAcl_Response, + DeleteScope, + DeleteScope_Response, + DeleteSecret, + DeleteSecret_Response, + GetAcl, + GetSecret, + GetSecret_Response, + ListAcls, + ListAcls_Response, + ListScopes, + ListScopes_Response, + ListSecrets, + ListSecrets_Response, + PutAcl, + PutAcl_Response, + PutSecret, + PutSecret_Response, + SecretMetadata, + SecretScope, +} from './model'; diff --git a/packages/secrets/src/v1/model.ts b/packages/secrets/src/v1/model.ts new file mode 100644 index 00000000..5747d881 --- /dev/null +++ b/packages/secrets/src/v1/model.ts @@ -0,0 +1,631 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +/** The ACL permission levels for Secret ACLs applied to secret scopes. */ +export enum AclPermission { + /** Allowed to perform read operations (get, list) on secrets in this scope. */ + READ = 'READ', + /** Allowed to read and write secrets to this secret scope. */ + WRITE = 'WRITE', + /** Allowed to read/write ACLs, and read/write secrets to this secret scope. */ + MANAGE = 'MANAGE', +} + +/** + * The types of secret scope backends in the Secret Manager. Azure KeyVault backed secret scopes + * will be supported in a later release. + */ +export enum ScopeBackendType { + /** + * A secret scope in which secrets are stored in Databrick managed storage + * and encrypted with a cloud-based specific encryption key. + */ + DATABRICKS = 'DATABRICKS', + /** + * A customer Azure KeyVault backed secret scope. Reading secrets from this scope will directly + * read secrets from the customer vault. Only scope and secret ACL metadata are stored in Databricks. + */ + AZURE_KEYVAULT = 'AZURE_KEYVAULT', +} + +/** + * An item representing an ACL rule applied to the given principal (user or group) + * on the associated scope point. + */ +export interface AclItem { + /** The principal in which the permission is applied. */ + principal?: string | undefined; + /** The permission level applied to the principal. */ + permission?: AclPermission | undefined; +} + +/** The metadata of the Azure KeyVault for a secret scope of type `AZURE_KEYVAULT` */ +export interface AzureKeyVaultSecretScopeMetadata { + /** The resource id of the azure KeyVault that user wants to associate the scope with. */ + resourceId?: string | undefined; + /** The DNS of the KeyVault */ + dnsName?: string | undefined; +} + +export interface CreateScope { + /** Scope name requested by the user. Scope names are unique. */ + scope?: string | undefined; + /** The principal that is initially granted ``MANAGE`` permission to the created scope. */ + initialManagePrincipal?: string | undefined; + /** The backend type the scope will be created with. If not specified, will default to ``DATABRICKS`` */ + scopeBackendType?: ScopeBackendType | undefined; + /** The metadata for the secret scope if the type is ``AZURE_KEYVAULT`` */ + backendAzureKeyvault?: AzureKeyVaultSecretScopeMetadata | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface CreateScope_Response {} + +export interface DeleteAcl { + /** The name of the scope to remove permissions from. */ + scope?: string | undefined; + /** The principal to remove an existing ACL from. */ + principal?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeleteAcl_Response {} + +export interface DeleteScope { + /** Name of the scope to delete. */ + scope?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeleteScope_Response {} + +export interface DeleteSecret { + /** The name of the scope that contains the secret to delete. */ + scope?: string | undefined; + /** Name of the secret to delete. */ + key?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeleteSecret_Response {} + +export interface GetAcl { + /** The name of the scope to fetch ACL information from. */ + scope?: string | undefined; + /** The principal to fetch ACL information for. */ + principal?: string | undefined; +} + +export interface GetSecret { + /** The name of the scope that contains the secret. */ + scope?: string | undefined; + /** Name of the secret to fetch value information. */ + key?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetSecret_Response { + /** A unique name to identify the secret. */ + key?: string | undefined; + /** The value of the secret in its byte representation. */ + value?: Uint8Array | undefined; +} + +export interface ListAcls { + /** The name of the scope to fetch ACL information from. */ + scope?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListAcls_Response { + /** The associated ACLs rule applied to principals in the given scope. */ + items?: AclItem[] | undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ListScopes {} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListScopes_Response { + /** The available secret scopes. */ + scopes?: SecretScope[] | undefined; +} + +export interface ListSecrets { + /** The name of the scope to list secrets within. */ + scope?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListSecrets_Response { + /** Metadata information of all secrets contained within the given scope. */ + secrets?: SecretMetadata[] | undefined; +} + +export interface PutAcl { + /** The name of the scope to apply permissions to. */ + scope?: string | undefined; + /** The principal in which the permission is applied. */ + principal?: string | undefined; + /** The permission level applied to the principal. */ + permission?: AclPermission | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface PutAcl_Response {} + +export interface PutSecret { + /** The name of the scope to which the secret will be associated with. */ + scope?: string | undefined; + /** A unique name to identify the secret. */ + key?: string | undefined; + /** If specified, note that the value will be stored in UTF-8 (MB4) form. */ + stringValue?: string | undefined; + /** If specified, value will be stored as bytes. */ + bytesValue?: Uint8Array | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface PutSecret_Response {} + +/** + * The metadata about a secret. Returned when listing secrets. Does not contain the + * actual secret value. + */ +export interface SecretMetadata { + /** A unique name to identify the secret. */ + key?: string | undefined; + /** The last updated timestamp (in milliseconds) for the secret. */ + lastUpdatedTimestamp?: number | undefined; +} + +/** + * 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. + */ +export interface SecretScope { + /** A unique name to identify the secret scope. */ + name?: string | undefined; + /** The type of secret scope backend. */ + backendType?: ScopeBackendType | undefined; + /** The metadata for the secret scope if the type is ``AZURE_KEYVAULT`` */ + keyvaultMetadata?: AzureKeyVaultSecretScopeMetadata | undefined; +} + +export const unmarshalAclItemSchema: z.ZodType = z + .object({ + principal: z.string().optional(), + permission: z.enum(AclPermission).optional(), + }) + .transform(d => ({ + principal: d.principal, + permission: d.permission, + })); + +export const unmarshalAzureKeyVaultSecretScopeMetadataSchema: z.ZodType = z + .object({ + resource_id: z.string().optional(), + dns_name: z.string().optional(), + }) + .transform(d => ({ + resourceId: d.resource_id, + dnsName: d.dns_name, + })); + +export const unmarshalCreateScopeSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + initial_manage_principal: z.string().optional(), + scope_backend_type: z.enum(ScopeBackendType).optional(), + backend_azure_keyvault: z.lazy(() => unmarshalAzureKeyVaultSecretScopeMetadataSchema).optional(), + }) + .transform(d => ({ + scope: d.scope, + initialManagePrincipal: d.initial_manage_principal, + scopeBackendType: d.scope_backend_type, + backendAzureKeyvault: d.backend_azure_keyvault, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateScope_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteAclSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + principal: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + principal: d.principal, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeleteAcl_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteScopeSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeleteScope_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteSecretSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + key: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + key: d.key, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeleteSecret_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalGetAclSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + principal: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + principal: d.principal, + })); + +export const unmarshalGetSecretSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + key: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + key: d.key, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetSecret_ResponseSchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalListAclsSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListAcls_ResponseSchema: z.ZodType = z + .object({ + items: z.array(z.lazy(() => unmarshalAclItemSchema)).optional(), + }) + .transform(d => ({ + items: d.items, + })); + +export const unmarshalListScopesSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListScopes_ResponseSchema: z.ZodType = z + .object({ + scopes: z.array(z.lazy(() => unmarshalSecretScopeSchema)).optional(), + }) + .transform(d => ({ + scopes: d.scopes, + })); + +export const unmarshalListSecretsSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListSecrets_ResponseSchema: z.ZodType = z + .object({ + secrets: z.array(z.lazy(() => unmarshalSecretMetadataSchema)).optional(), + }) + .transform(d => ({ + secrets: d.secrets, + })); + +export const unmarshalPutAclSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + principal: z.string().optional(), + permission: z.enum(AclPermission).optional(), + }) + .transform(d => ({ + scope: d.scope, + principal: d.principal, + permission: d.permission, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalPutAcl_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalPutSecretSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + key: z.string().optional(), + string_value: z.string().optional(), + bytes_value: z.string().transform(s => Uint8Array.from(atob(s), c => c.charCodeAt(0))).optional(), + }) + .transform(d => ({ + scope: d.scope, + key: d.key, + stringValue: d.string_value, + bytesValue: d.bytes_value, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalPutSecret_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalSecretMetadataSchema: z.ZodType = z + .object({ + key: z.string().optional(), + last_updated_timestamp: z.number().optional(), + }) + .transform(d => ({ + key: d.key, + lastUpdatedTimestamp: d.last_updated_timestamp, + })); + +export const unmarshalSecretScopeSchema: z.ZodType = z + .object({ + name: z.string().optional(), + backend_type: z.enum(ScopeBackendType).optional(), + keyvault_metadata: z.lazy(() => unmarshalAzureKeyVaultSecretScopeMetadataSchema).optional(), + }) + .transform(d => ({ + name: d.name, + backendType: d.backend_type, + keyvaultMetadata: d.keyvault_metadata, + })); + +export const marshalAclItemSchema: z.ZodType = z + .object({ + principal: z.string().optional(), + permission: z.enum(AclPermission).optional(), + }) + .transform(d => ({ + principal: d.principal, + permission: d.permission, + })); + +export const marshalAzureKeyVaultSecretScopeMetadataSchema: z.ZodType = z + .object({ + resourceId: z.string().optional(), + dnsName: z.string().optional(), + }) + .transform(d => ({ + resource_id: d.resourceId, + dns_name: d.dnsName, + })); + +export const marshalCreateScopeSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + initialManagePrincipal: z.string().optional(), + scopeBackendType: z.enum(ScopeBackendType).optional(), + backendAzureKeyvault: z.lazy(() => marshalAzureKeyVaultSecretScopeMetadataSchema).optional(), + }) + .transform(d => ({ + scope: d.scope, + initial_manage_principal: d.initialManagePrincipal, + scope_backend_type: d.scopeBackendType, + backend_azure_keyvault: d.backendAzureKeyvault, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreateScope_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalDeleteAclSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + principal: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + principal: d.principal, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeleteAcl_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalDeleteScopeSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeleteScope_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalDeleteSecretSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + key: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + key: d.key, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeleteSecret_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalGetAclSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + principal: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + principal: d.principal, + })); + +export const marshalGetSecretSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + key: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + key: d.key, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetSecret_ResponseSchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const marshalListAclsSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListAcls_ResponseSchema: z.ZodType = z + .object({ + items: z.array(z.lazy(() => marshalAclItemSchema)).optional(), + }) + .transform(d => ({ + items: d.items, + })); + +export const marshalListScopesSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListScopes_ResponseSchema: z.ZodType = z + .object({ + scopes: z.array(z.lazy(() => marshalSecretScopeSchema)).optional(), + }) + .transform(d => ({ + scopes: d.scopes, + })); + +export const marshalListSecretsSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + }) + .transform(d => ({ + scope: d.scope, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListSecrets_ResponseSchema: z.ZodType = z + .object({ + secrets: z.array(z.lazy(() => marshalSecretMetadataSchema)).optional(), + }) + .transform(d => ({ + secrets: d.secrets, + })); + +export const marshalPutAclSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + principal: z.string().optional(), + permission: z.enum(AclPermission).optional(), + }) + .transform(d => ({ + scope: d.scope, + principal: d.principal, + permission: d.permission, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalPutAcl_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalPutSecretSchema: z.ZodType = z + .object({ + scope: z.string().optional(), + key: z.string().optional(), + stringValue: z.string().optional(), + bytesValue: z.any().transform((d: Uint8Array) => btoa(Array.from(d, b => String.fromCharCode(b)).join(''))).optional(), + }) + .transform(d => ({ + scope: d.scope, + key: d.key, + string_value: d.stringValue, + bytes_value: d.bytesValue, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalPutSecret_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalSecretMetadataSchema: z.ZodType = z + .object({ + key: z.string().optional(), + lastUpdatedTimestamp: z.number().optional(), + }) + .transform(d => ({ + key: d.key, + last_updated_timestamp: d.lastUpdatedTimestamp, + })); + +export const marshalSecretScopeSchema: z.ZodType = z + .object({ + name: z.string().optional(), + backendType: z.enum(ScopeBackendType).optional(), + keyvaultMetadata: z.lazy(() => marshalAzureKeyVaultSecretScopeMetadataSchema).optional(), + }) + .transform(d => ({ + name: d.name, + backend_type: d.backendType, + keyvault_metadata: d.keyvaultMetadata, + })); diff --git a/packages/secrets/src/v1/utils.ts b/packages/secrets/src/v1/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/secrets/src/v1/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/secrets/tsconfig.json b/packages/secrets/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/secrets/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/serviceprincipalsecrets/package.json b/packages/serviceprincipalsecrets/package.json index f4e58946..3c7d6d3c 100644 --- a/packages/serviceprincipalsecrets/package.json +++ b/packages/serviceprincipalsecrets/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/serviceprincipalsecrets/src/v1/client.ts b/packages/serviceprincipalsecrets/src/v1/client.ts index 72de506a..0d2cf571 100644 --- a/packages/serviceprincipalsecrets/src/v1/client.ts +++ b/packages/serviceprincipalsecrets/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateServicePrincipalSecret, CreateServicePrincipalSecretResponse, @@ -44,25 +39,14 @@ export class Client { } /** Create a secret for the given service principal. */ - async createServicePrincipalSecret( - signal: AbortSignal | undefined, - req: CreateServicePrincipalSecret, - options?: Options - ): Promise { + async createServicePrincipalSecret(signal: AbortSignal | undefined, req: CreateServicePrincipalSecret, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//servicePrincipals/${req.servicePrincipal ?? ''}/credentials/secrets`; const body = marshalRequest(req, marshalCreateServicePrincipalSecretSchema); let resp: CreateServicePrincipalSecretResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalCreateServicePrincipalSecretResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateServicePrincipalSecretResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -72,11 +56,7 @@ export class Client { } /** Delete a secret from the given service principal. */ - async deleteServicePrincipalSecret( - signal: AbortSignal | undefined, - req: DeleteServicePrincipalSecret, - options?: Options - ): Promise { + async deleteServicePrincipalSecret(signal: AbortSignal | undefined, req: DeleteServicePrincipalSecret, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//servicePrincipals/${req.servicePrincipal ?? ''}/credentials/secrets/${req.secretId ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -87,15 +67,8 @@ export class Client { let resp: DeleteServicePrincipalSecret_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteServicePrincipalSecret_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteServicePrincipalSecret_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -105,11 +78,7 @@ export class Client { } /** List all secrets associated with the given service principal. This operation only returns information about the secrets themselves and does not include the secret values. */ - async listServicePrincipalSecrets( - signal: AbortSignal | undefined, - req: ListServicePrincipalSecrets, - options?: Options - ): Promise { + async listServicePrincipalSecrets(signal: AbortSignal | undefined, req: ListServicePrincipalSecrets, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//servicePrincipals/${req.servicePrincipal ?? ''}/credentials/secrets`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -126,15 +95,8 @@ export class Client { let resp: ListServicePrincipalSecrets_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListServicePrincipalSecrets_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListServicePrincipalSecrets_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -143,18 +105,11 @@ export class Client { return resp; } - async *listServicePrincipalSecretsIter( - signal: AbortSignal | undefined, - req: ListServicePrincipalSecrets, - options?: Options - ): AsyncGenerator { + + async *listServicePrincipalSecretsIter(signal: AbortSignal | undefined, req: ListServicePrincipalSecrets, options?: Options): AsyncGenerator { const pageReq: ListServicePrincipalSecrets = {...req}; for (;;) { - const resp = await this.listServicePrincipalSecrets( - signal, - pageReq, - options - ); + const resp = await this.listServicePrincipalSecrets(signal, pageReq, options); for (const item of resp.secrets ?? []) { yield item; } @@ -164,4 +119,5 @@ export class Client { pageReq.pageToken = resp.nextPageToken; } } + } diff --git a/packages/serviceprincipalsecrets/src/v1/index.ts b/packages/serviceprincipalsecrets/src/v1/index.ts index 710bc5b2..ffd4602d 100644 --- a/packages/serviceprincipalsecrets/src/v1/index.ts +++ b/packages/serviceprincipalsecrets/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { CreateServicePrincipalSecret, diff --git a/packages/serviceprincipalsecrets/src/v1/model.ts b/packages/serviceprincipalsecrets/src/v1/model.ts index 2fae16a3..6ac57970 100644 --- a/packages/serviceprincipalsecrets/src/v1/model.ts +++ b/packages/serviceprincipalsecrets/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; import {z} from 'zod'; @@ -80,124 +81,105 @@ export interface ServicePrincipalSecret { expireTime?: Temporal.Instant | undefined; } -export const unmarshalCreateServicePrincipalSecretSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z.string().optional(), - lifetime: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - lifetime: d.lifetime, - })); +export const unmarshalCreateServicePrincipalSecretSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + service_principal: z.string().optional(), + lifetime: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + servicePrincipal: d.service_principal, + lifetime: d.lifetime, + })); -export const unmarshalCreateServicePrincipalSecretResponseSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - secret: z.string().optional(), - secret_hash: z.string().optional(), - create_time: z.string().optional(), - update_time: z.string().optional(), - status: z.string().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - id: d.id, - secret: d.secret, - secretHash: d.secret_hash, - createTime: d.create_time, - updateTime: d.update_time, - status: d.status, - expireTime: d.expire_time, - })); +export const unmarshalCreateServicePrincipalSecretResponseSchema: z.ZodType = z + .object({ + id: z.string().optional(), + secret: z.string().optional(), + secret_hash: z.string().optional(), + create_time: z.string().optional(), + update_time: z.string().optional(), + status: z.string().optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + id: d.id, + secret: d.secret, + secretHash: d.secret_hash, + createTime: d.create_time, + updateTime: d.update_time, + status: d.status, + expireTime: d.expire_time, + })); -export const unmarshalDeleteServicePrincipalSecretSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z.string().optional(), - secret_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - secretId: d.secret_id, - })); +export const unmarshalDeleteServicePrincipalSecretSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + service_principal: z.string().optional(), + secret_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + servicePrincipal: d.service_principal, + secretId: d.secret_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = z + .object({ + }); -export const unmarshalListServicePrincipalSecretsSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - pageToken: d.page_token, - pageSize: d.page_size, - })); +export const unmarshalListServicePrincipalSecretsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + service_principal: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + servicePrincipal: d.service_principal, + pageToken: d.page_token, + pageSize: d.page_size, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListServicePrincipalSecrets_ResponseSchema: z.ZodType = - z - .object({ - secrets: z - .array(z.lazy(() => unmarshalServicePrincipalSecretSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - secrets: d.secrets, - nextPageToken: d.next_page_token, - })); +export const unmarshalListServicePrincipalSecrets_ResponseSchema: z.ZodType = z + .object({ + secrets: z.array(z.lazy(() => unmarshalServicePrincipalSecretSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + secrets: d.secrets, + nextPageToken: d.next_page_token, + })); -export const unmarshalServicePrincipalSecretSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - secret: z.string().optional(), - secret_hash: z.string().optional(), - create_time: z.string().optional(), - update_time: z.string().optional(), - status: z.string().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - id: d.id, - secret: d.secret, - secretHash: d.secret_hash, - createTime: d.create_time, - updateTime: d.update_time, - status: d.status, - expireTime: d.expire_time, - })); +export const unmarshalServicePrincipalSecretSchema: z.ZodType = z + .object({ + id: z.string().optional(), + secret: z.string().optional(), + secret_hash: z.string().optional(), + create_time: z.string().optional(), + update_time: z.string().optional(), + status: z.string().optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + id: d.id, + secret: d.secret, + secretHash: d.secret_hash, + createTime: d.create_time, + updateTime: d.update_time, + status: d.status, + expireTime: d.expire_time, + })); export const marshalCreateServicePrincipalSecretSchema: z.ZodType = z .object({ accountId: z.string().optional(), servicePrincipal: z.string().optional(), - lifetime: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + lifetime: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -213,10 +195,7 @@ export const marshalCreateServicePrincipalSecretResponseSchema: z.ZodType = z createTime: z.string().optional(), updateTime: z.string().optional(), status: z.string().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ id: d.id, @@ -241,8 +220,9 @@ export const marshalDeleteServicePrincipalSecretSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalListServicePrincipalSecretsSchema: z.ZodType = z .object({ @@ -261,9 +241,7 @@ export const marshalListServicePrincipalSecretsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListServicePrincipalSecrets_ResponseSchema: z.ZodType = z .object({ - secrets: z - .array(z.lazy(() => marshalServicePrincipalSecretSchema)) - .optional(), + secrets: z.array(z.lazy(() => marshalServicePrincipalSecretSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -279,10 +257,7 @@ export const marshalServicePrincipalSecretSchema: z.ZodType = z createTime: z.string().optional(), updateTime: z.string().optional(), status: z.string().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ id: d.id, diff --git a/packages/serviceprincipalsecrets/src/v1/utils.ts b/packages/serviceprincipalsecrets/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/serviceprincipalsecrets/src/v1/utils.ts +++ b/packages/serviceprincipalsecrets/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/serviceprincipalsecrets/tsconfig.json b/packages/serviceprincipalsecrets/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/serviceprincipalsecrets/tsconfig.json +++ b/packages/serviceprincipalsecrets/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/serviceprincipalsecretsproxy/package.json b/packages/serviceprincipalsecretsproxy/package.json index 48fd4711..5385beef 100644 --- a/packages/serviceprincipalsecretsproxy/package.json +++ b/packages/serviceprincipalsecretsproxy/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/serviceprincipalsecretsproxy/src/v1/client.ts b/packages/serviceprincipalsecretsproxy/src/v1/client.ts index 72de506a..0d2cf571 100644 --- a/packages/serviceprincipalsecretsproxy/src/v1/client.ts +++ b/packages/serviceprincipalsecretsproxy/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateServicePrincipalSecret, CreateServicePrincipalSecretResponse, @@ -44,25 +39,14 @@ export class Client { } /** Create a secret for the given service principal. */ - async createServicePrincipalSecret( - signal: AbortSignal | undefined, - req: CreateServicePrincipalSecret, - options?: Options - ): Promise { + async createServicePrincipalSecret(signal: AbortSignal | undefined, req: CreateServicePrincipalSecret, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//servicePrincipals/${req.servicePrincipal ?? ''}/credentials/secrets`; const body = marshalRequest(req, marshalCreateServicePrincipalSecretSchema); let resp: CreateServicePrincipalSecretResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalCreateServicePrincipalSecretResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateServicePrincipalSecretResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -72,11 +56,7 @@ export class Client { } /** Delete a secret from the given service principal. */ - async deleteServicePrincipalSecret( - signal: AbortSignal | undefined, - req: DeleteServicePrincipalSecret, - options?: Options - ): Promise { + async deleteServicePrincipalSecret(signal: AbortSignal | undefined, req: DeleteServicePrincipalSecret, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//servicePrincipals/${req.servicePrincipal ?? ''}/credentials/secrets/${req.secretId ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -87,15 +67,8 @@ export class Client { let resp: DeleteServicePrincipalSecret_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteServicePrincipalSecret_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteServicePrincipalSecret_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -105,11 +78,7 @@ export class Client { } /** List all secrets associated with the given service principal. This operation only returns information about the secrets themselves and does not include the secret values. */ - async listServicePrincipalSecrets( - signal: AbortSignal | undefined, - req: ListServicePrincipalSecrets, - options?: Options - ): Promise { + async listServicePrincipalSecrets(signal: AbortSignal | undefined, req: ListServicePrincipalSecrets, options?: Options): Promise { const url = `${this.host}/api/2.0/accounts//servicePrincipals/${req.servicePrincipal ?? ''}/credentials/secrets`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -126,15 +95,8 @@ export class Client { let resp: ListServicePrincipalSecrets_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListServicePrincipalSecrets_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListServicePrincipalSecrets_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -143,18 +105,11 @@ export class Client { return resp; } - async *listServicePrincipalSecretsIter( - signal: AbortSignal | undefined, - req: ListServicePrincipalSecrets, - options?: Options - ): AsyncGenerator { + + async *listServicePrincipalSecretsIter(signal: AbortSignal | undefined, req: ListServicePrincipalSecrets, options?: Options): AsyncGenerator { const pageReq: ListServicePrincipalSecrets = {...req}; for (;;) { - const resp = await this.listServicePrincipalSecrets( - signal, - pageReq, - options - ); + const resp = await this.listServicePrincipalSecrets(signal, pageReq, options); for (const item of resp.secrets ?? []) { yield item; } @@ -164,4 +119,5 @@ export class Client { pageReq.pageToken = resp.nextPageToken; } } + } diff --git a/packages/serviceprincipalsecretsproxy/src/v1/index.ts b/packages/serviceprincipalsecretsproxy/src/v1/index.ts index 710bc5b2..ffd4602d 100644 --- a/packages/serviceprincipalsecretsproxy/src/v1/index.ts +++ b/packages/serviceprincipalsecretsproxy/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { CreateServicePrincipalSecret, diff --git a/packages/serviceprincipalsecretsproxy/src/v1/model.ts b/packages/serviceprincipalsecretsproxy/src/v1/model.ts index 2fae16a3..6ac57970 100644 --- a/packages/serviceprincipalsecretsproxy/src/v1/model.ts +++ b/packages/serviceprincipalsecretsproxy/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; import {z} from 'zod'; @@ -80,124 +81,105 @@ export interface ServicePrincipalSecret { expireTime?: Temporal.Instant | undefined; } -export const unmarshalCreateServicePrincipalSecretSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z.string().optional(), - lifetime: z - .string() - .transform(s => Temporal.Duration.from('PT' + s.toUpperCase())) - .optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - lifetime: d.lifetime, - })); +export const unmarshalCreateServicePrincipalSecretSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + service_principal: z.string().optional(), + lifetime: z.string().transform(s => Temporal.Duration.from('PT' + s.toUpperCase())).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + servicePrincipal: d.service_principal, + lifetime: d.lifetime, + })); -export const unmarshalCreateServicePrincipalSecretResponseSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - secret: z.string().optional(), - secret_hash: z.string().optional(), - create_time: z.string().optional(), - update_time: z.string().optional(), - status: z.string().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - id: d.id, - secret: d.secret, - secretHash: d.secret_hash, - createTime: d.create_time, - updateTime: d.update_time, - status: d.status, - expireTime: d.expire_time, - })); +export const unmarshalCreateServicePrincipalSecretResponseSchema: z.ZodType = z + .object({ + id: z.string().optional(), + secret: z.string().optional(), + secret_hash: z.string().optional(), + create_time: z.string().optional(), + update_time: z.string().optional(), + status: z.string().optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + id: d.id, + secret: d.secret, + secretHash: d.secret_hash, + createTime: d.create_time, + updateTime: d.update_time, + status: d.status, + expireTime: d.expire_time, + })); -export const unmarshalDeleteServicePrincipalSecretSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z.string().optional(), - secret_id: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - secretId: d.secret_id, - })); +export const unmarshalDeleteServicePrincipalSecretSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + service_principal: z.string().optional(), + secret_id: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + servicePrincipal: d.service_principal, + secretId: d.secret_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = z + .object({ + }); -export const unmarshalListServicePrincipalSecretsSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - service_principal: z.string().optional(), - page_token: z.string().optional(), - page_size: z.number().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - servicePrincipal: d.service_principal, - pageToken: d.page_token, - pageSize: d.page_size, - })); +export const unmarshalListServicePrincipalSecretsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + service_principal: z.string().optional(), + page_token: z.string().optional(), + page_size: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + servicePrincipal: d.service_principal, + pageToken: d.page_token, + pageSize: d.page_size, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListServicePrincipalSecrets_ResponseSchema: z.ZodType = - z - .object({ - secrets: z - .array(z.lazy(() => unmarshalServicePrincipalSecretSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - secrets: d.secrets, - nextPageToken: d.next_page_token, - })); +export const unmarshalListServicePrincipalSecrets_ResponseSchema: z.ZodType = z + .object({ + secrets: z.array(z.lazy(() => unmarshalServicePrincipalSecretSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + secrets: d.secrets, + nextPageToken: d.next_page_token, + })); -export const unmarshalServicePrincipalSecretSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - secret: z.string().optional(), - secret_hash: z.string().optional(), - create_time: z.string().optional(), - update_time: z.string().optional(), - status: z.string().optional(), - expire_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - }) - .transform(d => ({ - id: d.id, - secret: d.secret, - secretHash: d.secret_hash, - createTime: d.create_time, - updateTime: d.update_time, - status: d.status, - expireTime: d.expire_time, - })); +export const unmarshalServicePrincipalSecretSchema: z.ZodType = z + .object({ + id: z.string().optional(), + secret: z.string().optional(), + secret_hash: z.string().optional(), + create_time: z.string().optional(), + update_time: z.string().optional(), + status: z.string().optional(), + expire_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + }) + .transform(d => ({ + id: d.id, + secret: d.secret, + secretHash: d.secret_hash, + createTime: d.create_time, + updateTime: d.update_time, + status: d.status, + expireTime: d.expire_time, + })); export const marshalCreateServicePrincipalSecretSchema: z.ZodType = z .object({ accountId: z.string().optional(), servicePrincipal: z.string().optional(), - lifetime: z - .any() - .transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()) - .optional(), + lifetime: z.any().transform((d: Temporal.Duration) => d.toString().slice(2).toLowerCase()).optional(), }) .transform(d => ({ account_id: d.accountId, @@ -213,10 +195,7 @@ export const marshalCreateServicePrincipalSecretResponseSchema: z.ZodType = z createTime: z.string().optional(), updateTime: z.string().optional(), status: z.string().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ id: d.id, @@ -241,8 +220,9 @@ export const marshalDeleteServicePrincipalSecretSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = - z.object({}); +export const marshalDeleteServicePrincipalSecret_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalListServicePrincipalSecretsSchema: z.ZodType = z .object({ @@ -261,9 +241,7 @@ export const marshalListServicePrincipalSecretsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalListServicePrincipalSecrets_ResponseSchema: z.ZodType = z .object({ - secrets: z - .array(z.lazy(() => marshalServicePrincipalSecretSchema)) - .optional(), + secrets: z.array(z.lazy(() => marshalServicePrincipalSecretSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -279,10 +257,7 @@ export const marshalServicePrincipalSecretSchema: z.ZodType = z createTime: z.string().optional(), updateTime: z.string().optional(), status: z.string().optional(), - expireTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + expireTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), }) .transform(d => ({ id: d.id, diff --git a/packages/serviceprincipalsecretsproxy/src/v1/utils.ts b/packages/serviceprincipalsecretsproxy/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/serviceprincipalsecretsproxy/src/v1/utils.ts +++ b/packages/serviceprincipalsecretsproxy/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/serviceprincipalsecretsproxy/tsconfig.json b/packages/serviceprincipalsecretsproxy/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/serviceprincipalsecretsproxy/tsconfig.json +++ b/packages/serviceprincipalsecretsproxy/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/settings/package.json b/packages/settings/package.json index c6785d75..9586ffc9 100644 --- a/packages/settings/package.json +++ b/packages/settings/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/settings/src/v2/client.ts b/packages/settings/src/v2/client.ts index d82e7c2b..f172d731 100644 --- a/packages/settings/src/v2/client.ts +++ b/packages/settings/src/v2/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { GetPublicAccountSettingRequest, GetPublicAccountUserPreferenceRequest, @@ -55,11 +50,7 @@ export class Client { } /** Get a setting value at account level. See :method:settingsv2/listaccountsettingsmetadata for list of setting available via public APIs at account level. */ - async getPublicAccountSetting( - signal: AbortSignal | undefined, - req: GetPublicAccountSettingRequest, - options?: Options - ): Promise { + async getPublicAccountSetting(signal: AbortSignal | undefined, req: GetPublicAccountSettingRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/accounts//settings/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -70,11 +61,7 @@ export class Client { let resp: Setting | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSettingSchema); }; await execute(signal, call, options); @@ -89,11 +76,7 @@ export class Client { * User preferences are personal settings that allow individual customization without affecting other users. * See :method:settingsv2/listaccountuserpreferencesmetadata for list of user preferences available via public APIs. */ - async getPublicAccountUserPreference( - signal: AbortSignal | undefined, - req: GetPublicAccountUserPreferenceRequest, - options?: Options - ): Promise { + async getPublicAccountUserPreference(signal: AbortSignal | undefined, req: GetPublicAccountUserPreferenceRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/accounts//users/${req.userId ?? ''}/settings/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -104,11 +87,7 @@ export class Client { let resp: UserPreference | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserPreferenceSchema); }; await execute(signal, call, options); @@ -119,20 +98,12 @@ export class Client { } /** Get a setting value at workspace level. See :method:settingsv2/listworkspacesettingsmetadata for list of setting available via public APIs. */ - async getPublicWorkspaceSetting( - signal: AbortSignal | undefined, - req: GetPublicWorkspaceSettingRequest, - options?: Options - ): Promise { + async getPublicWorkspaceSetting(signal: AbortSignal | undefined, req: GetPublicWorkspaceSettingRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/settings/${req.name ?? ''}`; let resp: Setting | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSettingSchema); }; await execute(signal, call, options); @@ -147,11 +118,7 @@ export class Client { * GET :method:settingsv2/getpublicaccountsetting and * PATCH :method:settingsv2/patchpublicaccountsetting APIs */ - async listAccountSettingsMetadata( - signal: AbortSignal | undefined, - req: ListAccountSettingsMetadataRequest, - options?: Options - ): Promise { + async listAccountSettingsMetadata(signal: AbortSignal | undefined, req: ListAccountSettingsMetadataRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/accounts/{account_id}/settings-metadata`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -168,15 +135,8 @@ export class Client { let resp: ListAccountSettingsMetadataResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListAccountSettingsMetadataResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListAccountSettingsMetadataResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -185,18 +145,11 @@ export class Client { return resp; } - async *listAccountSettingsMetadataIter( - signal: AbortSignal | undefined, - req: ListAccountSettingsMetadataRequest, - options?: Options - ): AsyncGenerator { + + async *listAccountSettingsMetadataIter(signal: AbortSignal | undefined, req: ListAccountSettingsMetadataRequest, options?: Options): AsyncGenerator { const pageReq: ListAccountSettingsMetadataRequest = {...req}; for (;;) { - const resp = await this.listAccountSettingsMetadata( - signal, - pageReq, - options - ); + const resp = await this.listAccountSettingsMetadata(signal, pageReq, options); for (const item of resp.settingsMetadata ?? []) { yield item; } @@ -207,6 +160,7 @@ export class Client { } } + /** * List valid user preferences and their metadata for a specific user. * User preferences are personal settings that allow individual customization without affecting other users. @@ -214,11 +168,7 @@ export class Client { * GET :method:settingsv2/getpublicaccountuserpreference and * PATCH :method:settingsv2/patchpublicaccountuserpreference APIs */ - async listAccountUserPreferencesMetadata( - signal: AbortSignal | undefined, - req: ListAccountUserPreferencesMetadataRequest, - options?: Options - ): Promise { + async listAccountUserPreferencesMetadata(signal: AbortSignal | undefined, req: ListAccountUserPreferencesMetadataRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/accounts//users/${req.userId ?? ''}/settings-metadata`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -235,15 +185,8 @@ export class Client { let resp: ListAccountUserPreferencesMetadataResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListAccountUserPreferencesMetadataResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListAccountUserPreferencesMetadataResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -252,18 +195,11 @@ export class Client { return resp; } - async *listAccountUserPreferencesMetadataIter( - signal: AbortSignal | undefined, - req: ListAccountUserPreferencesMetadataRequest, - options?: Options - ): AsyncGenerator { + + async *listAccountUserPreferencesMetadataIter(signal: AbortSignal | undefined, req: ListAccountUserPreferencesMetadataRequest, options?: Options): AsyncGenerator { const pageReq: ListAccountUserPreferencesMetadataRequest = {...req}; for (;;) { - const resp = await this.listAccountUserPreferencesMetadata( - signal, - pageReq, - options - ); + const resp = await this.listAccountUserPreferencesMetadata(signal, pageReq, options); for (const item of resp.settingsMetadata ?? []) { yield item; } @@ -274,16 +210,13 @@ export class Client { } } + /** * List valid setting keys and metadata. These settings are available to be referenced via * GET :method:settingsv2/getpublicworkspacesetting and * PATCH :method:settingsv2/patchpublicworkspacesetting APIs */ - async listWorkspaceSettingsMetadata( - signal: AbortSignal | undefined, - req: ListWorkspaceSettingsMetadataRequest, - options?: Options - ): Promise { + async listWorkspaceSettingsMetadata(signal: AbortSignal | undefined, req: ListWorkspaceSettingsMetadataRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/settings-metadata`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -297,15 +230,8 @@ export class Client { let resp: ListWorkspaceSettingsMetadataResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWorkspaceSettingsMetadataResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspaceSettingsMetadataResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -314,18 +240,11 @@ export class Client { return resp; } - async *listWorkspaceSettingsMetadataIter( - signal: AbortSignal | undefined, - req: ListWorkspaceSettingsMetadataRequest, - options?: Options - ): AsyncGenerator { + + async *listWorkspaceSettingsMetadataIter(signal: AbortSignal | undefined, req: ListWorkspaceSettingsMetadataRequest, options?: Options): AsyncGenerator { const pageReq: ListWorkspaceSettingsMetadataRequest = {...req}; for (;;) { - const resp = await this.listWorkspaceSettingsMetadata( - signal, - pageReq, - options - ); + const resp = await this.listWorkspaceSettingsMetadata(signal, pageReq, options); for (const item of resp.settingsMetadata ?? []) { yield item; } @@ -336,17 +255,14 @@ export class Client { } } + /** * Patch a setting value at account level. See :method:settingsv2/listaccountsettingsmetadata for list of setting available via public APIs at account level. * To determine the correct field to include in a patch request, refer to the type field of the setting returned in the :method:settingsv2/listaccountsettingsmetadata response. - * + * * Note: Page refresh is required for changes to take effect in UI. */ - async patchPublicAccountSetting( - signal: AbortSignal | undefined, - req: PatchPublicAccountSettingRequest, - options?: Options - ): Promise { + async patchPublicAccountSetting(signal: AbortSignal | undefined, req: PatchPublicAccountSettingRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/accounts//settings/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -358,11 +274,7 @@ export class Client { let resp: Setting | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSettingSchema); }; await execute(signal, call, options); @@ -376,14 +288,10 @@ export class Client { * Update a user preference for a specific user. * User preferences are personal settings that allow individual customization without affecting other users. * See :method:settingsv2/listaccountuserpreferencesmetadata for list of user preferences available via public APIs. - * + * * Note: Page refresh is required for changes to take effect in UI. */ - async patchPublicAccountUserPreference( - signal: AbortSignal | undefined, - req: PatchPublicAccountUserPreferenceRequest, - options?: Options - ): Promise { + async patchPublicAccountUserPreference(signal: AbortSignal | undefined, req: PatchPublicAccountUserPreferenceRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/accounts//users/${req.userId ?? ''}/settings/${req.name ?? ''}`; const params = new URLSearchParams(); if (req.accountId !== undefined) { @@ -395,11 +303,7 @@ export class Client { let resp: UserPreference | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUserPreferenceSchema); }; await execute(signal, call, options); @@ -412,24 +316,16 @@ export class Client { /** * Patch a setting value at workspace level. See :method:settingsv2/listworkspacesettingsmetadata for list of setting available via public APIs at workspace level. * To determine the correct field to include in a patch request, refer to the type field of the setting returned in the :method:settingsv2/listworkspacesettingsmetadata response. - * + * * Note: Page refresh is required for changes to take effect in UI. */ - async patchPublicWorkspaceSetting( - signal: AbortSignal | undefined, - req: PatchPublicWorkspaceSettingRequest, - options?: Options - ): Promise { + async patchPublicWorkspaceSetting(signal: AbortSignal | undefined, req: PatchPublicWorkspaceSettingRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/settings/${req.name ?? ''}`; const body = marshalRequest(req.setting, marshalSettingSchema); let resp: Setting | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalSettingSchema); }; await execute(signal, call, options); diff --git a/packages/settings/src/v2/index.ts b/packages/settings/src/v2/index.ts index 74a39d53..cbd4b745 100644 --- a/packages/settings/src/v2/index.ts +++ b/packages/settings/src/v2/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/settings/src/v2/model.ts b/packages/settings/src/v2/model.ts index d9c1c9b5..f71f8fec 100644 --- a/packages/settings/src/v2/model.ts +++ b/packages/settings/src/v2/model.ts @@ -62,9 +62,7 @@ export enum RestrictWorkspaceAdminsMessage_Status { } export interface AibiDashboardEmbeddingAccessPolicy { - accessPolicyType?: - | AibiDashboardEmbeddingAccessPolicy_AccessPolicyType - | undefined; + accessPolicyType?: AibiDashboardEmbeddingAccessPolicy_AccessPolicyType | undefined; } export interface AibiDashboardEmbeddingApprovedDomains { @@ -103,20 +101,14 @@ export interface ClusterAutoRestartMessage_EnablementDetails { // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export interface ClusterAutoRestartMessage_MaintenanceWindow { - weekDayBasedSchedule?: - | ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule - | undefined; + weekDayBasedSchedule?: ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule | undefined; } // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export interface ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule { - frequency?: - | ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency - | undefined; + frequency?: ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency | undefined; dayOfWeek?: ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek | undefined; - windowStartTime?: - | ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime - | undefined; + windowStartTime?: ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime | undefined; } // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. @@ -160,7 +152,7 @@ export interface ListAccountSettingsMetadataRequest { /** * 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. */ @@ -191,7 +183,7 @@ export interface ListAccountUserPreferencesMetadataRequest { /** * 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. */ @@ -218,7 +210,7 @@ export interface ListWorkspaceSettingsMetadataRequest { /** * 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. */ @@ -282,13 +274,9 @@ export interface Setting { /** Setting value for automatic_cluster_update_workspace setting. This is the setting value set by consumers, check effective_automatic_cluster_update_workspace for final setting value. */ automaticClusterUpdateWorkspace?: ClusterAutoRestartMessage | undefined; /** Setting value for aibi_dashboard_embedding_approved_domains setting. This is the setting value set by consumers, check effective_aibi_dashboard_embedding_approved_domains for final setting value. */ - aibiDashboardEmbeddingApprovedDomains?: - | AibiDashboardEmbeddingApprovedDomains - | undefined; + aibiDashboardEmbeddingApprovedDomains?: AibiDashboardEmbeddingApprovedDomains | undefined; /** Setting value for aibi_dashboard_embedding_access_policy setting. This is the setting value set by consumers, check effective_aibi_dashboard_embedding_access_policy for final setting value. */ - aibiDashboardEmbeddingAccessPolicy?: - | AibiDashboardEmbeddingAccessPolicy - | undefined; + aibiDashboardEmbeddingAccessPolicy?: AibiDashboardEmbeddingAccessPolicy | undefined; /** Setting value for restrict_workspace_admins setting. This is the setting value set by consumers, check effective_restrict_workspace_admins for final setting value. */ restrictWorkspaceAdmins?: RestrictWorkspaceAdminsMessage | undefined; /** Setting value for personal_compute setting. This is the setting value set by consumers, check effective_personal_compute for final setting value. */ @@ -300,17 +288,11 @@ export interface Setting { /** Effective setting value for integer type setting. This is the final effective value of setting. To set a value use integer_val. */ effectiveIntegerVal?: IntegerMessage | undefined; /** Effective setting value for automatic_cluster_update_workspace setting. This is the final effective value of setting. To set a value use automatic_cluster_update_workspace. */ - effectiveAutomaticClusterUpdateWorkspace?: - | ClusterAutoRestartMessage - | undefined; + effectiveAutomaticClusterUpdateWorkspace?: ClusterAutoRestartMessage | undefined; /** Effective setting value for aibi_dashboard_embedding_approved_domains setting. This is the final effective value of setting. To set a value use aibi_dashboard_embedding_approved_domains. */ - effectiveAibiDashboardEmbeddingApprovedDomains?: - | AibiDashboardEmbeddingApprovedDomains - | undefined; + effectiveAibiDashboardEmbeddingApprovedDomains?: AibiDashboardEmbeddingApprovedDomains | undefined; /** Effective setting value for aibi_dashboard_embedding_access_policy setting. This is the final effective value of setting. To set a value use aibi_dashboard_embedding_access_policy. */ - effectiveAibiDashboardEmbeddingAccessPolicy?: - | AibiDashboardEmbeddingAccessPolicy - | undefined; + effectiveAibiDashboardEmbeddingAccessPolicy?: AibiDashboardEmbeddingAccessPolicy | undefined; /** Effective setting value for restrict_workspace_admins setting. This is the final effective value of setting. To set a value use restrict_workspace_admins. */ effectiveRestrictWorkspaceAdmins?: RestrictWorkspaceAdminsMessage | undefined; /** Effective setting value for personal_compute setting. This is the final effective value of setting. To set a value use personal_compute. */ @@ -349,25 +331,21 @@ export interface UserPreference { effectiveStringVal?: StringMessage | undefined; } -export const unmarshalAibiDashboardEmbeddingAccessPolicySchema: z.ZodType = - z - .object({ - access_policy_type: z - .enum(AibiDashboardEmbeddingAccessPolicy_AccessPolicyType) - .optional(), - }) - .transform(d => ({ - accessPolicyType: d.access_policy_type, - })); - -export const unmarshalAibiDashboardEmbeddingApprovedDomainsSchema: z.ZodType = - z - .object({ - approved_domains: z.array(z.string()).optional(), - }) - .transform(d => ({ - approvedDomains: d.approved_domains, - })); +export const unmarshalAibiDashboardEmbeddingAccessPolicySchema: z.ZodType = z + .object({ + access_policy_type: z.enum(AibiDashboardEmbeddingAccessPolicy_AccessPolicyType).optional(), + }) + .transform(d => ({ + accessPolicyType: d.access_policy_type, + })); + +export const unmarshalAibiDashboardEmbeddingApprovedDomainsSchema: z.ZodType = z + .object({ + approved_domains: z.array(z.string()).optional(), + }) + .transform(d => ({ + approvedDomains: d.approved_domains, + })); export const unmarshalBooleanMessageSchema: z.ZodType = z .object({ @@ -377,123 +355,97 @@ export const unmarshalBooleanMessageSchema: z.ZodType = z value: d.value, })); -export const unmarshalClusterAutoRestartMessageSchema: z.ZodType = - z - .object({ - enabled: z.boolean().optional(), - can_toggle: z.boolean().optional(), - maintenance_window: z - .lazy(() => unmarshalClusterAutoRestartMessage_MaintenanceWindowSchema) - .optional(), - enablement_details: z - .lazy(() => unmarshalClusterAutoRestartMessage_EnablementDetailsSchema) - .optional(), - restart_even_if_no_updates_available: z.boolean().optional(), - }) - .transform(d => ({ - enabled: d.enabled, - canToggle: d.can_toggle, - maintenanceWindow: d.maintenance_window, - enablementDetails: d.enablement_details, - restartEvenIfNoUpdatesAvailable: d.restart_even_if_no_updates_available, - })); +export const unmarshalClusterAutoRestartMessageSchema: z.ZodType = z + .object({ + enabled: z.boolean().optional(), + can_toggle: z.boolean().optional(), + maintenance_window: z.lazy(() => unmarshalClusterAutoRestartMessage_MaintenanceWindowSchema).optional(), + enablement_details: z.lazy(() => unmarshalClusterAutoRestartMessage_EnablementDetailsSchema).optional(), + restart_even_if_no_updates_available: z.boolean().optional(), + }) + .transform(d => ({ + enabled: d.enabled, + canToggle: d.can_toggle, + maintenanceWindow: d.maintenance_window, + enablementDetails: d.enablement_details, + restartEvenIfNoUpdatesAvailable: d.restart_even_if_no_updates_available, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalClusterAutoRestartMessage_EnablementDetailsSchema: z.ZodType = - z - .object({ - unavailable_for_non_enterprise_tier: z.boolean().optional(), - unavailable_for_disabled_entitlement: z.boolean().optional(), - forced_for_compliance_mode: z.boolean().optional(), - }) - .transform(d => ({ - unavailableForNonEnterpriseTier: d.unavailable_for_non_enterprise_tier, - unavailableForDisabledEntitlement: d.unavailable_for_disabled_entitlement, - forcedForComplianceMode: d.forced_for_compliance_mode, - })); +export const unmarshalClusterAutoRestartMessage_EnablementDetailsSchema: z.ZodType = z + .object({ + unavailable_for_non_enterprise_tier: z.boolean().optional(), + unavailable_for_disabled_entitlement: z.boolean().optional(), + forced_for_compliance_mode: z.boolean().optional(), + }) + .transform(d => ({ + unavailableForNonEnterpriseTier: d.unavailable_for_non_enterprise_tier, + unavailableForDisabledEntitlement: d.unavailable_for_disabled_entitlement, + forcedForComplianceMode: d.forced_for_compliance_mode, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalClusterAutoRestartMessage_MaintenanceWindowSchema: z.ZodType = - z - .object({ - week_day_based_schedule: z - .lazy( - () => - unmarshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema - ) - .optional(), - }) - .transform(d => ({ - weekDayBasedSchedule: d.week_day_based_schedule, - })); +export const unmarshalClusterAutoRestartMessage_MaintenanceWindowSchema: z.ZodType = z + .object({ + week_day_based_schedule: z.lazy(() => unmarshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema).optional(), + }) + .transform(d => ({ + weekDayBasedSchedule: d.week_day_based_schedule, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema: z.ZodType = - z - .object({ - frequency: z - .enum(ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency) - .optional(), - day_of_week: z - .enum(ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek) - .optional(), - window_start_time: z - .lazy( - () => - unmarshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema - ) - .optional(), - }) - .transform(d => ({ - frequency: d.frequency, - dayOfWeek: d.day_of_week, - windowStartTime: d.window_start_time, - })); +export const unmarshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema: z.ZodType = z + .object({ + frequency: z.enum(ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency).optional(), + day_of_week: z.enum(ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek).optional(), + window_start_time: z.lazy(() => unmarshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema).optional(), + }) + .transform(d => ({ + frequency: d.frequency, + dayOfWeek: d.day_of_week, + windowStartTime: d.window_start_time, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema: z.ZodType = - z - .object({ - hours: z.number().optional(), - minutes: z.number().optional(), - }) - .transform(d => ({ - hours: d.hours, - minutes: d.minutes, - })); - -export const unmarshalGetPublicAccountSettingRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - name: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - name: d.name, - })); - -export const unmarshalGetPublicAccountUserPreferenceRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - user_id: z.string().optional(), - name: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - userId: d.user_id, - name: d.name, - })); - -export const unmarshalGetPublicWorkspaceSettingRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema: z.ZodType = z + .object({ + hours: z.number().optional(), + minutes: z.number().optional(), + }) + .transform(d => ({ + hours: d.hours, + minutes: d.minutes, + })); + +export const unmarshalGetPublicAccountSettingRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + name: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + name: d.name, + })); + +export const unmarshalGetPublicAccountUserPreferenceRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + user_id: z.string().optional(), + name: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + userId: d.user_id, + name: d.name, + })); + +export const unmarshalGetPublicWorkspaceSettingRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const unmarshalIntegerMessageSchema: z.ZodType = z .object({ @@ -503,144 +455,125 @@ export const unmarshalIntegerMessageSchema: z.ZodType = z value: d.value, })); -export const unmarshalListAccountSettingsMetadataRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListAccountSettingsMetadataResponseSchema: z.ZodType = - z - .object({ - settings_metadata: z - .array(z.lazy(() => unmarshalSettingsMetadataSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - settingsMetadata: d.settings_metadata, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListAccountUserPreferencesMetadataRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - user_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - accountId: d.account_id, - userId: d.user_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListAccountUserPreferencesMetadataResponseSchema: z.ZodType = - z - .object({ - settings_metadata: z - .array(z.lazy(() => unmarshalSettingsMetadataSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - settingsMetadata: d.settings_metadata, - nextPageToken: d.next_page_token, - })); - -export const unmarshalListWorkspaceSettingsMetadataRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListWorkspaceSettingsMetadataResponseSchema: z.ZodType = - z - .object({ - settings_metadata: z - .array(z.lazy(() => unmarshalSettingsMetadataSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - settingsMetadata: d.settings_metadata, - nextPageToken: d.next_page_token, - })); - -export const unmarshalPatchPublicAccountSettingRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - name: z.string().optional(), - setting: z.lazy(() => unmarshalSettingSchema).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - name: d.name, - setting: d.setting, - })); - -export const unmarshalPatchPublicAccountUserPreferenceRequestSchema: z.ZodType = - z - .object({ - account_id: z.string().optional(), - user_id: z.string().optional(), - name: z.string().optional(), - setting: z.lazy(() => unmarshalUserPreferenceSchema).optional(), - }) - .transform(d => ({ - accountId: d.account_id, - userId: d.user_id, - name: d.name, - setting: d.setting, - })); - -export const unmarshalPatchPublicWorkspaceSettingRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - setting: z.lazy(() => unmarshalSettingSchema).optional(), - }) - .transform(d => ({ - name: d.name, - setting: d.setting, - })); - -export const unmarshalPersonalComputeMessageSchema: z.ZodType = - z - .object({ - value: z - .enum(PersonalComputeMessage_PersonalComputeMessageEnum) - .optional(), - }) - .transform(d => ({ - value: d.value, - })); - -export const unmarshalRestrictWorkspaceAdminsMessageSchema: z.ZodType = - z - .object({ - status: z.enum(RestrictWorkspaceAdminsMessage_Status).optional(), - disable_gov_tag_creation: z.boolean().optional(), - }) - .transform(d => ({ - status: d.status, - disableGovTagCreation: d.disable_gov_tag_creation, - })); +export const unmarshalListAccountSettingsMetadataRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListAccountSettingsMetadataResponseSchema: z.ZodType = z + .object({ + settings_metadata: z.array(z.lazy(() => unmarshalSettingsMetadataSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + settingsMetadata: d.settings_metadata, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListAccountUserPreferencesMetadataRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + user_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + userId: d.user_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListAccountUserPreferencesMetadataResponseSchema: z.ZodType = z + .object({ + settings_metadata: z.array(z.lazy(() => unmarshalSettingsMetadataSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + settingsMetadata: d.settings_metadata, + nextPageToken: d.next_page_token, + })); + +export const unmarshalListWorkspaceSettingsMetadataRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListWorkspaceSettingsMetadataResponseSchema: z.ZodType = z + .object({ + settings_metadata: z.array(z.lazy(() => unmarshalSettingsMetadataSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + settingsMetadata: d.settings_metadata, + nextPageToken: d.next_page_token, + })); + +export const unmarshalPatchPublicAccountSettingRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + name: z.string().optional(), + setting: z.lazy(() => unmarshalSettingSchema).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + name: d.name, + setting: d.setting, + })); + +export const unmarshalPatchPublicAccountUserPreferenceRequestSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + user_id: z.string().optional(), + name: z.string().optional(), + setting: z.lazy(() => unmarshalUserPreferenceSchema).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + userId: d.user_id, + name: d.name, + setting: d.setting, + })); + +export const unmarshalPatchPublicWorkspaceSettingRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + setting: z.lazy(() => unmarshalSettingSchema).optional(), + }) + .transform(d => ({ + name: d.name, + setting: d.setting, + })); + +export const unmarshalPersonalComputeMessageSchema: z.ZodType = z + .object({ + value: z.enum(PersonalComputeMessage_PersonalComputeMessageEnum).optional(), + }) + .transform(d => ({ + value: d.value, + })); + +export const unmarshalRestrictWorkspaceAdminsMessageSchema: z.ZodType = z + .object({ + status: z.enum(RestrictWorkspaceAdminsMessage_Status).optional(), + disable_gov_tag_creation: z.boolean().optional(), + }) + .transform(d => ({ + status: d.status, + disableGovTagCreation: d.disable_gov_tag_creation, + })); export const unmarshalSettingSchema: z.ZodType = z .object({ @@ -648,43 +581,19 @@ export const unmarshalSettingSchema: z.ZodType = z boolean_val: z.lazy(() => unmarshalBooleanMessageSchema).optional(), string_val: z.lazy(() => unmarshalStringMessageSchema).optional(), integer_val: z.lazy(() => unmarshalIntegerMessageSchema).optional(), - automatic_cluster_update_workspace: z - .lazy(() => unmarshalClusterAutoRestartMessageSchema) - .optional(), - aibi_dashboard_embedding_approved_domains: z - .lazy(() => unmarshalAibiDashboardEmbeddingApprovedDomainsSchema) - .optional(), - aibi_dashboard_embedding_access_policy: z - .lazy(() => unmarshalAibiDashboardEmbeddingAccessPolicySchema) - .optional(), - restrict_workspace_admins: z - .lazy(() => unmarshalRestrictWorkspaceAdminsMessageSchema) - .optional(), - personal_compute: z - .lazy(() => unmarshalPersonalComputeMessageSchema) - .optional(), - effective_boolean_val: z - .lazy(() => unmarshalBooleanMessageSchema) - .optional(), + automatic_cluster_update_workspace: z.lazy(() => unmarshalClusterAutoRestartMessageSchema).optional(), + aibi_dashboard_embedding_approved_domains: z.lazy(() => unmarshalAibiDashboardEmbeddingApprovedDomainsSchema).optional(), + aibi_dashboard_embedding_access_policy: z.lazy(() => unmarshalAibiDashboardEmbeddingAccessPolicySchema).optional(), + restrict_workspace_admins: z.lazy(() => unmarshalRestrictWorkspaceAdminsMessageSchema).optional(), + personal_compute: z.lazy(() => unmarshalPersonalComputeMessageSchema).optional(), + effective_boolean_val: z.lazy(() => unmarshalBooleanMessageSchema).optional(), effective_string_val: z.lazy(() => unmarshalStringMessageSchema).optional(), - effective_integer_val: z - .lazy(() => unmarshalIntegerMessageSchema) - .optional(), - effective_automatic_cluster_update_workspace: z - .lazy(() => unmarshalClusterAutoRestartMessageSchema) - .optional(), - effective_aibi_dashboard_embedding_approved_domains: z - .lazy(() => unmarshalAibiDashboardEmbeddingApprovedDomainsSchema) - .optional(), - effective_aibi_dashboard_embedding_access_policy: z - .lazy(() => unmarshalAibiDashboardEmbeddingAccessPolicySchema) - .optional(), - effective_restrict_workspace_admins: z - .lazy(() => unmarshalRestrictWorkspaceAdminsMessageSchema) - .optional(), - effective_personal_compute: z - .lazy(() => unmarshalPersonalComputeMessageSchema) - .optional(), + effective_integer_val: z.lazy(() => unmarshalIntegerMessageSchema).optional(), + effective_automatic_cluster_update_workspace: z.lazy(() => unmarshalClusterAutoRestartMessageSchema).optional(), + effective_aibi_dashboard_embedding_approved_domains: z.lazy(() => unmarshalAibiDashboardEmbeddingApprovedDomainsSchema).optional(), + effective_aibi_dashboard_embedding_access_policy: z.lazy(() => unmarshalAibiDashboardEmbeddingAccessPolicySchema).optional(), + effective_restrict_workspace_admins: z.lazy(() => unmarshalRestrictWorkspaceAdminsMessageSchema).optional(), + effective_personal_compute: z.lazy(() => unmarshalPersonalComputeMessageSchema).optional(), }) .transform(d => ({ name: d.name, @@ -692,21 +601,16 @@ export const unmarshalSettingSchema: z.ZodType = z stringVal: d.string_val, integerVal: d.integer_val, automaticClusterUpdateWorkspace: d.automatic_cluster_update_workspace, - aibiDashboardEmbeddingApprovedDomains: - d.aibi_dashboard_embedding_approved_domains, - aibiDashboardEmbeddingAccessPolicy: - d.aibi_dashboard_embedding_access_policy, + aibiDashboardEmbeddingApprovedDomains: d.aibi_dashboard_embedding_approved_domains, + aibiDashboardEmbeddingAccessPolicy: d.aibi_dashboard_embedding_access_policy, restrictWorkspaceAdmins: d.restrict_workspace_admins, personalCompute: d.personal_compute, effectiveBooleanVal: d.effective_boolean_val, effectiveStringVal: d.effective_string_val, effectiveIntegerVal: d.effective_integer_val, - effectiveAutomaticClusterUpdateWorkspace: - d.effective_automatic_cluster_update_workspace, - effectiveAibiDashboardEmbeddingApprovedDomains: - d.effective_aibi_dashboard_embedding_approved_domains, - effectiveAibiDashboardEmbeddingAccessPolicy: - d.effective_aibi_dashboard_embedding_access_policy, + effectiveAutomaticClusterUpdateWorkspace: d.effective_automatic_cluster_update_workspace, + effectiveAibiDashboardEmbeddingApprovedDomains: d.effective_aibi_dashboard_embedding_approved_domains, + effectiveAibiDashboardEmbeddingAccessPolicy: d.effective_aibi_dashboard_embedding_access_policy, effectiveRestrictWorkspaceAdmins: d.effective_restrict_workspace_admins, effectivePersonalCompute: d.effective_personal_compute, })); @@ -739,9 +643,7 @@ export const unmarshalUserPreferenceSchema: z.ZodType = z user_id: z.string().optional(), boolean_val: z.lazy(() => unmarshalBooleanMessageSchema).optional(), string_val: z.lazy(() => unmarshalStringMessageSchema).optional(), - effective_boolean_val: z - .lazy(() => unmarshalBooleanMessageSchema) - .optional(), + effective_boolean_val: z.lazy(() => unmarshalBooleanMessageSchema).optional(), effective_string_val: z.lazy(() => unmarshalStringMessageSchema).optional(), }) .transform(d => ({ @@ -755,9 +657,7 @@ export const unmarshalUserPreferenceSchema: z.ZodType = z export const marshalAibiDashboardEmbeddingAccessPolicySchema: z.ZodType = z .object({ - accessPolicyType: z - .enum(AibiDashboardEmbeddingAccessPolicy_AccessPolicyType) - .optional(), + accessPolicyType: z.enum(AibiDashboardEmbeddingAccessPolicy_AccessPolicyType).optional(), }) .transform(d => ({ access_policy_type: d.accessPolicyType, @@ -783,12 +683,8 @@ export const marshalClusterAutoRestartMessageSchema: z.ZodType = z .object({ enabled: z.boolean().optional(), canToggle: z.boolean().optional(), - maintenanceWindow: z - .lazy(() => marshalClusterAutoRestartMessage_MaintenanceWindowSchema) - .optional(), - enablementDetails: z - .lazy(() => marshalClusterAutoRestartMessage_EnablementDetailsSchema) - .optional(), + maintenanceWindow: z.lazy(() => marshalClusterAutoRestartMessage_MaintenanceWindowSchema).optional(), + enablementDetails: z.lazy(() => marshalClusterAutoRestartMessage_EnablementDetailsSchema).optional(), restartEvenIfNoUpdatesAvailable: z.boolean().optional(), }) .transform(d => ({ @@ -800,68 +696,50 @@ export const marshalClusterAutoRestartMessageSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalClusterAutoRestartMessage_EnablementDetailsSchema: z.ZodType = - z - .object({ - unavailableForNonEnterpriseTier: z.boolean().optional(), - unavailableForDisabledEntitlement: z.boolean().optional(), - forcedForComplianceMode: z.boolean().optional(), - }) - .transform(d => ({ - unavailable_for_non_enterprise_tier: d.unavailableForNonEnterpriseTier, - unavailable_for_disabled_entitlement: d.unavailableForDisabledEntitlement, - forced_for_compliance_mode: d.forcedForComplianceMode, - })); +export const marshalClusterAutoRestartMessage_EnablementDetailsSchema: z.ZodType = z + .object({ + unavailableForNonEnterpriseTier: z.boolean().optional(), + unavailableForDisabledEntitlement: z.boolean().optional(), + forcedForComplianceMode: z.boolean().optional(), + }) + .transform(d => ({ + unavailable_for_non_enterprise_tier: d.unavailableForNonEnterpriseTier, + unavailable_for_disabled_entitlement: d.unavailableForDisabledEntitlement, + forced_for_compliance_mode: d.forcedForComplianceMode, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalClusterAutoRestartMessage_MaintenanceWindowSchema: z.ZodType = - z - .object({ - weekDayBasedSchedule: z - .lazy( - () => - marshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema - ) - .optional(), - }) - .transform(d => ({ - week_day_based_schedule: d.weekDayBasedSchedule, - })); +export const marshalClusterAutoRestartMessage_MaintenanceWindowSchema: z.ZodType = z + .object({ + weekDayBasedSchedule: z.lazy(() => marshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema).optional(), + }) + .transform(d => ({ + week_day_based_schedule: d.weekDayBasedSchedule, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema: z.ZodType = - z - .object({ - frequency: z - .enum(ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency) - .optional(), - dayOfWeek: z - .enum(ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek) - .optional(), - windowStartTime: z - .lazy( - () => - marshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema - ) - .optional(), - }) - .transform(d => ({ - frequency: d.frequency, - day_of_week: d.dayOfWeek, - window_start_time: d.windowStartTime, - })); +export const marshalClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleSchema: z.ZodType = z + .object({ + frequency: z.enum(ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency).optional(), + dayOfWeek: z.enum(ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek).optional(), + windowStartTime: z.lazy(() => marshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema).optional(), + }) + .transform(d => ({ + frequency: d.frequency, + day_of_week: d.dayOfWeek, + window_start_time: d.windowStartTime, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema: z.ZodType = - z - .object({ - hours: z.number().optional(), - minutes: z.number().optional(), - }) - .transform(d => ({ - hours: d.hours, - minutes: d.minutes, - })); +export const marshalClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeSchema: z.ZodType = z + .object({ + hours: z.number().optional(), + minutes: z.number().optional(), + }) + .transform(d => ({ + hours: d.hours, + minutes: d.minutes, + })); export const marshalGetPublicAccountSettingRequestSchema: z.ZodType = z .object({ @@ -915,9 +793,7 @@ export const marshalListAccountSettingsMetadataRequestSchema: z.ZodType = z export const marshalListAccountSettingsMetadataResponseSchema: z.ZodType = z .object({ - settingsMetadata: z - .array(z.lazy(() => marshalSettingsMetadataSchema)) - .optional(), + settingsMetadata: z.array(z.lazy(() => marshalSettingsMetadataSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -925,33 +801,29 @@ export const marshalListAccountSettingsMetadataResponseSchema: z.ZodType = z next_page_token: d.nextPageToken, })); -export const marshalListAccountUserPreferencesMetadataRequestSchema: z.ZodType = - z - .object({ - accountId: z.string().optional(), - userId: z.string().optional(), - pageSize: z.number().optional(), - pageToken: z.string().optional(), - }) - .transform(d => ({ - account_id: d.accountId, - user_id: d.userId, - page_size: d.pageSize, - page_token: d.pageToken, - })); - -export const marshalListAccountUserPreferencesMetadataResponseSchema: z.ZodType = - z - .object({ - settingsMetadata: z - .array(z.lazy(() => marshalSettingsMetadataSchema)) - .optional(), - nextPageToken: z.string().optional(), - }) - .transform(d => ({ - settings_metadata: d.settingsMetadata, - next_page_token: d.nextPageToken, - })); +export const marshalListAccountUserPreferencesMetadataRequestSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + userId: z.string().optional(), + pageSize: z.number().optional(), + pageToken: z.string().optional(), + }) + .transform(d => ({ + account_id: d.accountId, + user_id: d.userId, + page_size: d.pageSize, + page_token: d.pageToken, + })); + +export const marshalListAccountUserPreferencesMetadataResponseSchema: z.ZodType = z + .object({ + settingsMetadata: z.array(z.lazy(() => marshalSettingsMetadataSchema)).optional(), + nextPageToken: z.string().optional(), + }) + .transform(d => ({ + settings_metadata: d.settingsMetadata, + next_page_token: d.nextPageToken, + })); export const marshalListWorkspaceSettingsMetadataRequestSchema: z.ZodType = z .object({ @@ -965,9 +837,7 @@ export const marshalListWorkspaceSettingsMetadataRequestSchema: z.ZodType = z export const marshalListWorkspaceSettingsMetadataResponseSchema: z.ZodType = z .object({ - settingsMetadata: z - .array(z.lazy(() => marshalSettingsMetadataSchema)) - .optional(), + settingsMetadata: z.array(z.lazy(() => marshalSettingsMetadataSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -1035,39 +905,19 @@ export const marshalSettingSchema: z.ZodType = z booleanVal: z.lazy(() => marshalBooleanMessageSchema).optional(), stringVal: z.lazy(() => marshalStringMessageSchema).optional(), integerVal: z.lazy(() => marshalIntegerMessageSchema).optional(), - automaticClusterUpdateWorkspace: z - .lazy(() => marshalClusterAutoRestartMessageSchema) - .optional(), - aibiDashboardEmbeddingApprovedDomains: z - .lazy(() => marshalAibiDashboardEmbeddingApprovedDomainsSchema) - .optional(), - aibiDashboardEmbeddingAccessPolicy: z - .lazy(() => marshalAibiDashboardEmbeddingAccessPolicySchema) - .optional(), - restrictWorkspaceAdmins: z - .lazy(() => marshalRestrictWorkspaceAdminsMessageSchema) - .optional(), - personalCompute: z - .lazy(() => marshalPersonalComputeMessageSchema) - .optional(), + automaticClusterUpdateWorkspace: z.lazy(() => marshalClusterAutoRestartMessageSchema).optional(), + aibiDashboardEmbeddingApprovedDomains: z.lazy(() => marshalAibiDashboardEmbeddingApprovedDomainsSchema).optional(), + aibiDashboardEmbeddingAccessPolicy: z.lazy(() => marshalAibiDashboardEmbeddingAccessPolicySchema).optional(), + restrictWorkspaceAdmins: z.lazy(() => marshalRestrictWorkspaceAdminsMessageSchema).optional(), + personalCompute: z.lazy(() => marshalPersonalComputeMessageSchema).optional(), effectiveBooleanVal: z.lazy(() => marshalBooleanMessageSchema).optional(), effectiveStringVal: z.lazy(() => marshalStringMessageSchema).optional(), effectiveIntegerVal: z.lazy(() => marshalIntegerMessageSchema).optional(), - effectiveAutomaticClusterUpdateWorkspace: z - .lazy(() => marshalClusterAutoRestartMessageSchema) - .optional(), - effectiveAibiDashboardEmbeddingApprovedDomains: z - .lazy(() => marshalAibiDashboardEmbeddingApprovedDomainsSchema) - .optional(), - effectiveAibiDashboardEmbeddingAccessPolicy: z - .lazy(() => marshalAibiDashboardEmbeddingAccessPolicySchema) - .optional(), - effectiveRestrictWorkspaceAdmins: z - .lazy(() => marshalRestrictWorkspaceAdminsMessageSchema) - .optional(), - effectivePersonalCompute: z - .lazy(() => marshalPersonalComputeMessageSchema) - .optional(), + effectiveAutomaticClusterUpdateWorkspace: z.lazy(() => marshalClusterAutoRestartMessageSchema).optional(), + effectiveAibiDashboardEmbeddingApprovedDomains: z.lazy(() => marshalAibiDashboardEmbeddingApprovedDomainsSchema).optional(), + effectiveAibiDashboardEmbeddingAccessPolicy: z.lazy(() => marshalAibiDashboardEmbeddingAccessPolicySchema).optional(), + effectiveRestrictWorkspaceAdmins: z.lazy(() => marshalRestrictWorkspaceAdminsMessageSchema).optional(), + effectivePersonalCompute: z.lazy(() => marshalPersonalComputeMessageSchema).optional(), }) .transform(d => ({ name: d.name, @@ -1075,21 +925,16 @@ export const marshalSettingSchema: z.ZodType = z string_val: d.stringVal, integer_val: d.integerVal, automatic_cluster_update_workspace: d.automaticClusterUpdateWorkspace, - aibi_dashboard_embedding_approved_domains: - d.aibiDashboardEmbeddingApprovedDomains, - aibi_dashboard_embedding_access_policy: - d.aibiDashboardEmbeddingAccessPolicy, + aibi_dashboard_embedding_approved_domains: d.aibiDashboardEmbeddingApprovedDomains, + aibi_dashboard_embedding_access_policy: d.aibiDashboardEmbeddingAccessPolicy, restrict_workspace_admins: d.restrictWorkspaceAdmins, personal_compute: d.personalCompute, effective_boolean_val: d.effectiveBooleanVal, effective_string_val: d.effectiveStringVal, effective_integer_val: d.effectiveIntegerVal, - effective_automatic_cluster_update_workspace: - d.effectiveAutomaticClusterUpdateWorkspace, - effective_aibi_dashboard_embedding_approved_domains: - d.effectiveAibiDashboardEmbeddingApprovedDomains, - effective_aibi_dashboard_embedding_access_policy: - d.effectiveAibiDashboardEmbeddingAccessPolicy, + effective_automatic_cluster_update_workspace: d.effectiveAutomaticClusterUpdateWorkspace, + effective_aibi_dashboard_embedding_approved_domains: d.effectiveAibiDashboardEmbeddingApprovedDomains, + effective_aibi_dashboard_embedding_access_policy: d.effectiveAibiDashboardEmbeddingAccessPolicy, effective_restrict_workspace_admins: d.effectiveRestrictWorkspaceAdmins, effective_personal_compute: d.effectivePersonalCompute, })); diff --git a/packages/settings/src/v2/utils.ts b/packages/settings/src/v2/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/settings/src/v2/utils.ts +++ b/packages/settings/src/v2/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/settings/tsconfig.json b/packages/settings/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/settings/tsconfig.json +++ b/packages/settings/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/statementexecution/package.json b/packages/statementexecution/package.json index 6c173c19..7d5d2bc4 100644 --- a/packages/statementexecution/package.json +++ b/packages/statementexecution/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/statementexecution/src/v1/client.ts b/packages/statementexecution/src/v1/client.ts index 344db42c..d50b2d88 100644 --- a/packages/statementexecution/src/v1/client.ts +++ b/packages/statementexecution/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CancelStatementRequest, CancelStatementResponse, @@ -48,21 +43,13 @@ export class Client { * Requests that an executing statement be canceled. Callers must poll for status to see the * terminal state. Cancel response is empty; receiving response indicates successful receipt. */ - async cancelStatement( - signal: AbortSignal | undefined, - req: CancelStatementRequest, - options?: Options - ): Promise { + async cancelStatement(signal: AbortSignal | undefined, req: CancelStatementRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/statements/${req.statementId ?? ''}/cancel`; const body = marshalRequest(req, marshalCancelStatementRequestSchema); let resp: CancelStatementResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCancelStatementResponseSchema); }; await execute(signal, call, options); @@ -74,31 +61,31 @@ export class Client { /** * Execute a SQL statement and optionally await its results for a specified time. - * + * * **Use case: small result sets with INLINE + JSON_ARRAY** - * + * * For flows that generate small and predictable result sets (<= 25 MiB), `INLINE` responses of `JSON_ARRAY` result * data are typically the simplest way to execute and fetch result data. - * + * * **Use case: large result sets with EXTERNAL_LINKS** - * + * * Using `EXTERNAL_LINKS` to fetch result data allows you to fetch large result sets efficiently. * The main differences from using `INLINE` disposition are that the result data is accessed * with URLs, and * that there are 3 supported formats: `JSON_ARRAY`, `ARROW_STREAM` and `CSV` compared to only `JSON_ARRAY` with * `INLINE`. - * + * * ** URLs** - * + * * External links point to data stored within your workspace's internal storage, in the form of * a URL. The URLs are valid for only a short * period, <= 15 minutes. Alongside each `external_link` is an expiration field indicating the time at which the URL * is no longer valid. In `EXTERNAL_LINKS` mode, chunks can be resolved and fetched multiple times and in parallel. - * + * * ---- - * + * * ### **Warning: Databricks strongly recommends that you protect the URLs that are returned by the `EXTERNAL_LINKS` disposition.** - * + * * When you use the `EXTERNAL_LINKS` disposition, a * short-lived, URL is generated, which can be * used to download the results directly @@ -106,38 +93,30 @@ export class Client { * short-lived is * embedded in this URL, you should protect * the URL. - * + * * Because URLs are already generated with * embedded temporary s, * you must not set an `Authorization` header in the download requests. - * + * * The `EXTERNAL_LINKS` disposition can be disabled upon request by creating a support * case. - * + * * See also [Security best practices](/sql/admin/sql-execution-tutorial.html#security-best-practices). - * + * * ---- - * + * * StatementResponse contains `statement_id` and `status`; other fields might be absent or present depending on * context. If the SQL warehouse fails to execute the provided statement, a 200 response is returned with * `status.state` set to `FAILED` (in contrast to a failure when accepting the request, which results in a non-200 * response). Details of the error can be found at `status.error` in case of execution failures. */ - async executeStatement( - signal: AbortSignal | undefined, - req: ExecuteStatementRequest, - options?: Options - ): Promise { + async executeStatement(signal: AbortSignal | undefined, req: ExecuteStatementRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/statements/`; const body = marshalRequest(req, marshalExecuteStatementRequestSchema); let resp: StatementResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStatementResponseSchema); }; await execute(signal, call, options); @@ -157,20 +136,12 @@ export class Client { * iteration through the result set. Depending on `disposition`, the response returns chunks of * data either inline, or as links. */ - async getResultData( - signal: AbortSignal | undefined, - req: GetResultDataRequest, - options?: Options - ): Promise { + async getResultData(signal: AbortSignal | undefined, req: GetResultDataRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/statements/${req.statementId ?? ''}/result/chunks/${String(req.chunkIndex ?? '')}`; let resp: ResultData | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalResultDataSchema); }; await execute(signal, call, options); @@ -188,24 +159,16 @@ export class Client { * `CLOSED` or `FAILED`, it returns HTTP 200 with the state set. After at least 12 hours in * terminal state, the statement is removed from the warehouse and further calls will receive an * HTTP 404 response. - * + * * **NOTE** * This call currently might take up to 5 seconds to get the latest status and result. */ - async getStatementResult( - signal: AbortSignal | undefined, - req: GetStatementResultRequest, - options?: Options - ): Promise { + async getStatementResult(signal: AbortSignal | undefined, req: GetStatementResultRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/statements/${req.statementId ?? ''}`; let resp: StatementResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStatementResponseSchema); }; await execute(signal, call, options); diff --git a/packages/statementexecution/src/v1/index.ts b/packages/statementexecution/src/v1/index.ts index 78b8cd02..3f372d1c 100644 --- a/packages/statementexecution/src/v1/index.ts +++ b/packages/statementexecution/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { diff --git a/packages/statementexecution/src/v1/model.ts b/packages/statementexecution/src/v1/model.ts index 117027c9..d3760ef3 100644 --- a/packages/statementexecution/src/v1/model.ts +++ b/packages/statementexecution/src/v1/model.ts @@ -1,7 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import type {JsonValue} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; +const jsonValueSchema: z.ZodType = z.lazy(() => + z.union([z.null(), z.number(), z.string(), z.boolean(), z.record(z.string(), jsonValueSchema), z.array(jsonValueSchema)]) +); + /** The name of the base data type. This doesn't include details for complex types such as STRUCT, MAP or ARRAY. */ export enum ColumnTypeName { BOOLEAN = 'BOOLEAN', @@ -172,15 +177,15 @@ export interface ExecuteStatementRequest { byteLimit?: number | undefined; /** * 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 ], @@ -188,14 +193,14 @@ export interface ExecuteStatementRequest { * [ "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](https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format). - * + * * When specifying `format=CSV` and `disposition=EXTERNAL_LINKS`, each chunk in the result will be a CSV according to * [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180) standard. * All the columns values will have *string representation* similar to the `JSON_ARRAY` format, and `null` values will @@ -203,7 +208,7 @@ export interface ExecuteStatementRequest { * 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 @@ -214,23 +219,23 @@ export interface ExecuteStatementRequest { format?: Format | undefined; /** * 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 URLs * with a specific expiration, indicated in the response. The behavior when attempting to use an expired link is * cloud specific. @@ -239,11 +244,11 @@ export interface ExecuteStatementRequest { /** * 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, @@ -263,20 +268,20 @@ export interface ExecuteStatementRequest { * 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](https://docs.databricks.com/sql/language-manual/functions/cast.html) 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: - * + * * ` * { * ..., @@ -287,10 +292,10 @@ export interface ExecuteStatementRequest { * ] * } * ` - * + * * Currently, positional parameters denoted by a `?` marker are not supported by the * Databricks SQL Statement Execution API. - * + * * Also see the section [Parameter markers](https://docs.databricks.com/sql/language-manual/sql-ref-parameter-marker.html) of the SQL language reference. */ parameters?: StatementParameter[] | undefined; @@ -302,7 +307,7 @@ export interface ExecuteStatementRequest { * 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": [ @@ -407,7 +412,7 @@ export interface ResultData { * 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?: unknown[][] | undefined; + dataArray?: JsonValue[][] | undefined; /** The position within the sequence of result set chunks. */ chunkIndex?: number | undefined; /** The starting row offset within the result set. */ @@ -510,17 +515,17 @@ export interface StatementStatus { sqlState?: string | undefined; } -export const unmarshalCancelStatementRequestSchema: z.ZodType = - z - .object({ - statement_id: z.string().optional(), - }) - .transform(d => ({ - statementId: d.statement_id, - })); +export const unmarshalCancelStatementRequestSchema: z.ZodType = z + .object({ + statement_id: z.string().optional(), + }) + .transform(d => ({ + statementId: d.statement_id, + })); -export const unmarshalCancelStatementResponseSchema: z.ZodType = - z.object({}); +export const unmarshalCancelStatementResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalChunkInfoSchema: z.ZodType = z .object({ @@ -560,38 +565,35 @@ export const unmarshalColumnInfoSchema: z.ZodType = z typeIntervalType: d.type_interval_type, })); -export const unmarshalExecuteStatementRequestSchema: z.ZodType = - z - .object({ - statement: z.string().optional(), - warehouse_id: z.string().optional(), - catalog: z.string().optional(), - schema: z.string().optional(), - row_limit: z.number().optional(), - byte_limit: z.number().optional(), - format: z.enum(Format).optional(), - disposition: z.enum(Disposition).optional(), - wait_timeout: z.string().optional(), - on_wait_timeout: z.enum(TimeoutAction).optional(), - parameters: z - .array(z.lazy(() => unmarshalStatementParameterSchema)) - .optional(), - query_tags: z.array(z.lazy(() => unmarshalQueryTagSchema)).optional(), - }) - .transform(d => ({ - statement: d.statement, - warehouseId: d.warehouse_id, - catalog: d.catalog, - schema: d.schema, - rowLimit: d.row_limit, - byteLimit: d.byte_limit, - format: d.format, - disposition: d.disposition, - waitTimeout: d.wait_timeout, - onWaitTimeout: d.on_wait_timeout, - parameters: d.parameters, - queryTags: d.query_tags, - })); +export const unmarshalExecuteStatementRequestSchema: z.ZodType = z + .object({ + statement: z.string().optional(), + warehouse_id: z.string().optional(), + catalog: z.string().optional(), + schema: z.string().optional(), + row_limit: z.number().optional(), + byte_limit: z.number().optional(), + format: z.enum(Format).optional(), + disposition: z.enum(Disposition).optional(), + wait_timeout: z.string().optional(), + on_wait_timeout: z.enum(TimeoutAction).optional(), + parameters: z.array(z.lazy(() => unmarshalStatementParameterSchema)).optional(), + query_tags: z.array(z.lazy(() => unmarshalQueryTagSchema)).optional(), + }) + .transform(d => ({ + statement: d.statement, + warehouseId: d.warehouse_id, + catalog: d.catalog, + schema: d.schema, + rowLimit: d.row_limit, + byteLimit: d.byte_limit, + format: d.format, + disposition: d.disposition, + waitTimeout: d.wait_timeout, + onWaitTimeout: d.on_wait_timeout, + parameters: d.parameters, + queryTags: d.query_tags, + })); export const unmarshalExternalLinkSchema: z.ZodType = z .object({ @@ -618,36 +620,33 @@ export const unmarshalExternalLinkSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalExternalLink_HttpHeadersEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -export const unmarshalGetResultDataRequestSchema: z.ZodType = - z - .object({ - statement_id: z.string().optional(), - chunk_index: z.number().optional(), - }) - .transform(d => ({ - statementId: d.statement_id, - chunkIndex: d.chunk_index, - })); - -export const unmarshalGetStatementResultRequestSchema: z.ZodType = - z - .object({ - statement_id: z.string().optional(), - }) - .transform(d => ({ - statementId: d.statement_id, - })); +export const unmarshalExternalLink_HttpHeadersEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalGetResultDataRequestSchema: z.ZodType = z + .object({ + statement_id: z.string().optional(), + chunk_index: z.number().optional(), + }) + .transform(d => ({ + statementId: d.statement_id, + chunkIndex: d.chunk_index, + })); + +export const unmarshalGetStatementResultRequestSchema: z.ZodType = z + .object({ + statement_id: z.string().optional(), + }) + .transform(d => ({ + statementId: d.statement_id, + })); export const unmarshalQueryTagSchema: z.ZodType = z .object({ @@ -661,10 +660,8 @@ export const unmarshalQueryTagSchema: z.ZodType = z export const unmarshalResultDataSchema: z.ZodType = z .object({ - external_links: z - .array(z.lazy(() => unmarshalExternalLinkSchema)) - .optional(), - data_array: z.array(z.array(z.unknown())).optional(), + external_links: z.array(z.lazy(() => unmarshalExternalLinkSchema)).optional(), + data_array: z.array(z.array(jsonValueSchema)).optional(), chunk_index: z.number().optional(), row_offset: z.number().optional(), row_count: z.number().optional(), @@ -723,18 +720,17 @@ export const unmarshalServiceErrorSchema: z.ZodType = z message: d.message, })); -export const unmarshalStatementParameterSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - value: z.string().optional(), - type: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - value: d.value, - type: d.type, - })); +export const unmarshalStatementParameterSchema: z.ZodType = z + .object({ + name: z.string().optional(), + value: z.string().optional(), + type: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + value: d.value, + type: d.type, + })); export const unmarshalStatementResponseSchema: z.ZodType = z .object({ @@ -770,7 +766,9 @@ export const marshalCancelStatementRequestSchema: z.ZodType = z statement_id: d.statementId, })); -export const marshalCancelStatementResponseSchema: z.ZodType = z.object({}); +export const marshalCancelStatementResponseSchema: z.ZodType = z + .object({ + }); export const marshalChunkInfoSchema: z.ZodType = z .object({ @@ -822,9 +820,7 @@ export const marshalExecuteStatementRequestSchema: z.ZodType = z disposition: z.enum(Disposition).optional(), waitTimeout: z.string().optional(), onWaitTimeout: z.enum(TimeoutAction).optional(), - parameters: z - .array(z.lazy(() => marshalStatementParameterSchema)) - .optional(), + parameters: z.array(z.lazy(() => marshalStatementParameterSchema)).optional(), queryTags: z.array(z.lazy(() => marshalQueryTagSchema)).optional(), }) .transform(d => ({ @@ -908,7 +904,7 @@ export const marshalQueryTagSchema: z.ZodType = z export const marshalResultDataSchema: z.ZodType = z .object({ externalLinks: z.array(z.lazy(() => marshalExternalLinkSchema)).optional(), - dataArray: z.array(z.array(z.unknown())).optional(), + dataArray: z.array(z.array(jsonValueSchema)).optional(), chunkIndex: z.number().optional(), rowOffset: z.number().optional(), rowCount: z.number().optional(), diff --git a/packages/statementexecution/src/v1/utils.ts b/packages/statementexecution/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/statementexecution/src/v1/utils.ts +++ b/packages/statementexecution/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/statementexecution/tsconfig.json b/packages/statementexecution/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/statementexecution/tsconfig.json +++ b/packages/statementexecution/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/systemschemas/package.json b/packages/systemschemas/package.json index c0a4fc05..70bd8744 100644 --- a/packages/systemschemas/package.json +++ b/packages/systemschemas/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/systemschemas/src/v1/client.ts b/packages/systemschemas/src/v1/client.ts index f589c669..53aa1524 100644 --- a/packages/systemschemas/src/v1/client.ts +++ b/packages/systemschemas/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { DisableSystemSchema, DisableSystemSchema_Response, @@ -47,24 +42,13 @@ export class Client { * Disables the system schema and removes it from the system catalog. * The caller must be an account admin or a metastore admin. */ - async disableSystemSchema( - signal: AbortSignal | undefined, - req: DisableSystemSchema, - options?: Options - ): Promise { + async disableSystemSchema(signal: AbortSignal | undefined, req: DisableSystemSchema, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.metastoreId ?? ''}/systemschemas/${req.schema ?? ''}`; let resp: DisableSystemSchema_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDisableSystemSchema_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDisableSystemSchema_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -77,25 +61,14 @@ export class Client { * Enables the system schema and adds it to the system catalog. * The caller must be an account admin or a metastore admin. */ - async enableSystemSchema( - signal: AbortSignal | undefined, - req: EnableSystemSchema, - options?: Options - ): Promise { + async enableSystemSchema(signal: AbortSignal | undefined, req: EnableSystemSchema, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.metastoreId ?? ''}/systemschemas/${req.schema ?? ''}`; const body = marshalRequest(req, marshalEnableSystemSchemaSchema); let resp: EnableSystemSchema_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalEnableSystemSchema_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalEnableSystemSchema_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -107,17 +80,13 @@ export class Client { /** * Gets an array of system schemas for a metastore. * The caller must be an account admin or a metastore admin. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listSystemSchemas( - signal: AbortSignal | undefined, - req: ListSystemSchemas, - options?: Options - ): Promise { + async listSystemSchemas(signal: AbortSignal | undefined, req: ListSystemSchemas, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/metastores/${req.metastoreId ?? ''}/systemschemas`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -131,11 +100,7 @@ export class Client { let resp: ListSystemSchemas_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListSystemSchemas_ResponseSchema); }; await execute(signal, call, options); @@ -145,11 +110,8 @@ export class Client { return resp; } - async *listSystemSchemasIter( - signal: AbortSignal | undefined, - req: ListSystemSchemas, - options?: Options - ): AsyncGenerator { + + async *listSystemSchemasIter(signal: AbortSignal | undefined, req: ListSystemSchemas, options?: Options): AsyncGenerator { const pageReq: ListSystemSchemas = {...req}; for (;;) { const resp = await this.listSystemSchemas(signal, pageReq, options); @@ -162,4 +124,5 @@ export class Client { pageReq.pageToken = resp.nextPageToken; } } + } diff --git a/packages/systemschemas/src/v1/index.ts b/packages/systemschemas/src/v1/index.ts index 8adb1140..0ea96dd1 100644 --- a/packages/systemschemas/src/v1/index.ts +++ b/packages/systemschemas/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { DisableSystemSchema, diff --git a/packages/systemschemas/src/v1/model.ts b/packages/systemschemas/src/v1/model.ts index a9ee85e9..f3e14e93 100644 --- a/packages/systemschemas/src/v1/model.ts +++ b/packages/systemschemas/src/v1/model.ts @@ -60,37 +60,37 @@ export interface SystemSchemaInfo { state: string; } -export const unmarshalDisableSystemSchemaSchema: z.ZodType = - z - .object({ - schema: z.string().optional(), - metastore_id: z.string().optional(), - }) - .transform(d => ({ - schema: d.schema, - metastoreId: d.metastore_id, - })); +export const unmarshalDisableSystemSchemaSchema: z.ZodType = z + .object({ + schema: z.string().optional(), + metastore_id: z.string().optional(), + }) + .transform(d => ({ + schema: d.schema, + metastoreId: d.metastore_id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDisableSystemSchema_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalEnableSystemSchemaSchema: z.ZodType = - z - .object({ - schema: z.string().optional(), - metastore_id: z.string().optional(), - catalog_name: z.string().optional(), - }) - .transform(d => ({ - schema: d.schema, - metastoreId: d.metastore_id, - catalogName: d.catalog_name, - })); +export const unmarshalDisableSystemSchema_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalEnableSystemSchemaSchema: z.ZodType = z + .object({ + schema: z.string().optional(), + metastore_id: z.string().optional(), + catalog_name: z.string().optional(), + }) + .transform(d => ({ + schema: d.schema, + metastoreId: d.metastore_id, + catalogName: d.catalog_name, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalEnableSystemSchema_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalEnableSystemSchema_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalListSystemSchemasSchema: z.ZodType = z .object({ @@ -105,18 +105,15 @@ export const unmarshalListSystemSchemasSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListSystemSchemas_ResponseSchema: z.ZodType = - z - .object({ - schemas: z - .array(z.lazy(() => unmarshalSystemSchemaInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - schemas: d.schemas, - nextPageToken: d.next_page_token, - })); +export const unmarshalListSystemSchemas_ResponseSchema: z.ZodType = z + .object({ + schemas: z.array(z.lazy(() => unmarshalSystemSchemaInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + schemas: d.schemas, + nextPageToken: d.next_page_token, + })); export const unmarshalSystemSchemaInfoSchema: z.ZodType = z .object({ @@ -139,9 +136,9 @@ export const marshalDisableSystemSchemaSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDisableSystemSchema_ResponseSchema: z.ZodType = z.object( - {} -); +export const marshalDisableSystemSchema_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalEnableSystemSchemaSchema: z.ZodType = z .object({ @@ -156,7 +153,9 @@ export const marshalEnableSystemSchemaSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalEnableSystemSchema_ResponseSchema: z.ZodType = z.object({}); +export const marshalEnableSystemSchema_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalListSystemSchemasSchema: z.ZodType = z .object({ diff --git a/packages/systemschemas/src/v1/utils.ts b/packages/systemschemas/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/systemschemas/src/v1/utils.ts +++ b/packages/systemschemas/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/systemschemas/tsconfig.json b/packages/systemschemas/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/systemschemas/tsconfig.json +++ b/packages/systemschemas/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/tables/package.json b/packages/tables/package.json index 6223afb3..174ecbd0 100644 --- a/packages/tables/package.json +++ b/packages/tables/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/tables/src/v1/client.ts b/packages/tables/src/v1/client.ts index 96570e64..a2f9105d 100644 --- a/packages/tables/src/v1/client.ts +++ b/packages/tables/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateTable, CreateTableConstraint, @@ -63,45 +58,37 @@ export class Client { /** * Creates a new table in the specified catalog and schema. - * + * * To create an external delta table, the caller must have the **EXTERNAL_USE_SCHEMA** privilege on the parent schema * and the **EXTERNAL_USE_LOCATION** privilege on the external location. These privileges must always be granted explicitly, * and cannot be inherited through ownership or **ALL_PRIVILEGES**. - * + * * Standard UC permissions needed to create tables still apply: **USE_CATALOG** on the parent catalog (or ownership of * the parent catalog), **CREATE_TABLE** and **USE_SCHEMA** on the parent schema (or ownership of the parent schema), * and **CREATE_EXTERNAL_TABLE** on external location. - * + * * The **columns** field needs to be in a Spark compatible format, so we recommend you use Spark to create these tables. * The API itself does not validate the correctness of the column spec. If the spec is not Spark compatible, * the tables may not be readable by Databricks Runtime. - * - * - * - * - * - * - * + * + * + * + * + * + * + * * NOTE: The Create Table API for external clients only supports creating **external delta tables**. The values shown * in the respective enums are all values supported by , however for this specific Create Table API, * only **table_type** **EXTERNAL** and **data_source_format** **DELTA** are supported. Additionally, column masks * are not supported when creating tables through this API. */ - async createTable( - signal: AbortSignal | undefined, - req: CreateTable, - options?: Options - ): Promise { + async createTable(signal: AbortSignal | undefined, req: CreateTable, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables`; const body = marshalRequest(req, marshalCreateTableSchema); let resp: TableInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTableInfoSchema); }; await execute(signal, call, options); @@ -113,7 +100,7 @@ export class Client { /** * Creates a new table constraint. - * + * * For the table constraint creation to succeed, the user must satisfy both of these conditions: * - the user must have the **USE_CATALOG** privilege on the table's parent catalog, * the **USE_SCHEMA** privilege on the table's parent schema, and be the owner of the table. @@ -122,21 +109,13 @@ export class Client { * the **USE_SCHEMA** privilege on the referenced parent table's schema, * and be the owner of the referenced parent table. */ - async createTableConstraint( - signal: AbortSignal | undefined, - req: CreateTableConstraint, - options?: Options - ): Promise { + async createTableConstraint(signal: AbortSignal | undefined, req: CreateTableConstraint, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/constraints`; const body = marshalRequest(req, marshalCreateTableConstraintSchema); let resp: TableConstraint | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTableConstraintSchema); }; await execute(signal, call, options); @@ -151,20 +130,12 @@ export class Client { * The caller must be the owner of the parent catalog, have the **USE_CATALOG** privilege on the parent catalog and be the owner of the parent schema, * or be the owner of the table and have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async deleteTable( - signal: AbortSignal | undefined, - req: DeleteTable, - options?: Options - ): Promise { + async deleteTable(signal: AbortSignal | undefined, req: DeleteTable, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}`; let resp: DeleteTable_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteTable_ResponseSchema); }; await execute(signal, call, options); @@ -176,7 +147,7 @@ export class Client { /** * Deletes a table constraint. - * + * * For the table constraint deletion to succeed, the user must satisfy both of these conditions: * - the user must have the **USE_CATALOG** privilege on the table's parent catalog, * the **USE_SCHEMA** privilege on the table's parent schema, and be the owner of the table. @@ -185,11 +156,7 @@ export class Client { * the **USE_SCHEMA** privilege on the table's schema, * and be the owner of the table. */ - async deleteTableConstraint( - signal: AbortSignal | undefined, - req: DeleteTableConstraint, - options?: Options - ): Promise { + async deleteTableConstraint(signal: AbortSignal | undefined, req: DeleteTableConstraint, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/constraints/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.constraintName !== undefined) { @@ -203,15 +170,8 @@ export class Client { let resp: DeleteTableConstraint_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteTableConstraint_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteTableConstraint_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -229,11 +189,7 @@ export class Client { * * Have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema, * and either be the table owner or have the **SELECT** privilege on the table. */ - async getTable( - signal: AbortSignal | undefined, - req: GetTable, - options?: Options - ): Promise { + async getTable(signal: AbortSignal | undefined, req: GetTable, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeDeltaMetadata !== undefined) { @@ -243,21 +199,14 @@ export class Client { params.append('include_browse', String(req.includeBrowse)); } if (req.includeManifestCapabilities !== undefined) { - params.append( - 'include_manifest_capabilities', - String(req.includeManifestCapabilities) - ); + params.append('include_manifest_capabilities', String(req.includeManifestCapabilities)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: TableInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTableInfoSchema); }; await execute(signal, call, options); @@ -269,22 +218,18 @@ export class Client { /** * Gets an array of summaries for tables for a schema and catalog within the metastore. The table summaries returned are either: - * + * * * summaries for tables (within the current metastore and parent catalog and schema), when the user is a metastore admin, or: * * summaries for tables and schemas (within the current metastore and parent catalog) * for which the user has ownership or the **SELECT** privilege on the table and ownership or **USE_SCHEMA** privilege on the schema, * provided that the user also has ownership or the **USE_CATALOG** privilege on the parent catalog. - * + * * There is no guarantee of a specific ordering of the elements in the array. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listTableSummaries( - signal: AbortSignal | undefined, - req: ListTableSummaries, - options?: Options - ): Promise { + async listTableSummaries(signal: AbortSignal | undefined, req: ListTableSummaries, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/table-summaries`; const params = new URLSearchParams(); if (req.catalogName !== undefined) { @@ -303,25 +248,15 @@ export class Client { params.append('page_token', req.pageToken); } if (req.includeManifestCapabilities !== undefined) { - params.append( - 'include_manifest_capabilities', - String(req.includeManifestCapabilities) - ); + params.append('include_manifest_capabilities', String(req.includeManifestCapabilities)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: ListTableSummaries_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListTableSummaries_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListTableSummaries_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -330,11 +265,8 @@ export class Client { return resp; } - async *listTableSummariesIter( - signal: AbortSignal | undefined, - req: ListTableSummaries, - options?: Options - ): AsyncGenerator { + + async *listTableSummariesIter(signal: AbortSignal | undefined, req: ListTableSummaries, options?: Options): AsyncGenerator { const pageReq: ListTableSummaries = {...req}; for (;;) { const resp = await this.listTableSummaries(signal, pageReq, options); @@ -348,24 +280,21 @@ export class Client { } } + /** * Gets an array of all tables for the current metastore under the parent catalog and schema. * The caller must be a metastore admin or an owner of (or have the **SELECT** privilege on) the table. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. * There is no guarantee of a specific ordering of the elements in the array. - * + * * NOTE: **view_dependencies** and **table_constraints** are not returned by ListTables queries. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listTables( - signal: AbortSignal | undefined, - req: ListTables, - options?: Options - ): Promise { + async listTables(signal: AbortSignal | undefined, req: ListTables, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables`; const params = new URLSearchParams(); if (req.catalogName !== undefined) { @@ -393,21 +322,14 @@ export class Client { params.append('include_browse', String(req.includeBrowse)); } if (req.includeManifestCapabilities !== undefined) { - params.append( - 'include_manifest_capabilities', - String(req.includeManifestCapabilities) - ); + params.append('include_manifest_capabilities', String(req.includeManifestCapabilities)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; let resp: ListTables_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListTables_ResponseSchema); }; await execute(signal, call, options); @@ -417,11 +339,8 @@ export class Client { return resp; } - async *listTablesIter( - signal: AbortSignal | undefined, - req: ListTables, - options?: Options - ): AsyncGenerator { + + async *listTablesIter(signal: AbortSignal | undefined, req: ListTables, options?: Options): AsyncGenerator { const pageReq: ListTables = {...req}; for (;;) { const resp = await this.listTables(signal, pageReq, options); @@ -435,6 +354,7 @@ export class Client { } } + /** * Gets if a table exists in the metastore for a specific catalog and schema. * The caller must satisfy one of the following requirements: @@ -446,20 +366,12 @@ export class Client { * * Have **BROWSE** privilege on the parent catalog * * Have **BROWSE** privilege on the parent schema */ - async tableExists( - signal: AbortSignal | undefined, - req: TableExists, - options?: Options - ): Promise { + async tableExists(signal: AbortSignal | undefined, req: TableExists, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}/exists`; let resp: TableExists_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTableExists_ResponseSchema); }; await execute(signal, call, options); @@ -474,21 +386,13 @@ export class Client { * The caller must be the owner of the parent catalog, have the **USE_CATALOG** privilege on the parent catalog and be the owner of the parent schema, * or be the owner of the table and have the **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async updateTable( - signal: AbortSignal | undefined, - req: UpdateTable, - options?: Options - ): Promise { + async updateTable(signal: AbortSignal | undefined, req: UpdateTable, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/tables/${req.fullNameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateTableSchema); let resp: UpdateTable_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalUpdateTable_ResponseSchema); }; await execute(signal, call, options); diff --git a/packages/tables/src/v1/index.ts b/packages/tables/src/v1/index.ts index 856f1d6d..5ad38c09 100644 --- a/packages/tables/src/v1/index.ts +++ b/packages/tables/src/v1/index.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; export { @@ -44,6 +45,7 @@ export type { PolicyFunctionArgument, PrimaryKeyConstraint, RowFilter, + SecretDependency, SecurableKindManifest, SseEncryptionDetails, TableConstraint, @@ -56,4 +58,5 @@ export type { UpdateTable, UpdateTable_PropertiesEntry, UpdateTable_Response, + VolumeDependency, } from './model'; diff --git a/packages/tables/src/v1/model.ts b/packages/tables/src/v1/model.ts index 4899a7b0..7e1eb00d 100644 --- a/packages/tables/src/v1/model.ts +++ b/packages/tables/src/v1/model.ts @@ -27,6 +27,7 @@ export enum ColumnTypeName { GEOMETRY = 'GEOMETRY', GEOGRAPHY = 'GEOGRAPHY', TIME = 'TIME', + FILE = 'FILE', TABLE_TYPE = 'TABLE_TYPE', } @@ -362,9 +363,7 @@ export interface CreateTable { deltaRuntimePropertiesKvpairs?: DeltaRuntimePropertiesKvPairs | undefined; /** Time at which this table was deleted, in epoch milliseconds. Field is omitted if table is not deleted. */ deletedAt?: number | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** The AWS access point to use when accesing s3 for this external location. */ accessPoint?: string | undefined; /** 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. */ @@ -436,13 +435,17 @@ export interface DeltaRuntimePropertiesKvPairs_DeltaRuntimePropertiesEntry { /** * A dependency of a SQL object. One of the following fields must be defined: - * __table__, __function__, __connection__, or __credential__. + * __table__, __function__, __connection__, __credential__, __volume__, or __secret__. */ export interface Dependency { table?: TableDependency | undefined; function?: FunctionDependency | undefined; connection?: ConnectionDependency | undefined; credential?: CredentialDependency | undefined; + /** A dependency on a Unity Catalog volume. */ + volume?: VolumeDependency | undefined; + /** A dependency on a Unity Catalog secret. */ + secret?: SecretDependency | undefined; } /** A list of dependencies. */ @@ -663,6 +666,12 @@ export interface RowFilter { inputArguments?: PolicyFunctionArgument[] | undefined; } +/** A secret that is dependent on a SQL object. */ +export interface SecretDependency { + /** Full name of the dependent secret, in the form of __catalog_name__.__schema_name__.__secret_name__. */ + secretFullName?: string | undefined; +} + /** Manifest of a specific securable kind. */ export interface SecurableKindManifest { /** Securable Type of the kind. */ @@ -770,9 +779,7 @@ export interface TableInfo { deltaRuntimePropertiesKvpairs?: DeltaRuntimePropertiesKvPairs | undefined; /** Time at which this table was deleted, in epoch milliseconds. Field is omitted if table is not deleted. */ deletedAt?: number | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** The AWS access point to use when accesing s3 for this external location. */ accessPoint?: string | undefined; /** 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. */ @@ -857,9 +864,7 @@ export interface UpdateTable { deltaRuntimePropertiesKvpairs?: DeltaRuntimePropertiesKvPairs | undefined; /** Time at which this table was deleted, in epoch milliseconds. Field is omitted if table is not deleted. */ deletedAt?: number | undefined; - effectivePredictiveOptimizationFlag?: - | EffectivePredictiveOptimizationFlag - | undefined; + effectivePredictiveOptimizationFlag?: EffectivePredictiveOptimizationFlag | undefined; /** The AWS access point to use when accesing s3 for this external location. */ accessPoint?: string | undefined; /** 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. */ @@ -882,6 +887,12 @@ export interface UpdateTable_PropertiesEntry { // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. export interface UpdateTable_Response {} +/** A volume that is dependent on a SQL object. */ +export interface VolumeDependency { + /** Full name of the dependent volume, in the form of __catalog_name__.__schema_name__.__volume_name__. */ + volumeFullName?: string | undefined; +} + export const unmarshalColumnInfoSchema: z.ZodType = z .object({ name: z.string().optional(), @@ -916,9 +927,7 @@ export const unmarshalColumnMaskSchema: z.ZodType = z .object({ function_name: z.string().optional(), using_column_names: z.array(z.string()).optional(), - using_arguments: z - .array(z.lazy(() => unmarshalPolicyFunctionArgumentSchema)) - .optional(), + using_arguments: z.array(z.lazy(() => unmarshalPolicyFunctionArgumentSchema)).optional(), }) .transform(d => ({ functionName: d.function_name, @@ -926,25 +935,23 @@ export const unmarshalColumnMaskSchema: z.ZodType = z usingArguments: d.using_arguments, })); -export const unmarshalConditionalDisplaySchema: z.ZodType = - z - .object({ - depends_on_option: z.string().optional(), - hidden_when_values: z.array(z.string()).optional(), - }) - .transform(d => ({ - dependsOnOption: d.depends_on_option, - hiddenWhenValues: d.hidden_when_values, - })); - -export const unmarshalConnectionDependencySchema: z.ZodType = - z - .object({ - connection_name: z.string().optional(), - }) - .transform(d => ({ - connectionName: d.connection_name, - })); +export const unmarshalConditionalDisplaySchema: z.ZodType = z + .object({ + depends_on_option: z.string().optional(), + hidden_when_values: z.array(z.string()).optional(), + }) + .transform(d => ({ + dependsOnOption: d.depends_on_option, + hiddenWhenValues: d.hidden_when_values, + })); + +export const unmarshalConnectionDependencySchema: z.ZodType = z + .object({ + connection_name: z.string().optional(), + }) + .transform(d => ({ + connectionName: d.connection_name, + })); export const unmarshalCreateTableSchema: z.ZodType = z .object({ @@ -960,9 +967,7 @@ export const unmarshalCreateTableSchema: z.ZodType = z owner: z.string().optional(), comment: z.string().optional(), storage_credential_name: z.string().optional(), - table_constraints: z - .array(z.lazy(() => unmarshalTableConstraintSchema)) - .optional(), + table_constraints: z.array(z.lazy(() => unmarshalTableConstraintSchema)).optional(), row_filter: z.lazy(() => unmarshalRowFilterSchema).optional(), pipeline_id: z.string().optional(), enable_predictive_optimization: z.string().optional(), @@ -974,21 +979,13 @@ export const unmarshalCreateTableSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), table_id: z.string().optional(), - delta_runtime_properties_kvpairs: z - .lazy(() => unmarshalDeltaRuntimePropertiesKvPairsSchema) - .optional(), + delta_runtime_properties_kvpairs: z.lazy(() => unmarshalDeltaRuntimePropertiesKvPairsSchema).optional(), deleted_at: z.number().optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), access_point: z.string().optional(), browse_only: z.boolean().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), - securable_kind_manifest: z - .lazy(() => unmarshalSecurableKindManifestSchema) - .optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), + securable_kind_manifest: z.lazy(() => unmarshalSecurableKindManifestSchema).optional(), columns: z.array(z.lazy(() => unmarshalColumnInfoSchema)).optional(), properties: z.record(z.string(), z.string()).optional(), }) @@ -1019,8 +1016,7 @@ export const unmarshalCreateTableSchema: z.ZodType = z tableId: d.table_id, deltaRuntimePropertiesKvpairs: d.delta_runtime_properties_kvpairs, deletedAt: d.deleted_at, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, accessPoint: d.access_point, browseOnly: d.browse_only, encryptionDetails: d.encryption_details, @@ -1030,36 +1026,33 @@ export const unmarshalCreateTableSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateTable_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -export const unmarshalCreateTableConstraintSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - constraint: z.lazy(() => unmarshalTableConstraintSchema).optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - constraint: d.constraint, - })); - -export const unmarshalCredentialDependencySchema: z.ZodType = - z - .object({ - credential_name: z.string().optional(), - }) - .transform(d => ({ - credentialName: d.credential_name, - })); +export const unmarshalCreateTable_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalCreateTableConstraintSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + constraint: z.lazy(() => unmarshalTableConstraintSchema).optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + constraint: d.constraint, + })); + +export const unmarshalCredentialDependencySchema: z.ZodType = z + .object({ + credential_name: z.string().optional(), + }) + .transform(d => ({ + credentialName: d.credential_name, + })); export const unmarshalDeleteTableSchema: z.ZodType = z .object({ @@ -1070,46 +1063,45 @@ export const unmarshalDeleteTableSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteTable_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeleteTableConstraintSchema: z.ZodType = - z - .object({ - full_name_arg: z.string().optional(), - constraint_name: z.string().optional(), - cascade: z.boolean().optional(), - }) - .transform(d => ({ - fullNameArg: d.full_name_arg, - constraintName: d.constraint_name, - cascade: d.cascade, - })); +export const unmarshalDeleteTable_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeleteTableConstraintSchema: z.ZodType = z + .object({ + full_name_arg: z.string().optional(), + constraint_name: z.string().optional(), + cascade: z.boolean().optional(), + }) + .transform(d => ({ + fullNameArg: d.full_name_arg, + constraintName: d.constraint_name, + cascade: d.cascade, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteTableConstraint_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalDeltaRuntimePropertiesKvPairsSchema: z.ZodType = - z - .object({ - delta_runtime_properties: z.record(z.string(), z.string()).optional(), - }) - .transform(d => ({ - deltaRuntimeProperties: d.delta_runtime_properties, - })); +export const unmarshalDeleteTableConstraint_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalDeltaRuntimePropertiesKvPairsSchema: z.ZodType = z + .object({ + delta_runtime_properties: z.record(z.string(), z.string()).optional(), + }) + .transform(d => ({ + deltaRuntimeProperties: d.delta_runtime_properties, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeltaRuntimePropertiesKvPairs_DeltaRuntimePropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalDeltaRuntimePropertiesKvPairs_DeltaRuntimePropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalDependencySchema: z.ZodType = z .object({ @@ -1117,12 +1109,16 @@ export const unmarshalDependencySchema: z.ZodType = z function: z.lazy(() => unmarshalFunctionDependencySchema).optional(), connection: z.lazy(() => unmarshalConnectionDependencySchema).optional(), credential: z.lazy(() => unmarshalCredentialDependencySchema).optional(), + volume: z.lazy(() => unmarshalVolumeDependencySchema).optional(), + secret: z.lazy(() => unmarshalSecretDependencySchema).optional(), }) .transform(d => ({ table: d.table, function: d.function, connection: d.connection, credential: d.credential, + volume: d.volume, + secret: d.secret, })); export const unmarshalDependencyListSchema: z.ZodType = z @@ -1133,54 +1129,49 @@ export const unmarshalDependencyListSchema: z.ZodType = z dependencies: d.dependencies, })); -export const unmarshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = - z - .object({ - value: z.string().optional(), - inherited_from_type: z.string().optional(), - inherited_from_name: z.string().optional(), - }) - .transform(d => ({ - value: d.value, - inheritedFromType: d.inherited_from_type, - inheritedFromName: d.inherited_from_name, - })); +export const unmarshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = z + .object({ + value: z.string().optional(), + inherited_from_type: z.string().optional(), + inherited_from_name: z.string().optional(), + }) + .transform(d => ({ + value: d.value, + inheritedFromType: d.inherited_from_type, + inheritedFromName: d.inherited_from_name, + })); export const unmarshalEncryptionDetailsSchema: z.ZodType = z .object({ - sse_encryption_details: z - .lazy(() => unmarshalSseEncryptionDetailsSchema) - .optional(), + sse_encryption_details: z.lazy(() => unmarshalSseEncryptionDetailsSchema).optional(), }) .transform(d => ({ sseEncryptionDetails: d.sse_encryption_details, })); -export const unmarshalForeignKeyConstraintSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - child_columns: z.array(z.string()).optional(), - parent_table: z.string().optional(), - parent_columns: z.array(z.string()).optional(), - rely: z.boolean().optional(), - }) - .transform(d => ({ - name: d.name, - childColumns: d.child_columns, - parentTable: d.parent_table, - parentColumns: d.parent_columns, - rely: d.rely, - })); - -export const unmarshalFunctionDependencySchema: z.ZodType = - z - .object({ - function_full_name: z.string().optional(), - }) - .transform(d => ({ - functionFullName: d.function_full_name, - })); +export const unmarshalForeignKeyConstraintSchema: z.ZodType = z + .object({ + name: z.string().optional(), + child_columns: z.array(z.string()).optional(), + parent_table: z.string().optional(), + parent_columns: z.array(z.string()).optional(), + rely: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + childColumns: d.child_columns, + parentTable: d.parent_table, + parentColumns: d.parent_columns, + rely: d.rely, + })); + +export const unmarshalFunctionDependencySchema: z.ZodType = z + .object({ + function_full_name: z.string().optional(), + }) + .transform(d => ({ + functionFullName: d.function_full_name, + })); export const unmarshalGetTableSchema: z.ZodType = z .object({ @@ -1196,36 +1187,34 @@ export const unmarshalGetTableSchema: z.ZodType = z includeManifestCapabilities: d.include_manifest_capabilities, })); -export const unmarshalListTableSummariesSchema: z.ZodType = - z - .object({ - catalog_name: z.string().optional(), - schema_name_pattern: z.string().optional(), - table_name_pattern: z.string().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - include_manifest_capabilities: z.boolean().optional(), - }) - .transform(d => ({ - catalogName: d.catalog_name, - schemaNamePattern: d.schema_name_pattern, - tableNamePattern: d.table_name_pattern, - maxResults: d.max_results, - pageToken: d.page_token, - includeManifestCapabilities: d.include_manifest_capabilities, - })); +export const unmarshalListTableSummariesSchema: z.ZodType = z + .object({ + catalog_name: z.string().optional(), + schema_name_pattern: z.string().optional(), + table_name_pattern: z.string().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + include_manifest_capabilities: z.boolean().optional(), + }) + .transform(d => ({ + catalogName: d.catalog_name, + schemaNamePattern: d.schema_name_pattern, + tableNamePattern: d.table_name_pattern, + maxResults: d.max_results, + pageToken: d.page_token, + includeManifestCapabilities: d.include_manifest_capabilities, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListTableSummaries_ResponseSchema: z.ZodType = - z - .object({ - tables: z.array(z.lazy(() => unmarshalTableSummarySchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - tables: d.tables, - nextPageToken: d.next_page_token, - })); +export const unmarshalListTableSummaries_ResponseSchema: z.ZodType = z + .object({ + tables: z.array(z.lazy(() => unmarshalTableSummarySchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + tables: d.tables, + nextPageToken: d.next_page_token, + })); export const unmarshalListTablesSchema: z.ZodType = z .object({ @@ -1252,25 +1241,23 @@ export const unmarshalListTablesSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListTables_ResponseSchema: z.ZodType = - z - .object({ - tables: z.array(z.lazy(() => unmarshalTableInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - tables: d.tables, - nextPageToken: d.next_page_token, - })); - -export const unmarshalNamedTableConstraintSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalListTables_ResponseSchema: z.ZodType = z + .object({ + tables: z.array(z.lazy(() => unmarshalTableInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + tables: d.tables, + nextPageToken: d.next_page_token, + })); + +export const unmarshalNamedTableConstraintSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const unmarshalOptionSpecSchema: z.ZodType = z .object({ @@ -1288,9 +1275,7 @@ export const unmarshalOptionSpecSchema: z.ZodType = z is_loggable: z.boolean().optional(), is_creatable: z.boolean().optional(), is_copiable: z.boolean().optional(), - conditional_display: z - .lazy(() => unmarshalConditionalDisplaySchema) - .optional(), + conditional_display: z.lazy(() => unmarshalConditionalDisplaySchema).optional(), }) .transform(d => ({ name: d.name, @@ -1310,39 +1295,35 @@ export const unmarshalOptionSpecSchema: z.ZodType = z conditionalDisplay: d.conditional_display, })); -export const unmarshalPolicyFunctionArgumentSchema: z.ZodType = - z - .object({ - column: z.string().optional(), - constant: z.string().optional(), - }) - .transform(d => ({ - column: d.column, - constant: d.constant, - })); - -export const unmarshalPrimaryKeyConstraintSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - child_columns: z.array(z.string()).optional(), - timeseries_columns: z.array(z.string()).optional(), - rely: z.boolean().optional(), - }) - .transform(d => ({ - name: d.name, - childColumns: d.child_columns, - timeseriesColumns: d.timeseries_columns, - rely: d.rely, - })); +export const unmarshalPolicyFunctionArgumentSchema: z.ZodType = z + .object({ + column: z.string().optional(), + constant: z.string().optional(), + }) + .transform(d => ({ + column: d.column, + constant: d.constant, + })); + +export const unmarshalPrimaryKeyConstraintSchema: z.ZodType = z + .object({ + name: z.string().optional(), + child_columns: z.array(z.string()).optional(), + timeseries_columns: z.array(z.string()).optional(), + rely: z.boolean().optional(), + }) + .transform(d => ({ + name: d.name, + childColumns: d.child_columns, + timeseriesColumns: d.timeseries_columns, + rely: d.rely, + })); export const unmarshalRowFilterSchema: z.ZodType = z .object({ function_name: z.string().optional(), input_column_names: z.array(z.string()).optional(), - input_arguments: z - .array(z.lazy(() => unmarshalPolicyFunctionArgumentSchema)) - .optional(), + input_arguments: z.array(z.lazy(() => unmarshalPolicyFunctionArgumentSchema)).optional(), }) .transform(d => ({ functionName: d.function_name, @@ -1350,45 +1331,45 @@ export const unmarshalRowFilterSchema: z.ZodType = z inputArguments: d.input_arguments, })); -export const unmarshalSecurableKindManifestSchema: z.ZodType = - z - .object({ - securable_type: z.enum(SecurableType).optional(), - securable_kind: z.enum(SecurableKind).optional(), - assignable_privileges: z.array(z.string()).optional(), - options: z.array(z.lazy(() => unmarshalOptionSpecSchema)).optional(), - capabilities: z.array(z.string()).optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - securableKind: d.securable_kind, - assignablePrivileges: d.assignable_privileges, - options: d.options, - capabilities: d.capabilities, - })); - -export const unmarshalSseEncryptionDetailsSchema: z.ZodType = - z - .object({ - algorithm: z.enum(SseEncryptionAlgorithm).optional(), - aws_kms_key_arn: z.string().optional(), - }) - .transform(d => ({ - algorithm: d.algorithm, - awsKmsKeyArn: d.aws_kms_key_arn, - })); +export const unmarshalSecretDependencySchema: z.ZodType = z + .object({ + secret_full_name: z.string().optional(), + }) + .transform(d => ({ + secretFullName: d.secret_full_name, + })); + +export const unmarshalSecurableKindManifestSchema: z.ZodType = z + .object({ + securable_type: z.enum(SecurableType).optional(), + securable_kind: z.enum(SecurableKind).optional(), + assignable_privileges: z.array(z.string()).optional(), + options: z.array(z.lazy(() => unmarshalOptionSpecSchema)).optional(), + capabilities: z.array(z.string()).optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + securableKind: d.securable_kind, + assignablePrivileges: d.assignable_privileges, + options: d.options, + capabilities: d.capabilities, + })); + +export const unmarshalSseEncryptionDetailsSchema: z.ZodType = z + .object({ + algorithm: z.enum(SseEncryptionAlgorithm).optional(), + aws_kms_key_arn: z.string().optional(), + }) + .transform(d => ({ + algorithm: d.algorithm, + awsKmsKeyArn: d.aws_kms_key_arn, + })); export const unmarshalTableConstraintSchema: z.ZodType = z .object({ - primary_key_constraint: z - .lazy(() => unmarshalPrimaryKeyConstraintSchema) - .optional(), - foreign_key_constraint: z - .lazy(() => unmarshalForeignKeyConstraintSchema) - .optional(), - named_table_constraint: z - .lazy(() => unmarshalNamedTableConstraintSchema) - .optional(), + primary_key_constraint: z.lazy(() => unmarshalPrimaryKeyConstraintSchema).optional(), + foreign_key_constraint: z.lazy(() => unmarshalForeignKeyConstraintSchema).optional(), + named_table_constraint: z.lazy(() => unmarshalNamedTableConstraintSchema).optional(), }) .transform(d => ({ primaryKeyConstraint: d.primary_key_constraint, @@ -1413,14 +1394,13 @@ export const unmarshalTableExistsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalTableExists_ResponseSchema: z.ZodType = - z - .object({ - table_exists: z.boolean().optional(), - }) - .transform(d => ({ - tableExists: d.table_exists, - })); +export const unmarshalTableExists_ResponseSchema: z.ZodType = z + .object({ + table_exists: z.boolean().optional(), + }) + .transform(d => ({ + tableExists: d.table_exists, + })); export const unmarshalTableInfoSchema: z.ZodType = z .object({ @@ -1436,9 +1416,7 @@ export const unmarshalTableInfoSchema: z.ZodType = z owner: z.string().optional(), comment: z.string().optional(), storage_credential_name: z.string().optional(), - table_constraints: z - .array(z.lazy(() => unmarshalTableConstraintSchema)) - .optional(), + table_constraints: z.array(z.lazy(() => unmarshalTableConstraintSchema)).optional(), row_filter: z.lazy(() => unmarshalRowFilterSchema).optional(), pipeline_id: z.string().optional(), enable_predictive_optimization: z.string().optional(), @@ -1450,21 +1428,13 @@ export const unmarshalTableInfoSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), table_id: z.string().optional(), - delta_runtime_properties_kvpairs: z - .lazy(() => unmarshalDeltaRuntimePropertiesKvPairsSchema) - .optional(), + delta_runtime_properties_kvpairs: z.lazy(() => unmarshalDeltaRuntimePropertiesKvPairsSchema).optional(), deleted_at: z.number().optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), access_point: z.string().optional(), browse_only: z.boolean().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), - securable_kind_manifest: z - .lazy(() => unmarshalSecurableKindManifestSchema) - .optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), + securable_kind_manifest: z.lazy(() => unmarshalSecurableKindManifestSchema).optional(), columns: z.array(z.lazy(() => unmarshalColumnInfoSchema)).optional(), properties: z.record(z.string(), z.string()).optional(), }) @@ -1495,8 +1465,7 @@ export const unmarshalTableInfoSchema: z.ZodType = z tableId: d.table_id, deltaRuntimePropertiesKvpairs: d.delta_runtime_properties_kvpairs, deletedAt: d.deleted_at, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, accessPoint: d.access_point, browseOnly: d.browse_only, encryptionDetails: d.encryption_details, @@ -1506,24 +1475,21 @@ export const unmarshalTableInfoSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalTableInfo_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalTableInfo_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const unmarshalTableSummarySchema: z.ZodType = z .object({ full_name: z.string().optional(), table_type: z.enum(TableType).optional(), - securable_kind_manifest: z - .lazy(() => unmarshalSecurableKindManifestSchema) - .optional(), + securable_kind_manifest: z.lazy(() => unmarshalSecurableKindManifestSchema).optional(), }) .transform(d => ({ fullName: d.full_name, @@ -1546,9 +1512,7 @@ export const unmarshalUpdateTableSchema: z.ZodType = z owner: z.string().optional(), comment: z.string().optional(), storage_credential_name: z.string().optional(), - table_constraints: z - .array(z.lazy(() => unmarshalTableConstraintSchema)) - .optional(), + table_constraints: z.array(z.lazy(() => unmarshalTableConstraintSchema)).optional(), row_filter: z.lazy(() => unmarshalRowFilterSchema).optional(), pipeline_id: z.string().optional(), enable_predictive_optimization: z.string().optional(), @@ -1560,21 +1524,13 @@ export const unmarshalUpdateTableSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), table_id: z.string().optional(), - delta_runtime_properties_kvpairs: z - .lazy(() => unmarshalDeltaRuntimePropertiesKvPairsSchema) - .optional(), + delta_runtime_properties_kvpairs: z.lazy(() => unmarshalDeltaRuntimePropertiesKvPairsSchema).optional(), deleted_at: z.number().optional(), - effective_predictive_optimization_flag: z - .lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effective_predictive_optimization_flag: z.lazy(() => unmarshalEffectivePredictiveOptimizationFlagSchema).optional(), access_point: z.string().optional(), browse_only: z.boolean().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), - securable_kind_manifest: z - .lazy(() => unmarshalSecurableKindManifestSchema) - .optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), + securable_kind_manifest: z.lazy(() => unmarshalSecurableKindManifestSchema).optional(), columns: z.array(z.lazy(() => unmarshalColumnInfoSchema)).optional(), properties: z.record(z.string(), z.string()).optional(), }) @@ -1606,8 +1562,7 @@ export const unmarshalUpdateTableSchema: z.ZodType = z tableId: d.table_id, deltaRuntimePropertiesKvpairs: d.delta_runtime_properties_kvpairs, deletedAt: d.deleted_at, - effectivePredictiveOptimizationFlag: - d.effective_predictive_optimization_flag, + effectivePredictiveOptimizationFlag: d.effective_predictive_optimization_flag, accessPoint: d.access_point, browseOnly: d.browse_only, encryptionDetails: d.encryption_details, @@ -1617,20 +1572,28 @@ export const unmarshalUpdateTableSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateTable_PropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const unmarshalUpdateTable_PropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateTable_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalUpdateTable_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalVolumeDependencySchema: z.ZodType = z + .object({ + volume_full_name: z.string().optional(), + }) + .transform(d => ({ + volumeFullName: d.volume_full_name, + })); export const marshalColumnInfoSchema: z.ZodType = z .object({ @@ -1666,9 +1629,7 @@ export const marshalColumnMaskSchema: z.ZodType = z .object({ functionName: z.string().optional(), usingColumnNames: z.array(z.string()).optional(), - usingArguments: z - .array(z.lazy(() => marshalPolicyFunctionArgumentSchema)) - .optional(), + usingArguments: z.array(z.lazy(() => marshalPolicyFunctionArgumentSchema)).optional(), }) .transform(d => ({ function_name: d.functionName, @@ -1708,9 +1669,7 @@ export const marshalCreateTableSchema: z.ZodType = z owner: z.string().optional(), comment: z.string().optional(), storageCredentialName: z.string().optional(), - tableConstraints: z - .array(z.lazy(() => marshalTableConstraintSchema)) - .optional(), + tableConstraints: z.array(z.lazy(() => marshalTableConstraintSchema)).optional(), rowFilter: z.lazy(() => marshalRowFilterSchema).optional(), pipelineId: z.string().optional(), enablePredictiveOptimization: z.string().optional(), @@ -1722,19 +1681,13 @@ export const marshalCreateTableSchema: z.ZodType = z updatedAt: z.number().optional(), updatedBy: z.string().optional(), tableId: z.string().optional(), - deltaRuntimePropertiesKvpairs: z - .lazy(() => marshalDeltaRuntimePropertiesKvPairsSchema) - .optional(), + deltaRuntimePropertiesKvpairs: z.lazy(() => marshalDeltaRuntimePropertiesKvPairsSchema).optional(), deletedAt: z.number().optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), accessPoint: z.string().optional(), browseOnly: z.boolean().optional(), encryptionDetails: z.lazy(() => marshalEncryptionDetailsSchema).optional(), - securableKindManifest: z - .lazy(() => marshalSecurableKindManifestSchema) - .optional(), + securableKindManifest: z.lazy(() => marshalSecurableKindManifestSchema).optional(), columns: z.array(z.lazy(() => marshalColumnInfoSchema)).optional(), properties: z.record(z.string(), z.string()).optional(), }) @@ -1765,8 +1718,7 @@ export const marshalCreateTableSchema: z.ZodType = z table_id: d.tableId, delta_runtime_properties_kvpairs: d.deltaRuntimePropertiesKvpairs, deleted_at: d.deletedAt, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, access_point: d.accessPoint, browse_only: d.browseOnly, encryption_details: d.encryptionDetails, @@ -1813,7 +1765,9 @@ export const marshalDeleteTableSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteTable_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteTable_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeleteTableConstraintSchema: z.ZodType = z .object({ @@ -1828,9 +1782,9 @@ export const marshalDeleteTableConstraintSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteTableConstraint_ResponseSchema: z.ZodType = z.object( - {} -); +export const marshalDeleteTableConstraint_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalDeltaRuntimePropertiesKvPairsSchema: z.ZodType = z .object({ @@ -1841,16 +1795,15 @@ export const marshalDeltaRuntimePropertiesKvPairsSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeltaRuntimePropertiesKvPairs_DeltaRuntimePropertiesEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); +export const marshalDeltaRuntimePropertiesKvPairs_DeltaRuntimePropertiesEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); export const marshalDependencySchema: z.ZodType = z .object({ @@ -1858,12 +1811,16 @@ export const marshalDependencySchema: z.ZodType = z function: z.lazy(() => marshalFunctionDependencySchema).optional(), connection: z.lazy(() => marshalConnectionDependencySchema).optional(), credential: z.lazy(() => marshalCredentialDependencySchema).optional(), + volume: z.lazy(() => marshalVolumeDependencySchema).optional(), + secret: z.lazy(() => marshalSecretDependencySchema).optional(), }) .transform(d => ({ table: d.table, function: d.function, connection: d.connection, credential: d.credential, + volume: d.volume, + secret: d.secret, })); export const marshalDependencyListSchema: z.ZodType = z @@ -1888,9 +1845,7 @@ export const marshalEffectivePredictiveOptimizationFlagSchema: z.ZodType = z export const marshalEncryptionDetailsSchema: z.ZodType = z .object({ - sseEncryptionDetails: z - .lazy(() => marshalSseEncryptionDetailsSchema) - .optional(), + sseEncryptionDetails: z.lazy(() => marshalSseEncryptionDetailsSchema).optional(), }) .transform(d => ({ sse_encryption_details: d.sseEncryptionDetails, @@ -2022,9 +1977,7 @@ export const marshalOptionSpecSchema: z.ZodType = z isLoggable: z.boolean().optional(), isCreatable: z.boolean().optional(), isCopiable: z.boolean().optional(), - conditionalDisplay: z - .lazy(() => marshalConditionalDisplaySchema) - .optional(), + conditionalDisplay: z.lazy(() => marshalConditionalDisplaySchema).optional(), }) .transform(d => ({ name: d.name, @@ -2072,9 +2025,7 @@ export const marshalRowFilterSchema: z.ZodType = z .object({ functionName: z.string().optional(), inputColumnNames: z.array(z.string()).optional(), - inputArguments: z - .array(z.lazy(() => marshalPolicyFunctionArgumentSchema)) - .optional(), + inputArguments: z.array(z.lazy(() => marshalPolicyFunctionArgumentSchema)).optional(), }) .transform(d => ({ function_name: d.functionName, @@ -2082,6 +2033,14 @@ export const marshalRowFilterSchema: z.ZodType = z input_arguments: d.inputArguments, })); +export const marshalSecretDependencySchema: z.ZodType = z + .object({ + secretFullName: z.string().optional(), + }) + .transform(d => ({ + secret_full_name: d.secretFullName, + })); + export const marshalSecurableKindManifestSchema: z.ZodType = z .object({ securableType: z.enum(SecurableType).optional(), @@ -2110,15 +2069,9 @@ export const marshalSseEncryptionDetailsSchema: z.ZodType = z export const marshalTableConstraintSchema: z.ZodType = z .object({ - primaryKeyConstraint: z - .lazy(() => marshalPrimaryKeyConstraintSchema) - .optional(), - foreignKeyConstraint: z - .lazy(() => marshalForeignKeyConstraintSchema) - .optional(), - namedTableConstraint: z - .lazy(() => marshalNamedTableConstraintSchema) - .optional(), + primaryKeyConstraint: z.lazy(() => marshalPrimaryKeyConstraintSchema).optional(), + foreignKeyConstraint: z.lazy(() => marshalForeignKeyConstraintSchema).optional(), + namedTableConstraint: z.lazy(() => marshalNamedTableConstraintSchema).optional(), }) .transform(d => ({ primary_key_constraint: d.primaryKeyConstraint, @@ -2165,9 +2118,7 @@ export const marshalTableInfoSchema: z.ZodType = z owner: z.string().optional(), comment: z.string().optional(), storageCredentialName: z.string().optional(), - tableConstraints: z - .array(z.lazy(() => marshalTableConstraintSchema)) - .optional(), + tableConstraints: z.array(z.lazy(() => marshalTableConstraintSchema)).optional(), rowFilter: z.lazy(() => marshalRowFilterSchema).optional(), pipelineId: z.string().optional(), enablePredictiveOptimization: z.string().optional(), @@ -2179,19 +2130,13 @@ export const marshalTableInfoSchema: z.ZodType = z updatedAt: z.number().optional(), updatedBy: z.string().optional(), tableId: z.string().optional(), - deltaRuntimePropertiesKvpairs: z - .lazy(() => marshalDeltaRuntimePropertiesKvPairsSchema) - .optional(), + deltaRuntimePropertiesKvpairs: z.lazy(() => marshalDeltaRuntimePropertiesKvPairsSchema).optional(), deletedAt: z.number().optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), accessPoint: z.string().optional(), browseOnly: z.boolean().optional(), encryptionDetails: z.lazy(() => marshalEncryptionDetailsSchema).optional(), - securableKindManifest: z - .lazy(() => marshalSecurableKindManifestSchema) - .optional(), + securableKindManifest: z.lazy(() => marshalSecurableKindManifestSchema).optional(), columns: z.array(z.lazy(() => marshalColumnInfoSchema)).optional(), properties: z.record(z.string(), z.string()).optional(), }) @@ -2222,8 +2167,7 @@ export const marshalTableInfoSchema: z.ZodType = z table_id: d.tableId, delta_runtime_properties_kvpairs: d.deltaRuntimePropertiesKvpairs, deleted_at: d.deletedAt, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, access_point: d.accessPoint, browse_only: d.browseOnly, encryption_details: d.encryptionDetails, @@ -2247,9 +2191,7 @@ export const marshalTableSummarySchema: z.ZodType = z .object({ fullName: z.string().optional(), tableType: z.enum(TableType).optional(), - securableKindManifest: z - .lazy(() => marshalSecurableKindManifestSchema) - .optional(), + securableKindManifest: z.lazy(() => marshalSecurableKindManifestSchema).optional(), }) .transform(d => ({ full_name: d.fullName, @@ -2272,9 +2214,7 @@ export const marshalUpdateTableSchema: z.ZodType = z owner: z.string().optional(), comment: z.string().optional(), storageCredentialName: z.string().optional(), - tableConstraints: z - .array(z.lazy(() => marshalTableConstraintSchema)) - .optional(), + tableConstraints: z.array(z.lazy(() => marshalTableConstraintSchema)).optional(), rowFilter: z.lazy(() => marshalRowFilterSchema).optional(), pipelineId: z.string().optional(), enablePredictiveOptimization: z.string().optional(), @@ -2286,19 +2226,13 @@ export const marshalUpdateTableSchema: z.ZodType = z updatedAt: z.number().optional(), updatedBy: z.string().optional(), tableId: z.string().optional(), - deltaRuntimePropertiesKvpairs: z - .lazy(() => marshalDeltaRuntimePropertiesKvPairsSchema) - .optional(), + deltaRuntimePropertiesKvpairs: z.lazy(() => marshalDeltaRuntimePropertiesKvPairsSchema).optional(), deletedAt: z.number().optional(), - effectivePredictiveOptimizationFlag: z - .lazy(() => marshalEffectivePredictiveOptimizationFlagSchema) - .optional(), + effectivePredictiveOptimizationFlag: z.lazy(() => marshalEffectivePredictiveOptimizationFlagSchema).optional(), accessPoint: z.string().optional(), browseOnly: z.boolean().optional(), encryptionDetails: z.lazy(() => marshalEncryptionDetailsSchema).optional(), - securableKindManifest: z - .lazy(() => marshalSecurableKindManifestSchema) - .optional(), + securableKindManifest: z.lazy(() => marshalSecurableKindManifestSchema).optional(), columns: z.array(z.lazy(() => marshalColumnInfoSchema)).optional(), properties: z.record(z.string(), z.string()).optional(), }) @@ -2330,8 +2264,7 @@ export const marshalUpdateTableSchema: z.ZodType = z table_id: d.tableId, delta_runtime_properties_kvpairs: d.deltaRuntimePropertiesKvpairs, deleted_at: d.deletedAt, - effective_predictive_optimization_flag: - d.effectivePredictiveOptimizationFlag, + effective_predictive_optimization_flag: d.effectivePredictiveOptimizationFlag, access_point: d.accessPoint, browse_only: d.browseOnly, encryption_details: d.encryptionDetails, @@ -2352,4 +2285,14 @@ export const marshalUpdateTable_PropertiesEntrySchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalUpdateTable_ResponseSchema: z.ZodType = z.object({}); +export const marshalUpdateTable_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalVolumeDependencySchema: z.ZodType = z + .object({ + volumeFullName: z.string().optional(), + }) + .transform(d => ({ + volume_full_name: d.volumeFullName, + })); diff --git a/packages/tables/src/v1/utils.ts b/packages/tables/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/tables/src/v1/utils.ts +++ b/packages/tables/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/tables/tsconfig.json b/packages/tables/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/tables/tsconfig.json +++ b/packages/tables/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/tagassignments/package.json b/packages/tagassignments/package.json index 960d22ac..a1455559 100644 --- a/packages/tagassignments/package.json +++ b/packages/tagassignments/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/tagassignments/src/v1/client.ts b/packages/tagassignments/src/v1/client.ts index 7d864cc8..2330267e 100644 --- a/packages/tagassignments/src/v1/client.ts +++ b/packages/tagassignments/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateTagAssignmentRequest, DeleteTagAssignmentRequest, @@ -43,21 +38,13 @@ export class Client { } /** Create a tag assignment */ - async createTagAssignment( - signal: AbortSignal | undefined, - req: CreateTagAssignmentRequest, - options?: Options - ): Promise { + async createTagAssignment(signal: AbortSignal | undefined, req: CreateTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/entity-tag-assignments`; const body = marshalRequest(req.tagAssignment, marshalTagAssignmentSchema); let resp: TagAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTagAssignmentSchema); }; await execute(signal, call, options); @@ -68,38 +55,22 @@ export class Client { } /** Delete a tag assignment */ - async deleteTagAssignment( - signal: AbortSignal | undefined, - req: DeleteTagAssignmentRequest, - options?: Options - ): Promise { + async deleteTagAssignment(signal: AbortSignal | undefined, req: DeleteTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/entity-tag-assignments/${req.entityType ?? ''}/${req.entityId ?? ''}/tags/${req.tagKey ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Get a tag assignment */ - async getTagAssignment( - signal: AbortSignal | undefined, - req: GetTagAssignmentRequest, - options?: Options - ): Promise { + async getTagAssignment(signal: AbortSignal | undefined, req: GetTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/entity-tag-assignments/${req.entityType ?? ''}/${req.entityId ?? ''}/tags/${req.tagKey ?? ''}`; let resp: TagAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTagAssignmentSchema); }; await execute(signal, call, options); @@ -110,11 +81,7 @@ export class Client { } /** List the tag assignments for an entity */ - async listTagAssignments( - signal: AbortSignal | undefined, - req: ListTagAssignmentsRequest, - options?: Options - ): Promise { + async listTagAssignments(signal: AbortSignal | undefined, req: ListTagAssignmentsRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/entity-tag-assignments/${req.entityType ?? ''}/${req.entityId ?? ''}/tags`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -128,11 +95,7 @@ export class Client { let resp: ListTagAssignmentsResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListTagAssignmentsResponseSchema); }; await execute(signal, call, options); @@ -142,11 +105,8 @@ export class Client { return resp; } - async *listTagAssignmentsIter( - signal: AbortSignal | undefined, - req: ListTagAssignmentsRequest, - options?: Options - ): AsyncGenerator { + + async *listTagAssignmentsIter(signal: AbortSignal | undefined, req: ListTagAssignmentsRequest, options?: Options): AsyncGenerator { const pageReq: ListTagAssignmentsRequest = {...req}; for (;;) { const resp = await this.listTagAssignments(signal, pageReq, options); @@ -160,16 +120,13 @@ export class Client { } } + /** Update a tag assignment */ - async updateTagAssignment( - signal: AbortSignal | undefined, - req: UpdateTagAssignmentRequest, - options?: Options - ): Promise { + async updateTagAssignment(signal: AbortSignal | undefined, req: UpdateTagAssignmentRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/entity-tag-assignments/${req.tagAssignment?.entityType ?? ''}/${req.tagAssignment?.entityId ?? ''}/tags/${req.tagAssignment?.tagKey ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -177,11 +134,7 @@ export class Client { let resp: TagAssignment | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTagAssignmentSchema); }; await execute(signal, call, options); diff --git a/packages/tagassignments/src/v1/index.ts b/packages/tagassignments/src/v1/index.ts index fcd9d0cd..30c39d33 100644 --- a/packages/tagassignments/src/v1/index.ts +++ b/packages/tagassignments/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { CreateTagAssignmentRequest, diff --git a/packages/tagassignments/src/v1/model.ts b/packages/tagassignments/src/v1/model.ts index 7e2884c8..2dbff1cf 100644 --- a/packages/tagassignments/src/v1/model.ts +++ b/packages/tagassignments/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export interface CreateTagAssignmentRequest { @@ -54,71 +55,64 @@ export interface TagAssignment { export interface UpdateTagAssignmentRequest { tagAssignment?: TagAssignment | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } -export const unmarshalCreateTagAssignmentRequestSchema: z.ZodType = - z - .object({ - tag_assignment: z.lazy(() => unmarshalTagAssignmentSchema).optional(), - }) - .transform(d => ({ - tagAssignment: d.tag_assignment, - })); - -export const unmarshalDeleteTagAssignmentRequestSchema: z.ZodType = - z - .object({ - entity_type: z.string().optional(), - entity_id: z.string().optional(), - tag_key: z.string().optional(), - }) - .transform(d => ({ - entityType: d.entity_type, - entityId: d.entity_id, - tagKey: d.tag_key, - })); - -export const unmarshalGetTagAssignmentRequestSchema: z.ZodType = - z - .object({ - entity_type: z.string().optional(), - entity_id: z.string().optional(), - tag_key: z.string().optional(), - }) - .transform(d => ({ - entityType: d.entity_type, - entityId: d.entity_id, - tagKey: d.tag_key, - })); - -export const unmarshalListTagAssignmentsRequestSchema: z.ZodType = - z - .object({ - entity_type: z.string().optional(), - entity_id: z.string().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - entityType: d.entity_type, - entityId: d.entity_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListTagAssignmentsResponseSchema: z.ZodType = - z - .object({ - tag_assignments: z - .array(z.lazy(() => unmarshalTagAssignmentSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - tagAssignments: d.tag_assignments, - nextPageToken: d.next_page_token, - })); +export const unmarshalCreateTagAssignmentRequestSchema: z.ZodType = z + .object({ + tag_assignment: z.lazy(() => unmarshalTagAssignmentSchema).optional(), + }) + .transform(d => ({ + tagAssignment: d.tag_assignment, + })); + +export const unmarshalDeleteTagAssignmentRequestSchema: z.ZodType = z + .object({ + entity_type: z.string().optional(), + entity_id: z.string().optional(), + tag_key: z.string().optional(), + }) + .transform(d => ({ + entityType: d.entity_type, + entityId: d.entity_id, + tagKey: d.tag_key, + })); + +export const unmarshalGetTagAssignmentRequestSchema: z.ZodType = z + .object({ + entity_type: z.string().optional(), + entity_id: z.string().optional(), + tag_key: z.string().optional(), + }) + .transform(d => ({ + entityType: d.entity_type, + entityId: d.entity_id, + tagKey: d.tag_key, + })); + +export const unmarshalListTagAssignmentsRequestSchema: z.ZodType = z + .object({ + entity_type: z.string().optional(), + entity_id: z.string().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + entityType: d.entity_type, + entityId: d.entity_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListTagAssignmentsResponseSchema: z.ZodType = z + .object({ + tag_assignments: z.array(z.lazy(() => unmarshalTagAssignmentSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + tagAssignments: d.tag_assignments, + nextPageToken: d.next_page_token, + })); export const unmarshalTagAssignmentSchema: z.ZodType = z .object({ @@ -134,16 +128,15 @@ export const unmarshalTagAssignmentSchema: z.ZodType = z tagValue: d.tag_value, })); -export const unmarshalUpdateTagAssignmentRequestSchema: z.ZodType = - z - .object({ - tag_assignment: z.lazy(() => unmarshalTagAssignmentSchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - tagAssignment: d.tag_assignment, - updateMask: d.update_mask, - })); +export const unmarshalUpdateTagAssignmentRequestSchema: z.ZodType = z + .object({ + tag_assignment: z.lazy(() => unmarshalTagAssignmentSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + tagAssignment: d.tag_assignment, + updateMask: d.update_mask, + })); export const marshalCreateTagAssignmentRequestSchema: z.ZodType = z .object({ @@ -193,9 +186,7 @@ export const marshalListTagAssignmentsRequestSchema: z.ZodType = z export const marshalListTagAssignmentsResponseSchema: z.ZodType = z .object({ - tagAssignments: z - .array(z.lazy(() => marshalTagAssignmentSchema)) - .optional(), + tagAssignments: z.array(z.lazy(() => marshalTagAssignmentSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -220,7 +211,7 @@ export const marshalTagAssignmentSchema: z.ZodType = z export const marshalUpdateTagAssignmentRequestSchema: z.ZodType = z .object({ tagAssignment: z.lazy(() => marshalTagAssignmentSchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ tag_assignment: d.tagAssignment, diff --git a/packages/tagassignments/src/v1/utils.ts b/packages/tagassignments/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/tagassignments/src/v1/utils.ts +++ b/packages/tagassignments/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/tagassignments/tsconfig.json b/packages/tagassignments/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/tagassignments/tsconfig.json +++ b/packages/tagassignments/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/tagpolicies/package.json b/packages/tagpolicies/package.json index 77e4e818..3c9518be 100644 --- a/packages/tagpolicies/package.json +++ b/packages/tagpolicies/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/tagpolicies/src/v1/client.ts b/packages/tagpolicies/src/v1/client.ts index 758f6551..88b624e6 100644 --- a/packages/tagpolicies/src/v1/client.ts +++ b/packages/tagpolicies/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateTagPolicyRequest, DeleteTagPolicyRequest, @@ -43,21 +38,13 @@ export class Client { } /** Creates a new tag policy, making the associated tag key governed. For Terraform usage, see the [Tag Policy Terraform documentation](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/tag_policy). To manage permissions for tag policies, use the [Account Access Control Proxy API](https://docs.databricks.com/api/workspace/accountaccesscontrolproxy). */ - async createTagPolicy( - signal: AbortSignal | undefined, - req: CreateTagPolicyRequest, - options?: Options - ): Promise { + async createTagPolicy(signal: AbortSignal | undefined, req: CreateTagPolicyRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/tag-policies`; const body = marshalRequest(req.tagPolicy, marshalTagPolicySchema); let resp: TagPolicy | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTagPolicySchema); }; await execute(signal, call, options); @@ -68,38 +55,22 @@ export class Client { } /** Deletes a tag policy by its associated governed tag's key, leaving that tag key ungoverned. For Terraform usage, see the [Tag Policy Terraform documentation](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/tag_policy). */ - async deleteTagPolicy( - signal: AbortSignal | undefined, - req: DeleteTagPolicyRequest, - options?: Options - ): Promise { + async deleteTagPolicy(signal: AbortSignal | undefined, req: DeleteTagPolicyRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/tag-policies/${req.tagKey ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Gets a single tag policy by its associated governed tag's key. For Terraform usage, see the [Tag Policy Terraform documentation](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/tag_policy). To list granted permissions for tag policies, use the [Account Access Control Proxy API](https://docs.databricks.com/api/workspace/accountaccesscontrolproxy). */ - async getTagPolicy( - signal: AbortSignal | undefined, - req: GetTagPolicyRequest, - options?: Options - ): Promise { + async getTagPolicy(signal: AbortSignal | undefined, req: GetTagPolicyRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/tag-policies/${req.tagKey ?? ''}`; let resp: TagPolicy | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTagPolicySchema); }; await execute(signal, call, options); @@ -110,11 +81,7 @@ export class Client { } /** Lists the tag policies for all governed tags in the account. For Terraform usage, see the [Tag Policy Terraform documentation](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/tag_policies). To list granted permissions for tag policies, use the [Account Access Control Proxy API](https://docs.databricks.com/api/workspace/accountaccesscontrolproxy). */ - async listTagPolicies( - signal: AbortSignal | undefined, - req: ListTagPoliciesRequest, - options?: Options - ): Promise { + async listTagPolicies(signal: AbortSignal | undefined, req: ListTagPoliciesRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/tag-policies`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -128,11 +95,7 @@ export class Client { let resp: ListTagPoliciesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListTagPoliciesResponseSchema); }; await execute(signal, call, options); @@ -142,11 +105,8 @@ export class Client { return resp; } - async *listTagPoliciesIter( - signal: AbortSignal | undefined, - req: ListTagPoliciesRequest, - options?: Options - ): AsyncGenerator { + + async *listTagPoliciesIter(signal: AbortSignal | undefined, req: ListTagPoliciesRequest, options?: Options): AsyncGenerator { const pageReq: ListTagPoliciesRequest = {...req}; for (;;) { const resp = await this.listTagPolicies(signal, pageReq, options); @@ -160,16 +120,13 @@ export class Client { } } + /** Updates an existing tag policy for a single governed tag. For Terraform usage, see the [Tag Policy Terraform documentation](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/tag_policy). To manage permissions for tag policies, use the [Account Access Control Proxy API](https://docs.databricks.com/api/workspace/accountaccesscontrolproxy). */ - async updateTagPolicy( - signal: AbortSignal | undefined, - req: UpdateTagPolicyRequest, - options?: Options - ): Promise { + async updateTagPolicy(signal: AbortSignal | undefined, req: UpdateTagPolicyRequest, options?: Options): Promise { const url = `${this.host}/api/2.1/tag-policies/${req.tagPolicy?.tagKey ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; @@ -177,11 +134,7 @@ export class Client { let resp: TagPolicy | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalTagPolicySchema); }; await execute(signal, call, options); diff --git a/packages/tagpolicies/src/v1/index.ts b/packages/tagpolicies/src/v1/index.ts index 035f81f3..0b419b89 100644 --- a/packages/tagpolicies/src/v1/index.ts +++ b/packages/tagpolicies/src/v1/index.ts @@ -1,8 +1,10 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; export type { ConflictResolutionPolicy, diff --git a/packages/tagpolicies/src/v1/model.ts b/packages/tagpolicies/src/v1/model.ts index 7d59ed65..643ec8df 100644 --- a/packages/tagpolicies/src/v1/model.ts +++ b/packages/tagpolicies/src/v1/model.ts @@ -1,6 +1,8 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + import {Temporal} from '@js-temporal/polyfill'; +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; /** Policy that determines how to resolve conflicts when multiple upstream sources have different tag values. */ @@ -68,88 +70,77 @@ export interface TagPolicy { export interface UpdateTagPolicyRequest { tagPolicy?: TagPolicy | undefined; - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; } export interface Value { name?: string | undefined; } -export const unmarshalConflictResolutionPolicySchema: z.ZodType = - z - .object({ - default_value_override: z - .lazy(() => unmarshalDefaultValueOverridePolicySchema) - .optional(), - }) - .transform(d => ({ - defaultValueOverride: d.default_value_override, - })); - -export const unmarshalCreateTagPolicyRequestSchema: z.ZodType = - z - .object({ - tag_policy: z.lazy(() => unmarshalTagPolicySchema).optional(), - }) - .transform(d => ({ - tagPolicy: d.tag_policy, - })); - -export const unmarshalDefaultValueOverridePolicySchema: z.ZodType = - z - .object({ - default_value: z.string().optional(), - }) - .transform(d => ({ - defaultValue: d.default_value, - })); - -export const unmarshalDeleteTagPolicyRequestSchema: z.ZodType = - z - .object({ - tag_key: z.string().optional(), - }) - .transform(d => ({ - tagKey: d.tag_key, - })); - -export const unmarshalGetTagPolicyRequestSchema: z.ZodType = - z - .object({ - tag_key: z.string().optional(), - }) - .transform(d => ({ - tagKey: d.tag_key, - })); - -export const unmarshalListTagPoliciesRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListTagPoliciesResponseSchema: z.ZodType = - z - .object({ - tag_policies: z.array(z.lazy(() => unmarshalTagPolicySchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - tagPolicies: d.tag_policies, - nextPageToken: d.next_page_token, - })); +export const unmarshalConflictResolutionPolicySchema: z.ZodType = z + .object({ + default_value_override: z.lazy(() => unmarshalDefaultValueOverridePolicySchema).optional(), + }) + .transform(d => ({ + defaultValueOverride: d.default_value_override, + })); + +export const unmarshalCreateTagPolicyRequestSchema: z.ZodType = z + .object({ + tag_policy: z.lazy(() => unmarshalTagPolicySchema).optional(), + }) + .transform(d => ({ + tagPolicy: d.tag_policy, + })); + +export const unmarshalDefaultValueOverridePolicySchema: z.ZodType = z + .object({ + default_value: z.string().optional(), + }) + .transform(d => ({ + defaultValue: d.default_value, + })); + +export const unmarshalDeleteTagPolicyRequestSchema: z.ZodType = z + .object({ + tag_key: z.string().optional(), + }) + .transform(d => ({ + tagKey: d.tag_key, + })); + +export const unmarshalGetTagPolicyRequestSchema: z.ZodType = z + .object({ + tag_key: z.string().optional(), + }) + .transform(d => ({ + tagKey: d.tag_key, + })); + +export const unmarshalListTagPoliciesRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListTagPoliciesResponseSchema: z.ZodType = z + .object({ + tag_policies: z.array(z.lazy(() => unmarshalTagPolicySchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + tagPolicies: d.tag_policies, + nextPageToken: d.next_page_token, + })); export const unmarshalPropagationConfigSchema: z.ZodType = z .object({ enabled: z.boolean().optional(), - conflict_resolution: z - .lazy(() => unmarshalConflictResolutionPolicySchema) - .optional(), + conflict_resolution: z.lazy(() => unmarshalConflictResolutionPolicySchema).optional(), }) .transform(d => ({ enabled: d.enabled, @@ -162,17 +153,9 @@ export const unmarshalTagPolicySchema: z.ZodType = z id: z.string().optional(), description: z.string().optional(), values: z.array(z.lazy(() => unmarshalValueSchema)).optional(), - create_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - update_time: z - .string() - .transform(s => Temporal.Instant.from(s)) - .optional(), - propagation_config: z - .lazy(() => unmarshalPropagationConfigSchema) - .optional(), + create_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + update_time: z.string().transform(s => Temporal.Instant.from(s)).optional(), + propagation_config: z.lazy(() => unmarshalPropagationConfigSchema).optional(), account_id: z.string().optional(), }) .transform(d => ({ @@ -186,16 +169,15 @@ export const unmarshalTagPolicySchema: z.ZodType = z accountId: d.account_id, })); -export const unmarshalUpdateTagPolicyRequestSchema: z.ZodType = - z - .object({ - tag_policy: z.lazy(() => unmarshalTagPolicySchema).optional(), - update_mask: z.string().optional(), - }) - .transform(d => ({ - tagPolicy: d.tag_policy, - updateMask: d.update_mask, - })); +export const unmarshalUpdateTagPolicyRequestSchema: z.ZodType = z + .object({ + tag_policy: z.lazy(() => unmarshalTagPolicySchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + tagPolicy: d.tag_policy, + updateMask: d.update_mask, + })); export const unmarshalValueSchema: z.ZodType = z .object({ @@ -207,9 +189,7 @@ export const unmarshalValueSchema: z.ZodType = z export const marshalConflictResolutionPolicySchema: z.ZodType = z .object({ - defaultValueOverride: z - .lazy(() => marshalDefaultValueOverridePolicySchema) - .optional(), + defaultValueOverride: z.lazy(() => marshalDefaultValueOverridePolicySchema).optional(), }) .transform(d => ({ default_value_override: d.defaultValueOverride, @@ -270,9 +250,7 @@ export const marshalListTagPoliciesResponseSchema: z.ZodType = z export const marshalPropagationConfigSchema: z.ZodType = z .object({ enabled: z.boolean().optional(), - conflictResolution: z - .lazy(() => marshalConflictResolutionPolicySchema) - .optional(), + conflictResolution: z.lazy(() => marshalConflictResolutionPolicySchema).optional(), }) .transform(d => ({ enabled: d.enabled, @@ -285,14 +263,8 @@ export const marshalTagPolicySchema: z.ZodType = z id: z.string().optional(), description: z.string().optional(), values: z.array(z.lazy(() => marshalValueSchema)).optional(), - createTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), - updateTime: z - .any() - .transform((d: Temporal.Instant) => d.toString()) - .optional(), + createTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), + updateTime: z.any().transform((d: Temporal.Instant) => d.toString()).optional(), propagationConfig: z.lazy(() => marshalPropagationConfigSchema).optional(), accountId: z.string().optional(), }) @@ -310,7 +282,7 @@ export const marshalTagPolicySchema: z.ZodType = z export const marshalUpdateTagPolicyRequestSchema: z.ZodType = z .object({ tagPolicy: z.lazy(() => marshalTagPolicySchema).optional(), - updateMask: z.string().optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), }) .transform(d => ({ tag_policy: d.tagPolicy, diff --git a/packages/tagpolicies/src/v1/utils.ts b/packages/tagpolicies/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/tagpolicies/src/v1/utils.ts +++ b/packages/tagpolicies/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/tagpolicies/tsconfig.json b/packages/tagpolicies/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/tagpolicies/tsconfig.json +++ b/packages/tagpolicies/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/tokenmanagement/package.json b/packages/tokenmanagement/package.json new file mode 100644 index 00000000..870fcad0 --- /dev/null +++ b/packages/tokenmanagement/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-tokenmanagement", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v1": { + "types": "./dist/v1/index.d.ts", + "import": "./dist/v1/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/tokenmanagement/src/v1/client.ts b/packages/tokenmanagement/src/v1/client.ts new file mode 100644 index 00000000..514698bb --- /dev/null +++ b/packages/tokenmanagement/src/v1/client.ts @@ -0,0 +1,137 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + AdminTokenInfo, + CreateOnBehalfOfToken, + CreateOnBehalfOfToken_Response, + GetToken, + GetToken_Response, + ListTokens, + ListTokens_Response, + RevokeToken, + RevokeToken_Response, + UpdateToken, +} from './model'; +import { + marshalCreateOnBehalfOfTokenSchema, + marshalUpdateTokenSchema, + unmarshalAdminTokenInfoSchema, + unmarshalCreateOnBehalfOfToken_ResponseSchema, + unmarshalGetToken_ResponseSchema, + unmarshalListTokens_ResponseSchema, + unmarshalRevokeToken_ResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** Creates a token on behalf of a service principal. */ + async createOnBehalfOfToken(signal: AbortSignal | undefined, req: CreateOnBehalfOfToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token-management/on-behalf-of/tokens`; + const body = marshalRequest(req, marshalCreateOnBehalfOfTokenSchema); + let resp: CreateOnBehalfOfToken_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateOnBehalfOfToken_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Deletes a token, specified by its ID. */ + async deleteToken(signal: AbortSignal | undefined, req: RevokeToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token-management/tokens/${req.tokenId ?? ''}`; + let resp: RevokeToken_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('DELETE', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalRevokeToken_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Gets information about a token, specified by its ID. */ + async getToken(signal: AbortSignal | undefined, req: GetToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token-management/tokens/${req.tokenId ?? ''}`; + let resp: GetToken_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetToken_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Lists all tokens associated with the specified workspace or user. */ + async listTokens(signal: AbortSignal | undefined, req: ListTokens, options?: Options): Promise { + const url = `${this.host}/api/2.0/token-management/tokens`; + const params = new URLSearchParams(); + if (req.createdById !== undefined) { + params.append('created_by_id', String(req.createdById)); + } + if (req.createdByUsername !== undefined) { + params.append('created_by_username', req.createdByUsername); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListTokens_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListTokens_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Updates a token, specified by its ID. */ + async updateToken(signal: AbortSignal | undefined, req: UpdateToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token-management/tokens/${req.token?.tokenId ?? ''}`; + const body = marshalRequest(req, marshalUpdateTokenSchema); + let resp: AdminTokenInfo | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('PATCH', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalAdminTokenInfoSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/tokenmanagement/src/v1/index.ts b/packages/tokenmanagement/src/v1/index.ts new file mode 100644 index 00000000..f9b8ecca --- /dev/null +++ b/packages/tokenmanagement/src/v1/index.ts @@ -0,0 +1,21 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { + AutoscopeState, +} from './model'; + +export type { + AdminTokenInfo, + CreateOnBehalfOfToken, + CreateOnBehalfOfToken_Response, + GetToken, + GetToken_Response, + ListTokens, + ListTokens_Response, + RevokeToken, + RevokeToken_Response, + UpdateToken, +} from './model'; diff --git a/packages/tokenmanagement/src/v1/model.ts b/packages/tokenmanagement/src/v1/model.ts new file mode 100644 index 00000000..075bc5f8 --- /dev/null +++ b/packages/tokenmanagement/src/v1/model.ts @@ -0,0 +1,349 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; +import {z} from 'zod'; + +/** + * State of inferred scope collection (autoscope) for an external PAT. + * Mirrored in databricks.identity.AutoscopeState in common/principal-context/api/proto/tokendetails.proto. + * Token store and token management proto can depend on this. + * Principal context proto should NOT depend on this proto definitions because too many services depend on the principal context proto. + */ +export enum AutoscopeState { + AUTOSCOPE_STATE_UNSPECIFIED = 'AUTOSCOPE_STATE_UNSPECIFIED', + AUTOSCOPE_STATE_DISABLED = 'AUTOSCOPE_STATE_DISABLED', + AUTOSCOPE_STATE_RUNNING = 'AUTOSCOPE_STATE_RUNNING', + AUTOSCOPE_STATE_COMPLETED = 'AUTOSCOPE_STATE_COMPLETED', + AUTOSCOPE_STATE_BACKFILLED = 'AUTOSCOPE_STATE_BACKFILLED', + AUTOSCOPE_STATE_USER_SELECTED = 'AUTOSCOPE_STATE_USER_SELECTED', + AUTOSCOPE_STATE_API_NOT_COVERED = 'AUTOSCOPE_STATE_API_NOT_COVERED', +} + +export interface AdminTokenInfo { + /** ID of the token. */ + tokenId?: string | undefined; + /** Timestamp when the token was created. */ + creationTime?: number | undefined; + /** Timestamp when the token expires. */ + expiryTime?: number | undefined; + /** Comment that describes the purpose of the token, specified by the token creator. */ + comment?: string | undefined; + /** User ID of the user that created the token. */ + createdById?: number | undefined; + /** Username of the user that created the token. */ + createdByUsername?: string | undefined; + /** User ID of the user that owns the token. */ + ownerId?: number | undefined; + /** If applicable, the ID of the workspace that the token was created in. */ + workspaceId?: number | undefined; + /** Approximate timestamp for the day the token was last used. Accurate up to 1 day. */ + lastUsedDay?: number | undefined; + /** Scope of the token was created with, if applicable. */ + scopes?: string[] | undefined; + /** Output only. The autoscope state of this token. */ + autoscopeState?: AutoscopeState | undefined; +} + +/** Configuration details for creating on-behalf tokens. */ +export interface CreateOnBehalfOfToken { + /** Application ID of the service principal. */ + applicationId?: string | undefined; + /** The number of seconds before the token expires. */ + lifetimeSeconds?: number | undefined; + /** Comment that describes the purpose of the token. */ + comment?: string | undefined; + scopes?: string[] | undefined; + /** Whether to enable autoscoping for this token. */ + autoscopeEnabled?: boolean | undefined; +} + +/** An on-behalf token was successfully created for the service principal. */ +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface CreateOnBehalfOfToken_Response { + /** Value of the token. */ + tokenValue?: string | undefined; + tokenInfo?: AdminTokenInfo | undefined; +} + +/** + * !! KEEP THIS IN-SYNC WITH THE WORKSPACE PROTO DEFINITIONS IN SERVICE.PROTO !! + * + * The only differences should be: + * 1. The OpenAPI labels. + * 2. The account_id request parameter. + */ +export interface GetToken { + /** The ID of the token to get. */ + tokenId?: string | undefined; +} + +/** Token with specified Token ID was successfully returned. */ +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetToken_Response { + tokenInfo?: AdminTokenInfo | undefined; +} + +/** + * !! 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. + */ +export interface ListTokens { + /** User ID of the user that created the token. */ + createdById?: number | undefined; + /** Username of the user that created the token. */ + createdByUsername?: string | undefined; +} + +/** Tokens were successfully returned. */ +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListTokens_Response { + /** Token metadata of each user-created token in the workspace */ + tokenInfos?: AdminTokenInfo[] | undefined; +} + +export interface RevokeToken { + /** The ID of the token to revoke. */ + tokenId?: string | undefined; +} + +/** The token was successfully deleted. */ +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface RevokeToken_Response {} + +export interface UpdateToken { + token?: AdminTokenInfo | undefined; + /** A list of field name under AdminTokenInfo, For example in request use {"update_mask": "comment,scopes"} */ + updateMask?: FieldMask> | undefined; +} + +export const unmarshalAdminTokenInfoSchema: z.ZodType = z + .object({ + token_id: z.string().optional(), + creation_time: z.number().optional(), + expiry_time: z.number().optional(), + comment: z.string().optional(), + created_by_id: z.number().optional(), + created_by_username: z.string().optional(), + owner_id: z.number().optional(), + workspace_id: z.number().optional(), + last_used_day: z.number().optional(), + scopes: z.array(z.string()).optional(), + autoscope_state: z.enum(AutoscopeState).optional(), + }) + .transform(d => ({ + tokenId: d.token_id, + creationTime: d.creation_time, + expiryTime: d.expiry_time, + comment: d.comment, + createdById: d.created_by_id, + createdByUsername: d.created_by_username, + ownerId: d.owner_id, + workspaceId: d.workspace_id, + lastUsedDay: d.last_used_day, + scopes: d.scopes, + autoscopeState: d.autoscope_state, + })); + +export const unmarshalCreateOnBehalfOfTokenSchema: z.ZodType = z + .object({ + application_id: z.string().optional(), + lifetime_seconds: z.number().optional(), + comment: z.string().optional(), + scopes: z.array(z.string()).optional(), + autoscope_enabled: z.boolean().optional(), + }) + .transform(d => ({ + applicationId: d.application_id, + lifetimeSeconds: d.lifetime_seconds, + comment: d.comment, + scopes: d.scopes, + autoscopeEnabled: d.autoscope_enabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateOnBehalfOfToken_ResponseSchema: z.ZodType = z + .object({ + token_value: z.string().optional(), + token_info: z.lazy(() => unmarshalAdminTokenInfoSchema).optional(), + }) + .transform(d => ({ + tokenValue: d.token_value, + tokenInfo: d.token_info, + })); + +export const unmarshalGetTokenSchema: z.ZodType = z + .object({ + token_id: z.string().optional(), + }) + .transform(d => ({ + tokenId: d.token_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetToken_ResponseSchema: z.ZodType = z + .object({ + token_info: z.lazy(() => unmarshalAdminTokenInfoSchema).optional(), + }) + .transform(d => ({ + tokenInfo: d.token_info, + })); + +export const unmarshalListTokensSchema: z.ZodType = z + .object({ + created_by_id: z.number().optional(), + created_by_username: z.string().optional(), + }) + .transform(d => ({ + createdById: d.created_by_id, + createdByUsername: d.created_by_username, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListTokens_ResponseSchema: z.ZodType = z + .object({ + token_infos: z.array(z.lazy(() => unmarshalAdminTokenInfoSchema)).optional(), + }) + .transform(d => ({ + tokenInfos: d.token_infos, + })); + +export const unmarshalRevokeTokenSchema: z.ZodType = z + .object({ + token_id: z.string().optional(), + }) + .transform(d => ({ + tokenId: d.token_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalRevokeToken_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalUpdateTokenSchema: z.ZodType = z + .object({ + token: z.lazy(() => unmarshalAdminTokenInfoSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + token: d.token, + updateMask: d.update_mask, + })); + +export const marshalAdminTokenInfoSchema: z.ZodType = z + .object({ + tokenId: z.string().optional(), + creationTime: z.number().optional(), + expiryTime: z.number().optional(), + comment: z.string().optional(), + createdById: z.number().optional(), + createdByUsername: z.string().optional(), + ownerId: z.number().optional(), + workspaceId: z.number().optional(), + lastUsedDay: z.number().optional(), + scopes: z.array(z.string()).optional(), + autoscopeState: z.enum(AutoscopeState).optional(), + }) + .transform(d => ({ + token_id: d.tokenId, + creation_time: d.creationTime, + expiry_time: d.expiryTime, + comment: d.comment, + created_by_id: d.createdById, + created_by_username: d.createdByUsername, + owner_id: d.ownerId, + workspace_id: d.workspaceId, + last_used_day: d.lastUsedDay, + scopes: d.scopes, + autoscope_state: d.autoscopeState, + })); + +export const marshalCreateOnBehalfOfTokenSchema: z.ZodType = z + .object({ + applicationId: z.string().optional(), + lifetimeSeconds: z.number().optional(), + comment: z.string().optional(), + scopes: z.array(z.string()).optional(), + autoscopeEnabled: z.boolean().optional(), + }) + .transform(d => ({ + application_id: d.applicationId, + lifetime_seconds: d.lifetimeSeconds, + comment: d.comment, + scopes: d.scopes, + autoscope_enabled: d.autoscopeEnabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreateOnBehalfOfToken_ResponseSchema: z.ZodType = z + .object({ + tokenValue: z.string().optional(), + tokenInfo: z.lazy(() => marshalAdminTokenInfoSchema).optional(), + }) + .transform(d => ({ + token_value: d.tokenValue, + token_info: d.tokenInfo, + })); + +export const marshalGetTokenSchema: z.ZodType = z + .object({ + tokenId: z.string().optional(), + }) + .transform(d => ({ + token_id: d.tokenId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetToken_ResponseSchema: z.ZodType = z + .object({ + tokenInfo: z.lazy(() => marshalAdminTokenInfoSchema).optional(), + }) + .transform(d => ({ + token_info: d.tokenInfo, + })); + +export const marshalListTokensSchema: z.ZodType = z + .object({ + createdById: z.number().optional(), + createdByUsername: z.string().optional(), + }) + .transform(d => ({ + created_by_id: d.createdById, + created_by_username: d.createdByUsername, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListTokens_ResponseSchema: z.ZodType = z + .object({ + tokenInfos: z.array(z.lazy(() => marshalAdminTokenInfoSchema)).optional(), + }) + .transform(d => ({ + token_infos: d.tokenInfos, + })); + +export const marshalRevokeTokenSchema: z.ZodType = z + .object({ + tokenId: z.string().optional(), + }) + .transform(d => ({ + token_id: d.tokenId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalRevokeToken_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalUpdateTokenSchema: z.ZodType = z + .object({ + token: z.lazy(() => marshalAdminTokenInfoSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), + }) + .transform(d => ({ + token: d.token, + update_mask: d.updateMask, + })); diff --git a/packages/tokenmanagement/src/v1/utils.ts b/packages/tokenmanagement/src/v1/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/tokenmanagement/src/v1/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/tokenmanagement/tsconfig.json b/packages/tokenmanagement/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/tokenmanagement/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/tokens/package.json b/packages/tokens/package.json new file mode 100644 index 00000000..8a2ca5b9 --- /dev/null +++ b/packages/tokens/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-tokens", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v1": { + "types": "./dist/v1/index.d.ts", + "import": "./dist/v1/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/tokens/src/v1/client.ts b/packages/tokens/src/v1/client.ts new file mode 100644 index 00000000..5f3f072b --- /dev/null +++ b/packages/tokens/src/v1/client.ts @@ -0,0 +1,123 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + CreateToken, + CreateToken_Response, + ListTokens, + ListTokens_Response, + RevokeToken, + RevokeToken_Response, + UpdateToken, + UpdateTokenResponse, +} from './model'; +import { + marshalCreateTokenSchema, + marshalRevokeTokenSchema, + marshalUpdateTokenSchema, + unmarshalCreateToken_ResponseSchema, + unmarshalListTokens_ResponseSchema, + unmarshalRevokeToken_ResponseSchema, + unmarshalUpdateTokenResponseSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** + * Creates and returns a token for a user. If this call is made through token authentication, it creates + * a token with the same client ID as the authenticated token. If the user's token quota is exceeded, this call + * returns an error **QUOTA_EXCEEDED**. + */ + async createToken(signal: AbortSignal | undefined, req: CreateToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token/create`; + const body = marshalRequest(req, marshalCreateTokenSchema); + let resp: CreateToken_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalCreateToken_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Lists all the valid tokens for a user-workspace pair. */ + async listTokens(signal: AbortSignal | undefined, _req: ListTokens, options?: Options): Promise { + const url = `${this.host}/api/2.0/token/list`; + let resp: ListTokens_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', url, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListTokens_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Revokes an access token. + * + * If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**. + */ + async revokeToken(signal: AbortSignal | undefined, req: RevokeToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token/delete`; + const body = marshalRequest(req, marshalRevokeTokenSchema); + let resp: RevokeToken_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('POST', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalRevokeToken_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** + * Updates the comment or scopes of a token. + * + * If a token with the specified ID is not valid, this call returns an error **RESOURCE_DOES_NOT_EXIST**. + */ + async updateToken(signal: AbortSignal | undefined, req: UpdateToken, options?: Options): Promise { + const url = `${this.host}/api/2.0/token/${req.tokenId ?? ''}`; + const body = marshalRequest(req, marshalUpdateTokenSchema); + let resp: UpdateTokenResponse | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('PATCH', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdateTokenResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/tokens/src/v1/index.ts b/packages/tokens/src/v1/index.ts new file mode 100644 index 00000000..489951d3 --- /dev/null +++ b/packages/tokens/src/v1/index.ts @@ -0,0 +1,20 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { + AutoscopeState, +} from './model'; + +export type { + CreateToken, + CreateToken_Response, + ListTokens, + ListTokens_Response, + PublicTokenInfo, + RevokeToken, + RevokeToken_Response, + UpdateToken, + UpdateTokenResponse, +} from './model'; diff --git a/packages/tokens/src/v1/model.ts b/packages/tokens/src/v1/model.ts new file mode 100644 index 00000000..62c72ccb --- /dev/null +++ b/packages/tokens/src/v1/model.ts @@ -0,0 +1,277 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; +import {z} from 'zod'; + +/** + * State of inferred scope collection (autoscope) for an external PAT. + * Mirrored in databricks.identity.AutoscopeState in common/principal-context/api/proto/tokendetails.proto. + * Token store and token management proto can depend on this. + * Principal context proto should NOT depend on this proto definitions because too many services depend on the principal context proto. + */ +export enum AutoscopeState { + AUTOSCOPE_STATE_UNSPECIFIED = 'AUTOSCOPE_STATE_UNSPECIFIED', + AUTOSCOPE_STATE_DISABLED = 'AUTOSCOPE_STATE_DISABLED', + AUTOSCOPE_STATE_RUNNING = 'AUTOSCOPE_STATE_RUNNING', + AUTOSCOPE_STATE_COMPLETED = 'AUTOSCOPE_STATE_COMPLETED', + AUTOSCOPE_STATE_BACKFILLED = 'AUTOSCOPE_STATE_BACKFILLED', + AUTOSCOPE_STATE_USER_SELECTED = 'AUTOSCOPE_STATE_USER_SELECTED', + AUTOSCOPE_STATE_API_NOT_COVERED = 'AUTOSCOPE_STATE_API_NOT_COVERED', +} + +export interface CreateToken { + /** + * The lifetime of the token, in seconds. + * + * If the lifetime is not specified, this token remains valid for 2 years. + */ + lifetimeSeconds?: number | undefined; + /** Optional description to attach to the token. */ + comment?: string | undefined; + /** Optional scopes of the token. */ + scopes?: string[] | undefined; + /** + * Whether to enable autoscoping for this token. When true, the token will + * automatically collect inferred API path scopes as it is used. + */ + autoscopeEnabled?: boolean | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface CreateToken_Response { + /** The value of the new token. */ + tokenValue?: string | undefined; + /** The information for the new token. */ + tokenInfo?: PublicTokenInfo | undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ListTokens {} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListTokens_Response { + /** The information for each token. */ + tokenInfos?: PublicTokenInfo[] | undefined; +} + +export interface PublicTokenInfo { + /** The ID of this token. */ + tokenId?: string | undefined; + /** Server time (in epoch milliseconds) when the token was created. */ + creationTime?: number | undefined; + /** Server time (in epoch milliseconds) when the token will expire, or -1 if not applicable. */ + expiryTime?: number | undefined; + /** Comment the token was created with, if applicable. */ + comment?: string | undefined; + /** Scope of the token was created with, if applicable. */ + scopes?: string[] | undefined; + /** Server time (in epoch milliseconds) when the token was accessed most recently. */ + lastAccessedTime?: number | undefined; + /** Output only. The autoscope state of this token. */ + autoscopeState?: AutoscopeState | undefined; + /** Output only. Inferred API path scopes collected for this token when autoscope is enabled. */ + inferredScopes?: string[] | undefined; + /** Output only. Scopes inferred from offline backfill processing. */ + backfillScopes?: string[] | undefined; +} + +export interface RevokeToken { + /** The ID of the token to be revoked. */ + tokenId?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface RevokeToken_Response {} + +export interface UpdateToken { + /** The SHA-256 hash of the token to be updated. */ + tokenId?: string | undefined; + token?: PublicTokenInfo | undefined; + /** A list of field name under PublicTokenInfo, For example in request use {"update_mask": "comment,scopes"} */ + updateMask?: FieldMask> | undefined; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface UpdateTokenResponse {} + +export const unmarshalCreateTokenSchema: z.ZodType = z + .object({ + lifetime_seconds: z.number().optional(), + comment: z.string().optional(), + scopes: z.array(z.string()).optional(), + autoscope_enabled: z.boolean().optional(), + }) + .transform(d => ({ + lifetimeSeconds: d.lifetime_seconds, + comment: d.comment, + scopes: d.scopes, + autoscopeEnabled: d.autoscope_enabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalCreateToken_ResponseSchema: z.ZodType = z + .object({ + token_value: z.string().optional(), + token_info: z.lazy(() => unmarshalPublicTokenInfoSchema).optional(), + }) + .transform(d => ({ + tokenValue: d.token_value, + tokenInfo: d.token_info, + })); + +export const unmarshalListTokensSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListTokens_ResponseSchema: z.ZodType = z + .object({ + token_infos: z.array(z.lazy(() => unmarshalPublicTokenInfoSchema)).optional(), + }) + .transform(d => ({ + tokenInfos: d.token_infos, + })); + +export const unmarshalPublicTokenInfoSchema: z.ZodType = z + .object({ + token_id: z.string().optional(), + creation_time: z.number().optional(), + expiry_time: z.number().optional(), + comment: z.string().optional(), + scopes: z.array(z.string()).optional(), + last_accessed_time: z.number().optional(), + autoscope_state: z.enum(AutoscopeState).optional(), + inferred_scopes: z.array(z.string()).optional(), + backfill_scopes: z.array(z.string()).optional(), + }) + .transform(d => ({ + tokenId: d.token_id, + creationTime: d.creation_time, + expiryTime: d.expiry_time, + comment: d.comment, + scopes: d.scopes, + lastAccessedTime: d.last_accessed_time, + autoscopeState: d.autoscope_state, + inferredScopes: d.inferred_scopes, + backfillScopes: d.backfill_scopes, + })); + +export const unmarshalRevokeTokenSchema: z.ZodType = z + .object({ + token_id: z.string().optional(), + }) + .transform(d => ({ + tokenId: d.token_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalRevokeToken_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalUpdateTokenSchema: z.ZodType = z + .object({ + token_id: z.string().optional(), + token: z.lazy(() => unmarshalPublicTokenInfoSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + }) + .transform(d => ({ + tokenId: d.token_id, + token: d.token, + updateMask: d.update_mask, + })); + +export const unmarshalUpdateTokenResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalCreateTokenSchema: z.ZodType = z + .object({ + lifetimeSeconds: z.number().optional(), + comment: z.string().optional(), + scopes: z.array(z.string()).optional(), + autoscopeEnabled: z.boolean().optional(), + }) + .transform(d => ({ + lifetime_seconds: d.lifetimeSeconds, + comment: d.comment, + scopes: d.scopes, + autoscope_enabled: d.autoscopeEnabled, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalCreateToken_ResponseSchema: z.ZodType = z + .object({ + tokenValue: z.string().optional(), + tokenInfo: z.lazy(() => marshalPublicTokenInfoSchema).optional(), + }) + .transform(d => ({ + token_value: d.tokenValue, + token_info: d.tokenInfo, + })); + +export const marshalListTokensSchema: z.ZodType = z + .object({ + }); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListTokens_ResponseSchema: z.ZodType = z + .object({ + tokenInfos: z.array(z.lazy(() => marshalPublicTokenInfoSchema)).optional(), + }) + .transform(d => ({ + token_infos: d.tokenInfos, + })); + +export const marshalPublicTokenInfoSchema: z.ZodType = z + .object({ + tokenId: z.string().optional(), + creationTime: z.number().optional(), + expiryTime: z.number().optional(), + comment: z.string().optional(), + scopes: z.array(z.string()).optional(), + lastAccessedTime: z.number().optional(), + autoscopeState: z.enum(AutoscopeState).optional(), + inferredScopes: z.array(z.string()).optional(), + backfillScopes: z.array(z.string()).optional(), + }) + .transform(d => ({ + token_id: d.tokenId, + creation_time: d.creationTime, + expiry_time: d.expiryTime, + comment: d.comment, + scopes: d.scopes, + last_accessed_time: d.lastAccessedTime, + autoscope_state: d.autoscopeState, + inferred_scopes: d.inferredScopes, + backfill_scopes: d.backfillScopes, + })); + +export const marshalRevokeTokenSchema: z.ZodType = z + .object({ + tokenId: z.string().optional(), + }) + .transform(d => ({ + token_id: d.tokenId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalRevokeToken_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalUpdateTokenSchema: z.ZodType = z + .object({ + tokenId: z.string().optional(), + token: z.lazy(() => marshalPublicTokenInfoSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), + }) + .transform(d => ({ + token_id: d.tokenId, + token: d.token, + update_mask: d.updateMask, + })); + +export const marshalUpdateTokenResponseSchema: z.ZodType = z + .object({ + }); diff --git a/packages/tokens/src/v1/utils.ts b/packages/tokens/src/v1/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/tokens/src/v1/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/tokens/tsconfig.json b/packages/tokens/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/tokens/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/volumes/package.json b/packages/volumes/package.json index 4b71f4b5..bfb29ae3 100644 --- a/packages/volumes/package.json +++ b/packages/volumes/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/volumes/src/v1/client.ts b/packages/volumes/src/v1/client.ts index 6e699f00..d4bf3fcc 100644 --- a/packages/volumes/src/v1/client.ts +++ b/packages/volumes/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateVolume, DeleteVolume, @@ -47,39 +42,31 @@ export class Client { /** * Creates a new volume. - * + * * The user could create either an external volume or a managed volume. An external volume * will be created in the specified external location, while a managed volume * will be located in the default location which is specified by the parent schema, * or the parent catalog, or the Metastore. - * + * * For the volume creation to succeed, the user must satisfy following conditions: * - The caller must be a metastore admin, or be the owner of the parent catalog and schema, * or have the **USE_CATALOG** privilege on the parent catalog * and the **USE_SCHEMA** privilege on the parent schema. * - The caller must have **CREATE VOLUME** privilege on the parent schema. - * + * * For an external volume, following conditions also need to satisfy * - The caller must have **CREATE EXTERNAL VOLUME** privilege on the external location. * - There are no other tables, nor volumes existing in the specified storage location. * - The specified storage location is not under the location of other tables, nor volumes, * or catalogs or schemas. */ - async createVolume( - signal: AbortSignal | undefined, - req: CreateVolume, - options?: Options - ): Promise { + async createVolume(signal: AbortSignal | undefined, req: CreateVolume, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/volumes`; const body = marshalRequest(req, marshalCreateVolumeSchema); let resp: VolumeInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalVolumeInfoSchema); }; await execute(signal, call, options); @@ -91,25 +78,17 @@ export class Client { /** * Deletes a volume from the specified parent catalog and schema. - * + * * The caller must be a metastore admin or an owner of the volume. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async deleteVolume( - signal: AbortSignal | undefined, - req: DeleteVolume, - options?: Options - ): Promise { + async deleteVolume(signal: AbortSignal | undefined, req: DeleteVolume, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/volumes/${req.fullNameArg ?? ''}`; let resp: DeleteVolume_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDeleteVolume_ResponseSchema); }; await execute(signal, call, options); @@ -121,17 +100,13 @@ export class Client { /** * Gets a volume from the metastore for a specific catalog and schema. - * + * * The caller must be a metastore admin or an owner of (or have the **READ VOLUME** * privilege on) the volume. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. */ - async getVolume( - signal: AbortSignal | undefined, - req: GetVolume, - options?: Options - ): Promise { + async getVolume(signal: AbortSignal | undefined, req: GetVolume, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/volumes/${req.fullNameArg ?? ''}`; const params = new URLSearchParams(); if (req.includeBrowse !== undefined) { @@ -142,11 +117,7 @@ export class Client { let resp: VolumeInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalVolumeInfoSchema); }; await execute(signal, call, options); @@ -159,24 +130,20 @@ export class Client { /** * Gets an array of volumes for the current metastore * under the parent catalog and schema. - * + * * The returned volumes are filtered based on the privileges of the calling user. * For example, the metastore admin is able to list all the volumes. * A regular user needs to be the owner or have the **READ VOLUME** privilege * on the volume to receive the volumes in the response. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - * + * * There is no guarantee of a specific ordering of the elements in the array. - * + * * PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async listVolumes( - signal: AbortSignal | undefined, - req: ListVolumes, - options?: Options - ): Promise { + async listVolumes(signal: AbortSignal | undefined, req: ListVolumes, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/volumes`; const params = new URLSearchParams(); if (req.catalogName !== undefined) { @@ -199,11 +166,7 @@ export class Client { let resp: ListVolumes_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalListVolumes_ResponseSchema); }; await execute(signal, call, options); @@ -213,11 +176,8 @@ export class Client { return resp; } - async *listVolumesIter( - signal: AbortSignal | undefined, - req: ListVolumes, - options?: Options - ): AsyncGenerator { + + async *listVolumesIter(signal: AbortSignal | undefined, req: ListVolumes, options?: Options): AsyncGenerator { const pageReq: ListVolumes = {...req}; for (;;) { const resp = await this.listVolumes(signal, pageReq, options); @@ -231,30 +191,23 @@ export class Client { } } + /** * Updates the specified volume under the specified parent catalog and schema. - * + * * The caller must be a metastore admin or an owner of the volume. * For the latter case, the caller must also be the owner or have the **USE_CATALOG** * privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent schema. - * + * * Currently only the name, the owner or the comment of the volume could be updated. */ - async updateVolume( - signal: AbortSignal | undefined, - req: UpdateVolume, - options?: Options - ): Promise { + async updateVolume(signal: AbortSignal | undefined, req: UpdateVolume, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/volumes/${req.fullNameArg ?? ''}`; const body = marshalRequest(req, marshalUpdateVolumeSchema); let resp: VolumeInfo | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalVolumeInfoSchema); }; await execute(signal, call, options); diff --git a/packages/volumes/src/v1/index.ts b/packages/volumes/src/v1/index.ts index 9726833a..0801491c 100644 --- a/packages/volumes/src/v1/index.ts +++ b/packages/volumes/src/v1/index.ts @@ -1,8 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {SseEncryptionAlgorithm, VolumeType} from './model'; +export { + SseEncryptionAlgorithm, + VolumeType, +} from './model'; export type { CreateVolume, diff --git a/packages/volumes/src/v1/model.ts b/packages/volumes/src/v1/model.ts index 3484b792..5e187491 100644 --- a/packages/volumes/src/v1/model.ts +++ b/packages/volumes/src/v1/model.ts @@ -81,12 +81,12 @@ export interface ListVolumes { includeBrowse?: boolean | undefined; /** * 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. */ @@ -213,9 +213,7 @@ export const unmarshalCreateVolumeSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), access_point: z.string().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), browse_only: z.boolean().optional(), }) .transform(d => ({ @@ -247,14 +245,13 @@ export const unmarshalDeleteVolumeSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteVolume_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalDeleteVolume_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalEncryptionDetailsSchema: z.ZodType = z .object({ - sse_encryption_details: z - .lazy(() => unmarshalSseEncryptionDetailsSchema) - .optional(), + sse_encryption_details: z.lazy(() => unmarshalSseEncryptionDetailsSchema).optional(), }) .transform(d => ({ sseEncryptionDetails: d.sse_encryption_details, @@ -287,27 +284,25 @@ export const unmarshalListVolumesSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListVolumes_ResponseSchema: z.ZodType = - z - .object({ - volumes: z.array(z.lazy(() => unmarshalVolumeInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - volumes: d.volumes, - nextPageToken: d.next_page_token, - })); - -export const unmarshalSseEncryptionDetailsSchema: z.ZodType = - z - .object({ - algorithm: z.enum(SseEncryptionAlgorithm).optional(), - aws_kms_key_arn: z.string().optional(), - }) - .transform(d => ({ - algorithm: d.algorithm, - awsKmsKeyArn: d.aws_kms_key_arn, - })); +export const unmarshalListVolumes_ResponseSchema: z.ZodType = z + .object({ + volumes: z.array(z.lazy(() => unmarshalVolumeInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + volumes: d.volumes, + nextPageToken: d.next_page_token, + })); + +export const unmarshalSseEncryptionDetailsSchema: z.ZodType = z + .object({ + algorithm: z.enum(SseEncryptionAlgorithm).optional(), + aws_kms_key_arn: z.string().optional(), + }) + .transform(d => ({ + algorithm: d.algorithm, + awsKmsKeyArn: d.aws_kms_key_arn, + })); export const unmarshalUpdateVolumeSchema: z.ZodType = z .object({ @@ -328,9 +323,7 @@ export const unmarshalUpdateVolumeSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), access_point: z.string().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), browse_only: z.boolean().optional(), }) .transform(d => ({ @@ -372,9 +365,7 @@ export const unmarshalVolumeInfoSchema: z.ZodType = z updated_at: z.number().optional(), updated_by: z.string().optional(), access_point: z.string().optional(), - encryption_details: z - .lazy(() => unmarshalEncryptionDetailsSchema) - .optional(), + encryption_details: z.lazy(() => unmarshalEncryptionDetailsSchema).optional(), browse_only: z.boolean().optional(), }) .transform(d => ({ @@ -446,13 +437,13 @@ export const marshalDeleteVolumeSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteVolume_ResponseSchema: z.ZodType = z.object({}); +export const marshalDeleteVolume_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalEncryptionDetailsSchema: z.ZodType = z .object({ - sseEncryptionDetails: z - .lazy(() => marshalSseEncryptionDetailsSchema) - .optional(), + sseEncryptionDetails: z.lazy(() => marshalSseEncryptionDetailsSchema).optional(), }) .transform(d => ({ sse_encryption_details: d.sseEncryptionDetails, diff --git a/packages/volumes/src/v1/utils.ts b/packages/volumes/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/volumes/src/v1/utils.ts +++ b/packages/volumes/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/volumes/tsconfig.json b/packages/volumes/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/volumes/tsconfig.json +++ b/packages/volumes/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/warehouses/package.json b/packages/warehouses/package.json index 81be86e0..09c5535d 100644 --- a/packages/warehouses/package.json +++ b/packages/warehouses/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/warehouses/src/v1/client.ts b/packages/warehouses/src/v1/client.ts index d403e3e3..8457018f 100644 --- a/packages/warehouses/src/v1/client.ts +++ b/packages/warehouses/src/v1/client.ts @@ -1,18 +1,13 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. import type {Call, Options} from '@databricks/sdk-databricks/api'; -import {execute} from '@databricks/sdk-databricks/api'; +import {execute, retryOn} from '@databricks/sdk-databricks/api'; import type {Logger} from '@databricks/sdk-databricks/logger'; import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { CreateDefaultWarehouseOverrideRequest, CreateWarehouse, @@ -42,6 +37,7 @@ import type { UpdateDefaultWarehouseOverrideRequest, } from './model'; import { + EndpointState, marshalCreateWarehouseSchema, marshalDefaultWarehouseOverrideSchema, marshalEditWarehouseRequestSchema, @@ -61,6 +57,8 @@ import { unmarshalStopRequest_ResponseSchema, } from './model'; +class StillRunningError extends Error {} + export class Client { private readonly host: string; private readonly httpClient: HttpClient; @@ -79,33 +77,19 @@ export class Client { * Creates a new default warehouse override for a user. * Users can create their own override. Admins can create overrides for any user. */ - async createDefaultWarehouseOverride( - signal: AbortSignal | undefined, - req: CreateDefaultWarehouseOverrideRequest, - options?: Options - ): Promise { + async createDefaultWarehouseOverride(signal: AbortSignal | undefined, req: CreateDefaultWarehouseOverrideRequest, options?: Options): Promise { const url = `${this.host}/api/warehouses/v1/default-warehouse-overrides`; const params = new URLSearchParams(); if (req.defaultWarehouseOverrideId !== undefined) { - params.append( - 'default_warehouse_override_id', - req.defaultWarehouseOverrideId - ); + params.append('default_warehouse_override_id', req.defaultWarehouseOverrideId); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.defaultWarehouseOverride, - marshalDefaultWarehouseOverrideSchema - ); + const body = marshalRequest(req.defaultWarehouseOverride, marshalDefaultWarehouseOverrideSchema); let resp: DefaultWarehouseOverride | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDefaultWarehouseOverrideSchema); }; await execute(signal, call, options); @@ -116,21 +100,13 @@ export class Client { } /** Creates a new SQL warehouse. */ - async createWarehouse( - signal: AbortSignal | undefined, - req: CreateWarehouse, - options?: Options - ): Promise { + async createWarehouse(signal: AbortSignal | undefined, req: CreateWarehouse, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses`; const body = marshalRequest(req, marshalCreateWarehouseSchema); let resp: CreateWarehouse_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalCreateWarehouse_ResponseSchema); }; await execute(signal, call, options); @@ -140,47 +116,45 @@ export class Client { return resp; } +async createWarehouseWaiter( + signal: AbortSignal | undefined, + req: CreateWarehouse, + options?: Options + ): Promise { + const resp = await this.createWarehouse(signal, req, options); + if (resp.id === undefined) { + throw new Error( + 'response field id required for polling is missing' + ); + } + return new CreateWarehouseWaiter( + this, + resp.id, + ); + } + /** * Deletes the default warehouse override for a user. * Users can delete their own override. Admins can delete overrides for any user. * After deletion, the workspace default warehouse will be used. */ - async deleteDefaultWarehouseOverride( - signal: AbortSignal | undefined, - req: DeleteDefaultWarehouseOverrideRequest, - options?: Options - ): Promise { + async deleteDefaultWarehouseOverride(signal: AbortSignal | undefined, req: DeleteDefaultWarehouseOverrideRequest, options?: Options): Promise { const url = `${this.host}/api/warehouses/v1/${req.name ?? ''}`; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } /** Deletes a SQL warehouse. */ - async deleteWarehouse( - signal: AbortSignal | undefined, - req: DeleteWarehouseRequest, - options?: Options - ): Promise { + async deleteWarehouse(signal: AbortSignal | undefined, req: DeleteWarehouseRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}`; let resp: DeleteWarehouseRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('DELETE', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalDeleteWarehouseRequest_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteWarehouseRequest_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -190,25 +164,14 @@ export class Client { } /** Updates the configuration for a SQL warehouse. */ - async editWarehouse( - signal: AbortSignal | undefined, - req: EditWarehouseRequest, - options?: Options - ): Promise { + async editWarehouse(signal: AbortSignal | undefined, req: EditWarehouseRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}/edit`; const body = marshalRequest(req, marshalEditWarehouseRequestSchema); let resp: EditWarehouseRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalEditWarehouseRequest_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalEditWarehouseRequest_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -217,25 +180,34 @@ export class Client { return resp; } +async editWarehouseWaiter( + signal: AbortSignal | undefined, + req: EditWarehouseRequest, + options?: Options + ): Promise { + await this.editWarehouse(signal, req, options); + if (req.id === undefined) { + throw new Error( + 'request field id required for polling is missing' + ); + } + return new EditWarehouseWaiter( + this, + req.id, + ); + } + /** * Returns the default warehouse override for a user. * Users can fetch their own override. Admins can fetch overrides for any user. * If no override exists, the UI will fallback to the workspace default warehouse. */ - async getDefaultWarehouseOverride( - signal: AbortSignal | undefined, - req: GetDefaultWarehouseOverrideRequest, - options?: Options - ): Promise { + async getDefaultWarehouseOverride(signal: AbortSignal | undefined, req: GetDefaultWarehouseOverrideRequest, options?: Options): Promise { const url = `${this.host}/api/warehouses/v1/${req.name ?? ''}`; let resp: DefaultWarehouseOverride | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDefaultWarehouseOverrideSchema); }; await execute(signal, call, options); @@ -246,20 +218,12 @@ export class Client { } /** Gets the information for a single SQL warehouse. */ - async getWarehouse( - signal: AbortSignal | undefined, - req: GetWarehouse, - options?: Options - ): Promise { + async getWarehouse(signal: AbortSignal | undefined, req: GetWarehouse, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}`; let resp: GetWarehouse_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalGetWarehouse_ResponseSchema); }; await execute(signal, call, options); @@ -270,24 +234,13 @@ export class Client { } /** Gets the workspace level configuration that is shared by all SQL warehouses in a workspace. */ - async getWorkspaceWarehouseConfig( - signal: AbortSignal | undefined, - _req: GetWorkspaceWarehouseConfigRequest, - options?: Options - ): Promise { + async getWorkspaceWarehouseConfig(signal: AbortSignal | undefined, _req: GetWorkspaceWarehouseConfigRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/config/warehouses`; let resp: GetWorkspaceWarehouseConfigRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetWorkspaceWarehouseConfigRequest_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetWorkspaceWarehouseConfigRequest_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -300,11 +253,7 @@ export class Client { * Lists all default warehouse overrides in the workspace. * Only workspace administrators can list all overrides. */ - async listDefaultWarehouseOverrides( - signal: AbortSignal | undefined, - req: ListDefaultWarehouseOverridesRequest, - options?: Options - ): Promise { + async listDefaultWarehouseOverrides(signal: AbortSignal | undefined, req: ListDefaultWarehouseOverridesRequest, options?: Options): Promise { const url = `${this.host}/api/warehouses/v1/default-warehouse-overrides`; const params = new URLSearchParams(); if (req.pageSize !== undefined) { @@ -318,15 +267,8 @@ export class Client { let resp: ListDefaultWarehouseOverridesResponse | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListDefaultWarehouseOverridesResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListDefaultWarehouseOverridesResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -335,18 +277,11 @@ export class Client { return resp; } - async *listDefaultWarehouseOverridesIter( - signal: AbortSignal | undefined, - req: ListDefaultWarehouseOverridesRequest, - options?: Options - ): AsyncGenerator { + + async *listDefaultWarehouseOverridesIter(signal: AbortSignal | undefined, req: ListDefaultWarehouseOverridesRequest, options?: Options): AsyncGenerator { const pageReq: ListDefaultWarehouseOverridesRequest = {...req}; for (;;) { - const resp = await this.listDefaultWarehouseOverrides( - signal, - pageReq, - options - ); + const resp = await this.listDefaultWarehouseOverrides(signal, pageReq, options); for (const item of resp.defaultWarehouseOverrides ?? []) { yield item; } @@ -357,12 +292,9 @@ export class Client { } } + /** Lists all SQL warehouses that a user has access to. */ - async listWarehouses( - signal: AbortSignal | undefined, - req: ListWarehousesRequest, - options?: Options - ): Promise { + async listWarehouses(signal: AbortSignal | undefined, req: ListWarehousesRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses`; const params = new URLSearchParams(); if (req.runAsUserId !== undefined) { @@ -379,15 +311,8 @@ export class Client { let resp: ListWarehousesRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalListWarehousesRequest_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWarehousesRequest_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -396,11 +321,8 @@ export class Client { return resp; } - async *listWarehousesIter( - signal: AbortSignal | undefined, - req: ListWarehousesRequest, - options?: Options - ): AsyncGenerator { + + async *listWarehousesIter(signal: AbortSignal | undefined, req: ListWarehousesRequest, options?: Options): AsyncGenerator { const pageReq: ListWarehousesRequest = {...req}; for (;;) { const resp = await this.listWarehouses(signal, pageReq, options); @@ -414,29 +336,16 @@ export class Client { } } + /** Sets the workspace level configuration that is shared by all SQL warehouses in a workspace. */ - async setWorkspaceWarehouseConfig( - signal: AbortSignal | undefined, - req: SetWorkspaceWarehouseConfigRequest, - options?: Options - ): Promise { + async setWorkspaceWarehouseConfig(signal: AbortSignal | undefined, req: SetWorkspaceWarehouseConfigRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/config/warehouses`; - const body = marshalRequest( - req, - marshalSetWorkspaceWarehouseConfigRequestSchema - ); + const body = marshalRequest(req, marshalSetWorkspaceWarehouseConfigRequestSchema); let resp: SetWorkspaceWarehouseConfigRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PUT', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalSetWorkspaceWarehouseConfigRequest_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalSetWorkspaceWarehouseConfigRequest_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -446,21 +355,13 @@ export class Client { } /** Starts a SQL warehouse. */ - async startWarehouse( - signal: AbortSignal | undefined, - req: StartRequest, - options?: Options - ): Promise { + async startWarehouse(signal: AbortSignal | undefined, req: StartRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}/start`; const body = marshalRequest(req, marshalStartRequestSchema); let resp: StartRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStartRequest_ResponseSchema); }; await execute(signal, call, options); @@ -470,22 +371,31 @@ export class Client { return resp; } - /** Stops a SQL warehouse. */ - async stopWarehouse( +async startWarehouseWaiter( signal: AbortSignal | undefined, - req: StopRequest, + req: StartRequest, options?: Options - ): Promise { + ): Promise { + await this.startWarehouse(signal, req, options); + if (req.id === undefined) { + throw new Error( + 'request field id required for polling is missing' + ); + } + return new StartWarehouseWaiter( + this, + req.id, + ); + } + + /** Stops a SQL warehouse. */ + async stopWarehouse(signal: AbortSignal | undefined, req: StopRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/sql/warehouses/${req.id ?? ''}/stop`; const body = marshalRequest(req, marshalStopRequestSchema); let resp: StopRequest_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('POST', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalStopRequest_ResponseSchema); }; await execute(signal, call, options); @@ -495,37 +405,43 @@ export class Client { return resp; } +async stopWarehouseWaiter( + signal: AbortSignal | undefined, + req: StopRequest, + options?: Options + ): Promise { + await this.stopWarehouse(signal, req, options); + if (req.id === undefined) { + throw new Error( + 'request field id required for polling is missing' + ); + } + return new StopWarehouseWaiter( + this, + req.id, + ); + } + /** * Updates an existing default warehouse override for a user. * Users can update their own override. Admins can update overrides for any user. */ - async updateDefaultWarehouseOverride( - signal: AbortSignal | undefined, - req: UpdateDefaultWarehouseOverrideRequest, - options?: Options - ): Promise { + async updateDefaultWarehouseOverride(signal: AbortSignal | undefined, req: UpdateDefaultWarehouseOverrideRequest, options?: Options): Promise { const url = `${this.host}/api/warehouses/v1/${req.defaultWarehouseOverride?.name ?? ''}`; const params = new URLSearchParams(); if (req.updateMask !== undefined) { - params.append('update_mask', req.updateMask); + params.append('update_mask', req.updateMask.paths.join(',')); } if (req.allowMissing !== undefined) { params.append('allow_missing', String(req.allowMissing)); } const query = params.toString(); const fullUrl = query !== '' ? `${url}?${query}` : url; - const body = marshalRequest( - req.defaultWarehouseOverride, - marshalDefaultWarehouseOverrideSchema - ); + const body = marshalRequest(req.defaultWarehouseOverride, marshalDefaultWarehouseOverrideSchema); let resp: DefaultWarehouseOverride | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', fullUrl, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalDefaultWarehouseOverrideSchema); }; await execute(signal, call, options); @@ -535,3 +451,347 @@ export class Client { return resp; } } + +export class CreateWarehouseWaiter { + constructor( + private readonly client: Client, + readonly id: string, + ) {} + + /** + * Polls until the operation reaches a terminal state. + * + * Throws if a failure state is reached. + */ + async wait( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + let result: GetWarehouse_Response | undefined; + + const call: Call = async (callSignal?: AbortSignal): Promise => { + const pollResp = await this.client.getWarehouse( + callSignal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.RUNNING: + result = pollResp; + return; + case EndpointState.STOPPED: + case EndpointState.DELETED: + { + const msg = pollResp.health?.summary ?? '(no message)'; + throw new Error(`terminal state ${status}: ${msg}`); + } + default: + throw new StillRunningError(); + } + }; + + const retryOptions: Options = { + retrier: () => + retryOn({}, (err: Error) => { + return err instanceof StillRunningError; + }), + }; + await execute(signal, call, retryOptions); + if (result === undefined) { + throw new Error('API call completed without a result.'); + } + return result; + } + + /** Checks whether the operation has reached a terminal state. */ + async done( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + const pollResp = await this.client.getWarehouse( + signal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.RUNNING: + case EndpointState.STOPPED: + case EndpointState.DELETED: + return true; + default: + return false; + } + } +} + +export class EditWarehouseWaiter { + constructor( + private readonly client: Client, + readonly id: string, + ) {} + + /** + * Polls until the operation reaches a terminal state. + * + * Throws if a failure state is reached. + */ + async wait( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + let result: GetWarehouse_Response | undefined; + + const call: Call = async (callSignal?: AbortSignal): Promise => { + const pollResp = await this.client.getWarehouse( + callSignal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.RUNNING: + result = pollResp; + return; + case EndpointState.STOPPED: + case EndpointState.DELETED: + { + const msg = pollResp.health?.summary ?? '(no message)'; + throw new Error(`terminal state ${status}: ${msg}`); + } + default: + throw new StillRunningError(); + } + }; + + const retryOptions: Options = { + retrier: () => + retryOn({}, (err: Error) => { + return err instanceof StillRunningError; + }), + }; + await execute(signal, call, retryOptions); + if (result === undefined) { + throw new Error('API call completed without a result.'); + } + return result; + } + + /** Checks whether the operation has reached a terminal state. */ + async done( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + const pollResp = await this.client.getWarehouse( + signal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.RUNNING: + case EndpointState.STOPPED: + case EndpointState.DELETED: + return true; + default: + return false; + } + } +} + +export class StartWarehouseWaiter { + constructor( + private readonly client: Client, + readonly id: string, + ) {} + + /** + * Polls until the operation reaches a terminal state. + * + * Throws if a failure state is reached. + */ + async wait( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + let result: GetWarehouse_Response | undefined; + + const call: Call = async (callSignal?: AbortSignal): Promise => { + const pollResp = await this.client.getWarehouse( + callSignal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.RUNNING: + result = pollResp; + return; + case EndpointState.STOPPED: + case EndpointState.DELETED: + { + const msg = pollResp.health?.summary ?? '(no message)'; + throw new Error(`terminal state ${status}: ${msg}`); + } + default: + throw new StillRunningError(); + } + }; + + const retryOptions: Options = { + retrier: () => + retryOn({}, (err: Error) => { + return err instanceof StillRunningError; + }), + }; + await execute(signal, call, retryOptions); + if (result === undefined) { + throw new Error('API call completed without a result.'); + } + return result; + } + + /** Checks whether the operation has reached a terminal state. */ + async done( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + const pollResp = await this.client.getWarehouse( + signal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.RUNNING: + case EndpointState.STOPPED: + case EndpointState.DELETED: + return true; + default: + return false; + } + } +} + +export class StopWarehouseWaiter { + constructor( + private readonly client: Client, + readonly id: string, + ) {} + + /** + * Polls until the operation reaches a terminal state. + * + * Throws if a failure state is reached. + */ + async wait( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + let result: GetWarehouse_Response | undefined; + + const call: Call = async (callSignal?: AbortSignal): Promise => { + const pollResp = await this.client.getWarehouse( + callSignal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.STOPPED: + result = pollResp; + return; + default: + throw new StillRunningError(); + } + }; + + const retryOptions: Options = { + retrier: () => + retryOn({}, (err: Error) => { + return err instanceof StillRunningError; + }), + }; + await execute(signal, call, retryOptions); + if (result === undefined) { + throw new Error('API call completed without a result.'); + } + return result; + } + + /** Checks whether the operation has reached a terminal state. */ + async done( + signal: AbortSignal | undefined, + options?: Options + ): Promise { + const pollResp = await this.client.getWarehouse( + signal, + { + id: this.id, + }, + options + ); + + const status = pollResp.state; + if (status === undefined) { + throw new Error('response missing required status field'); + } + + switch (status) { + case EndpointState.STOPPED: + return true; + default: + return false; + } + } +} diff --git a/packages/warehouses/src/v1/index.ts b/packages/warehouses/src/v1/index.ts index 3498468f..b3546609 100644 --- a/packages/warehouses/src/v1/index.ts +++ b/packages/warehouses/src/v1/index.ts @@ -1,6 +1,7 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. -export {Client} from './client'; + +export {Client, CreateWarehouseWaiter, EditWarehouseWaiter, StartWarehouseWaiter, StopWarehouseWaiter} from './client'; export { ChannelName, diff --git a/packages/warehouses/src/v1/model.ts b/packages/warehouses/src/v1/model.ts index dadabf48..419c6aca 100644 --- a/packages/warehouses/src/v1/model.ts +++ b/packages/warehouses/src/v1/model.ts @@ -1,5 +1,6 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. +import {FieldMask, type FieldPaths} from '@databricks/sdk-core/wkt'; import {z} from 'zod'; export enum ChannelName { @@ -33,10 +34,10 @@ export enum EndpointSecurityPolicy { /** * EndpointSpotInstancePolicy configures whether the endpoint should use spot * instances. - * + * * The breakdown of how the EndpointSpotInstancePolicy converts to per cloud * configurations is: - * + * * +-------+--------------------------------------+--------------------------------+ * | Cloud | COST_OPTIMIZED | RELIABILITY_OPTIMIZED | * +-------+--------------------------------------+--------------------------------+ @@ -44,7 +45,7 @@ export enum EndpointSecurityPolicy { * Executors | | AZURE | On Demand Driver and Executors | On Demand Driver * and Executors | * +-------+--------------------------------------+--------------------------------+ - * + * * While including "spot" in the enum name may limit the the future * extensibility of this field because it limits this enum to denoting "spot or * not", this is the field that PM recommends after discussion with customers @@ -55,7 +56,7 @@ export enum EndpointSpotInstancePolicy { * UNSPECIFIED if no value is set by the caller. * Consult endpoint docs to learn about the defaults that kick in if * UNSPECIFIED. - * + * * Protobuf enums should start with INVALID/UNSPECIFIED=0 * (https://github.com/uber/prototool/tree/dev/style#enums), but since proto * enum values must be unique within a proto package so protobuf recommends @@ -63,11 +64,11 @@ export enum EndpointSpotInstancePolicy { * (https://buf.build/docs/lint-checkers/#enum_value_prefix). We do not want * to do that because it makes for unergonomic customer facing JSON api * {"spot_instance_policy": "ENDPOINT_SPOT_INSTANCE_POLICY_UNSPECIFIED"}. - * + * * As a compromise between protobuf rules (i.e., package unique enum values) * and JSON friendliness, we prevent UNSPECIFIED collision but hope that the * rest of the enums do not collide. - * + * * This follows Google APIs: * https://cloud.google.com/apis/design/design_patterns#enum_default_value. */ @@ -439,14 +440,14 @@ export enum TerminationCode { INVALID_AWS_PARAMETER = 'INVALID_AWS_PARAMETER', /** * ** Only relevant on k8s dataplanes (i.e. clusters launched with CMv2 - not CMv1). - * + * * k8s evicted the driver pod due to disk pressure on the driver node. This is likely due to a * customer job consuming too much disk and so this is classified as a customer issue. */ DRIVER_OUT_OF_DISK = 'DRIVER_OUT_OF_DISK', /** * ** Only relevant on k8s dataplanes (i.e. clusters launched with CMv2 - not CMv1). - * + * * k8s evicted the driver pod due to memory pressure on the driver node. A customer job consuming * significant amounts of memory should not be able to trigger this as the driver container would * OOM first (we set memory limits on our pods). Thus this termination reason will be considered @@ -738,7 +739,7 @@ export interface CreateDefaultWarehouseOverrideRequest { export interface CreateWarehouse { /** * Logical name for the cluster. - * + * * Supported values: * - Must be unique within an org. * - Must be less than 100 characters. @@ -749,7 +750,7 @@ export interface CreateWarehouse { * 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 @@ -769,33 +770,33 @@ export interface CreateWarehouse { * 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?: number | undefined; /** * 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?: number | undefined; /** * 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?: number | undefined; @@ -806,7 +807,7 @@ export interface CreateWarehouse { /** * 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. */ @@ -815,7 +816,7 @@ export interface CreateWarehouse { spotInstancePolicy?: EndpointSpotInstancePolicy | undefined; /** * Configures whether the warehouse should use Photon optimized clusters. - * + * * Defaults to true. */ enablePhoton?: boolean | undefined; @@ -882,7 +883,7 @@ export interface EditWarehouseRequest { id?: string | undefined; /** * Logical name for the cluster. - * + * * Supported values: * - Must be unique within an org. * - Must be less than 100 characters. @@ -893,7 +894,7 @@ export interface EditWarehouseRequest { * 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 @@ -913,33 +914,33 @@ export interface EditWarehouseRequest { * 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?: number | undefined; /** * 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?: number | undefined; /** * 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?: number | undefined; @@ -950,7 +951,7 @@ export interface EditWarehouseRequest { /** * 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. */ @@ -959,7 +960,7 @@ export interface EditWarehouseRequest { spotInstancePolicy?: EndpointSpotInstancePolicy | undefined; /** * Configures whether the warehouse should use Photon optimized clusters. - * + * * Defaults to true. */ enablePhoton?: boolean | undefined; @@ -1000,7 +1001,7 @@ export interface EndpointInfo { id?: string | undefined; /** * Logical name for the cluster. - * + * * Supported values: * - Must be unique within an org. * - Must be less than 100 characters. @@ -1011,7 +1012,7 @@ export interface EndpointInfo { * 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 @@ -1031,33 +1032,33 @@ export interface EndpointInfo { * 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?: number | undefined; /** * 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?: number | undefined; /** * 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?: number | undefined; @@ -1068,7 +1069,7 @@ export interface EndpointInfo { /** * 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. */ @@ -1077,7 +1078,7 @@ export interface EndpointInfo { spotInstancePolicy?: EndpointSpotInstancePolicy | undefined; /** * Configures whether the warehouse should use Photon optimized clusters. - * + * * Defaults to true. */ enablePhoton?: boolean | undefined; @@ -1135,7 +1136,7 @@ export interface GetWarehouse_Response { id?: string | undefined; /** * Logical name for the cluster. - * + * * Supported values: * - Must be unique within an org. * - Must be less than 100 characters. @@ -1146,7 +1147,7 @@ export interface GetWarehouse_Response { * 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 @@ -1166,33 +1167,33 @@ export interface GetWarehouse_Response { * 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?: number | undefined; /** * 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?: number | undefined; /** * 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?: number | undefined; @@ -1203,7 +1204,7 @@ export interface GetWarehouse_Response { /** * 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. */ @@ -1212,7 +1213,7 @@ export interface GetWarehouse_Response { spotInstancePolicy?: EndpointSpotInstancePolicy | undefined; /** * Configures whether the warehouse should use Photon optimized clusters. - * + * * Defaults to true. */ enablePhoton?: boolean | undefined; @@ -1300,7 +1301,7 @@ export interface ListDefaultWarehouseOverridesRequest { /** * 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. */ @@ -1333,7 +1334,7 @@ export interface RepeatedEndpointConfPairs { /** * Sets the workspace level warehouse configuration that is shared by all SQL warehouses in this workspace. - * + * * This is idempotent. */ export interface SetWorkspaceWarehouseConfigRequest { @@ -1409,7 +1410,7 @@ export interface UpdateDefaultWarehouseOverrideRequest { * Use "*" to update all fields. * When allow_missing is true, this field is ignored and all fields are applied. */ - updateMask?: string | undefined; + updateMask?: FieldMask> | undefined; /** * 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. @@ -1461,7 +1462,7 @@ export interface ListWarehousesRequest { * 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. */ @@ -1513,18 +1514,15 @@ export const unmarshalChannelSchema: z.ZodType = z dbsqlVersion: d.dbsql_version, })); -export const unmarshalCreateDefaultWarehouseOverrideRequestSchema: z.ZodType = - z - .object({ - default_warehouse_override_id: z.string().optional(), - default_warehouse_override: z - .lazy(() => unmarshalDefaultWarehouseOverrideSchema) - .optional(), - }) - .transform(d => ({ - defaultWarehouseOverrideId: d.default_warehouse_override_id, - defaultWarehouseOverride: d.default_warehouse_override, - })); +export const unmarshalCreateDefaultWarehouseOverrideRequestSchema: z.ZodType = z + .object({ + default_warehouse_override_id: z.string().optional(), + default_warehouse_override: z.lazy(() => unmarshalDefaultWarehouseOverrideSchema).optional(), + }) + .transform(d => ({ + defaultWarehouseOverrideId: d.default_warehouse_override_id, + defaultWarehouseOverride: d.default_warehouse_override, + })); export const unmarshalCreateWarehouseSchema: z.ZodType = z .object({ @@ -1559,77 +1557,74 @@ export const unmarshalCreateWarehouseSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalCreateWarehouse_ResponseSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - })); - -export const unmarshalDefaultWarehouseOverrideSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - default_warehouse_override_id: z.string().optional(), - type: z.enum(DefaultWarehouseOverrideType).optional(), - warehouse_id: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - defaultWarehouseOverrideId: d.default_warehouse_override_id, - type: d.type, - warehouseId: d.warehouse_id, - })); - -export const unmarshalDeleteDefaultWarehouseOverrideRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); - -export const unmarshalEditWarehouseRequestSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - name: z.string().optional(), - cluster_size: z.string().optional(), - min_num_clusters: z.number().optional(), - max_num_clusters: z.number().optional(), - auto_stop_mins: z.number().optional(), - creator_name: z.string().optional(), - instance_profile_arn: z.string().optional(), - tags: z.lazy(() => unmarshalEndpointTagsSchema).optional(), - spot_instance_policy: z.enum(EndpointSpotInstancePolicy).optional(), - enable_photon: z.boolean().optional(), - channel: z.lazy(() => unmarshalChannelSchema).optional(), - enable_serverless_compute: z.boolean().optional(), - warehouse_type: z.enum(WarehouseType).optional(), - }) - .transform(d => ({ - id: d.id, - name: d.name, - clusterSize: d.cluster_size, - minNumClusters: d.min_num_clusters, - maxNumClusters: d.max_num_clusters, - autoStopMins: d.auto_stop_mins, - creatorName: d.creator_name, - instanceProfileArn: d.instance_profile_arn, - tags: d.tags, - spotInstancePolicy: d.spot_instance_policy, - enablePhoton: d.enable_photon, - channel: d.channel, - enableServerlessCompute: d.enable_serverless_compute, - warehouseType: d.warehouse_type, - })); +export const unmarshalCreateWarehouse_ResponseSchema: z.ZodType = z + .object({ + id: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + })); + +export const unmarshalDefaultWarehouseOverrideSchema: z.ZodType = z + .object({ + name: z.string().optional(), + default_warehouse_override_id: z.string().optional(), + type: z.enum(DefaultWarehouseOverrideType).optional(), + warehouse_id: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + defaultWarehouseOverrideId: d.default_warehouse_override_id, + type: d.type, + warehouseId: d.warehouse_id, + })); + +export const unmarshalDeleteDefaultWarehouseOverrideRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); + +export const unmarshalEditWarehouseRequestSchema: z.ZodType = z + .object({ + id: z.string().optional(), + name: z.string().optional(), + cluster_size: z.string().optional(), + min_num_clusters: z.number().optional(), + max_num_clusters: z.number().optional(), + auto_stop_mins: z.number().optional(), + creator_name: z.string().optional(), + instance_profile_arn: z.string().optional(), + tags: z.lazy(() => unmarshalEndpointTagsSchema).optional(), + spot_instance_policy: z.enum(EndpointSpotInstancePolicy).optional(), + enable_photon: z.boolean().optional(), + channel: z.lazy(() => unmarshalChannelSchema).optional(), + enable_serverless_compute: z.boolean().optional(), + warehouse_type: z.enum(WarehouseType).optional(), + }) + .transform(d => ({ + id: d.id, + name: d.name, + clusterSize: d.cluster_size, + minNumClusters: d.min_num_clusters, + maxNumClusters: d.max_num_clusters, + autoStopMins: d.auto_stop_mins, + creatorName: d.creator_name, + instanceProfileArn: d.instance_profile_arn, + tags: d.tags, + spotInstancePolicy: d.spot_instance_policy, + enablePhoton: d.enable_photon, + channel: d.channel, + enableServerlessCompute: d.enable_serverless_compute, + warehouseType: d.warehouse_type, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalEditWarehouseRequest_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalEditWarehouseRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalEndpointConfPairSchema: z.ZodType = z .object({ @@ -1715,22 +1710,19 @@ export const unmarshalEndpointTagPairSchema: z.ZodType = z export const unmarshalEndpointTagsSchema: z.ZodType = z .object({ - custom_tags: z - .array(z.lazy(() => unmarshalEndpointTagPairSchema)) - .optional(), + custom_tags: z.array(z.lazy(() => unmarshalEndpointTagPairSchema)).optional(), }) .transform(d => ({ customTags: d.custom_tags, })); -export const unmarshalGetDefaultWarehouseOverrideRequestSchema: z.ZodType = - z - .object({ - name: z.string().optional(), - }) - .transform(d => ({ - name: d.name, - })); +export const unmarshalGetDefaultWarehouseOverrideRequestSchema: z.ZodType = z + .object({ + name: z.string().optional(), + }) + .transform(d => ({ + name: d.name, + })); export const unmarshalGetWarehouseSchema: z.ZodType = z .object({ @@ -1741,117 +1733,102 @@ export const unmarshalGetWarehouseSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetWarehouse_ResponseSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - name: z.string().optional(), - cluster_size: z.string().optional(), - min_num_clusters: z.number().optional(), - max_num_clusters: z.number().optional(), - auto_stop_mins: z.number().optional(), - creator_name: z.string().optional(), - instance_profile_arn: z.string().optional(), - tags: z.lazy(() => unmarshalEndpointTagsSchema).optional(), - spot_instance_policy: z.enum(EndpointSpotInstancePolicy).optional(), - enable_photon: z.boolean().optional(), - channel: z.lazy(() => unmarshalChannelSchema).optional(), - enable_serverless_compute: z.boolean().optional(), - warehouse_type: z.enum(WarehouseType).optional(), - num_clusters: z.number().optional(), - num_active_sessions: z.number().optional(), - state: z.enum(EndpointState).optional(), - jdbc_url: z.string().optional(), - odbc_params: z.lazy(() => unmarshalOdbcParamsSchema).optional(), - health: z.lazy(() => unmarshalEndpointHealthSchema).optional(), - }) - .transform(d => ({ - id: d.id, - name: d.name, - clusterSize: d.cluster_size, - minNumClusters: d.min_num_clusters, - maxNumClusters: d.max_num_clusters, - autoStopMins: d.auto_stop_mins, - creatorName: d.creator_name, - instanceProfileArn: d.instance_profile_arn, - tags: d.tags, - spotInstancePolicy: d.spot_instance_policy, - enablePhoton: d.enable_photon, - channel: d.channel, - enableServerlessCompute: d.enable_serverless_compute, - warehouseType: d.warehouse_type, - numClusters: d.num_clusters, - numActiveSessions: d.num_active_sessions, - state: d.state, - jdbcUrl: d.jdbc_url, - odbcParams: d.odbc_params, - health: d.health, - })); - -export const unmarshalGetWorkspaceWarehouseConfigRequestSchema: z.ZodType = - z.object({}); +export const unmarshalGetWarehouse_ResponseSchema: z.ZodType = z + .object({ + id: z.string().optional(), + name: z.string().optional(), + cluster_size: z.string().optional(), + min_num_clusters: z.number().optional(), + max_num_clusters: z.number().optional(), + auto_stop_mins: z.number().optional(), + creator_name: z.string().optional(), + instance_profile_arn: z.string().optional(), + tags: z.lazy(() => unmarshalEndpointTagsSchema).optional(), + spot_instance_policy: z.enum(EndpointSpotInstancePolicy).optional(), + enable_photon: z.boolean().optional(), + channel: z.lazy(() => unmarshalChannelSchema).optional(), + enable_serverless_compute: z.boolean().optional(), + warehouse_type: z.enum(WarehouseType).optional(), + num_clusters: z.number().optional(), + num_active_sessions: z.number().optional(), + state: z.enum(EndpointState).optional(), + jdbc_url: z.string().optional(), + odbc_params: z.lazy(() => unmarshalOdbcParamsSchema).optional(), + health: z.lazy(() => unmarshalEndpointHealthSchema).optional(), + }) + .transform(d => ({ + id: d.id, + name: d.name, + clusterSize: d.cluster_size, + minNumClusters: d.min_num_clusters, + maxNumClusters: d.max_num_clusters, + autoStopMins: d.auto_stop_mins, + creatorName: d.creator_name, + instanceProfileArn: d.instance_profile_arn, + tags: d.tags, + spotInstancePolicy: d.spot_instance_policy, + enablePhoton: d.enable_photon, + channel: d.channel, + enableServerlessCompute: d.enable_serverless_compute, + warehouseType: d.warehouse_type, + numClusters: d.num_clusters, + numActiveSessions: d.num_active_sessions, + state: d.state, + jdbcUrl: d.jdbc_url, + odbcParams: d.odbc_params, + health: d.health, + })); + +export const unmarshalGetWorkspaceWarehouseConfigRequestSchema: z.ZodType = z + .object({ + }); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = - z - .object({ - security_policy: z.enum(EndpointSecurityPolicy).optional(), - data_access_config: z - .array(z.lazy(() => unmarshalEndpointConfPairSchema)) - .optional(), - instance_profile_arn: z.string().optional(), - channel: z.lazy(() => unmarshalChannelSchema).optional(), - enable_serverless_compute: z.boolean().optional(), - global_param: z - .lazy(() => unmarshalRepeatedEndpointConfPairsSchema) - .optional(), - config_param: z - .lazy(() => unmarshalRepeatedEndpointConfPairsSchema) - .optional(), - sql_configuration_parameters: z - .lazy(() => unmarshalRepeatedEndpointConfPairsSchema) - .optional(), - google_service_account: z.string().optional(), - enabled_warehouse_types: z - .array(z.lazy(() => unmarshalWarehouseTypePairSchema)) - .optional(), - }) - .transform(d => ({ - securityPolicy: d.security_policy, - dataAccessConfig: d.data_access_config, - instanceProfileArn: d.instance_profile_arn, - channel: d.channel, - enableServerlessCompute: d.enable_serverless_compute, - globalParam: d.global_param, - configParam: d.config_param, - sqlConfigurationParameters: d.sql_configuration_parameters, - googleServiceAccount: d.google_service_account, - enabledWarehouseTypes: d.enabled_warehouse_types, - })); - -export const unmarshalListDefaultWarehouseOverridesRequestSchema: z.ZodType = - z - .object({ - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - pageSize: d.page_size, - pageToken: d.page_token, - })); - -export const unmarshalListDefaultWarehouseOverridesResponseSchema: z.ZodType = - z - .object({ - default_warehouse_overrides: z - .array(z.lazy(() => unmarshalDefaultWarehouseOverrideSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - defaultWarehouseOverrides: d.default_warehouse_overrides, - nextPageToken: d.next_page_token, - })); +export const unmarshalGetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = z + .object({ + security_policy: z.enum(EndpointSecurityPolicy).optional(), + data_access_config: z.array(z.lazy(() => unmarshalEndpointConfPairSchema)).optional(), + instance_profile_arn: z.string().optional(), + channel: z.lazy(() => unmarshalChannelSchema).optional(), + enable_serverless_compute: z.boolean().optional(), + global_param: z.lazy(() => unmarshalRepeatedEndpointConfPairsSchema).optional(), + config_param: z.lazy(() => unmarshalRepeatedEndpointConfPairsSchema).optional(), + sql_configuration_parameters: z.lazy(() => unmarshalRepeatedEndpointConfPairsSchema).optional(), + google_service_account: z.string().optional(), + enabled_warehouse_types: z.array(z.lazy(() => unmarshalWarehouseTypePairSchema)).optional(), + }) + .transform(d => ({ + securityPolicy: d.security_policy, + dataAccessConfig: d.data_access_config, + instanceProfileArn: d.instance_profile_arn, + channel: d.channel, + enableServerlessCompute: d.enable_serverless_compute, + globalParam: d.global_param, + configParam: d.config_param, + sqlConfigurationParameters: d.sql_configuration_parameters, + googleServiceAccount: d.google_service_account, + enabledWarehouseTypes: d.enabled_warehouse_types, + })); + +export const unmarshalListDefaultWarehouseOverridesRequestSchema: z.ZodType = z + .object({ + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + pageSize: d.page_size, + pageToken: d.page_token, + })); + +export const unmarshalListDefaultWarehouseOverridesResponseSchema: z.ZodType = z + .object({ + default_warehouse_overrides: z.array(z.lazy(() => unmarshalDefaultWarehouseOverrideSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + defaultWarehouseOverrides: d.default_warehouse_overrides, + nextPageToken: d.next_page_token, + })); export const unmarshalOdbcParamsSchema: z.ZodType = z .object({ @@ -1867,61 +1844,46 @@ export const unmarshalOdbcParamsSchema: z.ZodType = z port: d.port, })); -export const unmarshalRepeatedEndpointConfPairsSchema: z.ZodType = - z - .object({ - config_pair: z - .array(z.lazy(() => unmarshalEndpointConfPairSchema)) - .optional(), - configuration_pairs: z - .array(z.lazy(() => unmarshalEndpointConfPairSchema)) - .optional(), - }) - .transform(d => ({ - configPair: d.config_pair, - configurationPairs: d.configuration_pairs, - })); - -export const unmarshalSetWorkspaceWarehouseConfigRequestSchema: z.ZodType = - z - .object({ - security_policy: z.enum(EndpointSecurityPolicy).optional(), - data_access_config: z - .array(z.lazy(() => unmarshalEndpointConfPairSchema)) - .optional(), - instance_profile_arn: z.string().optional(), - channel: z.lazy(() => unmarshalChannelSchema).optional(), - enable_serverless_compute: z.boolean().optional(), - global_param: z - .lazy(() => unmarshalRepeatedEndpointConfPairsSchema) - .optional(), - config_param: z - .lazy(() => unmarshalRepeatedEndpointConfPairsSchema) - .optional(), - sql_configuration_parameters: z - .lazy(() => unmarshalRepeatedEndpointConfPairsSchema) - .optional(), - google_service_account: z.string().optional(), - enabled_warehouse_types: z - .array(z.lazy(() => unmarshalWarehouseTypePairSchema)) - .optional(), - }) - .transform(d => ({ - securityPolicy: d.security_policy, - dataAccessConfig: d.data_access_config, - instanceProfileArn: d.instance_profile_arn, - channel: d.channel, - enableServerlessCompute: d.enable_serverless_compute, - globalParam: d.global_param, - configParam: d.config_param, - sqlConfigurationParameters: d.sql_configuration_parameters, - googleServiceAccount: d.google_service_account, - enabledWarehouseTypes: d.enabled_warehouse_types, - })); +export const unmarshalRepeatedEndpointConfPairsSchema: z.ZodType = z + .object({ + config_pair: z.array(z.lazy(() => unmarshalEndpointConfPairSchema)).optional(), + configuration_pairs: z.array(z.lazy(() => unmarshalEndpointConfPairSchema)).optional(), + }) + .transform(d => ({ + configPair: d.config_pair, + configurationPairs: d.configuration_pairs, + })); + +export const unmarshalSetWorkspaceWarehouseConfigRequestSchema: z.ZodType = z + .object({ + security_policy: z.enum(EndpointSecurityPolicy).optional(), + data_access_config: z.array(z.lazy(() => unmarshalEndpointConfPairSchema)).optional(), + instance_profile_arn: z.string().optional(), + channel: z.lazy(() => unmarshalChannelSchema).optional(), + enable_serverless_compute: z.boolean().optional(), + global_param: z.lazy(() => unmarshalRepeatedEndpointConfPairsSchema).optional(), + config_param: z.lazy(() => unmarshalRepeatedEndpointConfPairsSchema).optional(), + sql_configuration_parameters: z.lazy(() => unmarshalRepeatedEndpointConfPairsSchema).optional(), + google_service_account: z.string().optional(), + enabled_warehouse_types: z.array(z.lazy(() => unmarshalWarehouseTypePairSchema)).optional(), + }) + .transform(d => ({ + securityPolicy: d.security_policy, + dataAccessConfig: d.data_access_config, + instanceProfileArn: d.instance_profile_arn, + channel: d.channel, + enableServerlessCompute: d.enable_serverless_compute, + globalParam: d.global_param, + configParam: d.config_param, + sqlConfigurationParameters: d.sql_configuration_parameters, + googleServiceAccount: d.google_service_account, + enabledWarehouseTypes: d.enabled_warehouse_types, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalSetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalSetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalTerminationReasonSchema: z.ZodType = z .object({ @@ -1936,31 +1898,27 @@ export const unmarshalTerminationReasonSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalTerminationReason_ParametersEntrySchema: z.ZodType = - z - .object({ - key: z.string().optional(), - value: z.string().optional(), - }) - .transform(d => ({ - key: d.key, - value: d.value, - })); - -export const unmarshalUpdateDefaultWarehouseOverrideRequestSchema: z.ZodType = - z - .object({ - default_warehouse_override: z - .lazy(() => unmarshalDefaultWarehouseOverrideSchema) - .optional(), - update_mask: z.string().optional(), - allow_missing: z.boolean().optional(), - }) - .transform(d => ({ - defaultWarehouseOverride: d.default_warehouse_override, - updateMask: d.update_mask, - allowMissing: d.allow_missing, - })); +export const unmarshalTerminationReason_ParametersEntrySchema: z.ZodType = z + .object({ + key: z.string().optional(), + value: z.string().optional(), + }) + .transform(d => ({ + key: d.key, + value: d.value, + })); + +export const unmarshalUpdateDefaultWarehouseOverrideRequestSchema: z.ZodType = z + .object({ + default_warehouse_override: z.lazy(() => unmarshalDefaultWarehouseOverrideSchema).optional(), + update_mask: z.string().transform(s => FieldMask.of(...(s === '' ? [] : s.split(','))) as FieldMask>).optional(), + allow_missing: z.boolean().optional(), + }) + .transform(d => ({ + defaultWarehouseOverride: d.default_warehouse_override, + updateMask: d.update_mask, + allowMissing: d.allow_missing, + })); export const unmarshalWarehouseTypePairSchema: z.ZodType = z .object({ @@ -1972,43 +1930,41 @@ export const unmarshalWarehouseTypePairSchema: z.ZodType = z enabled: d.enabled, })); -export const unmarshalDeleteWarehouseRequestSchema: z.ZodType = - z - .object({ - id: z.string().optional(), - }) - .transform(d => ({ - id: d.id, - })); +export const unmarshalDeleteWarehouseRequestSchema: z.ZodType = z + .object({ + id: z.string().optional(), + }) + .transform(d => ({ + id: d.id, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalDeleteWarehouseRequest_ResponseSchema: z.ZodType = - z.object({}); - -export const unmarshalListWarehousesRequestSchema: z.ZodType = - z - .object({ - run_as_user_id: z.number().optional(), - page_size: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - runAsUserId: d.run_as_user_id, - pageSize: d.page_size, - pageToken: d.page_token, - })); +export const unmarshalDeleteWarehouseRequest_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalListWarehousesRequestSchema: z.ZodType = z + .object({ + run_as_user_id: z.number().optional(), + page_size: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + runAsUserId: d.run_as_user_id, + pageSize: d.page_size, + pageToken: d.page_token, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalListWarehousesRequest_ResponseSchema: z.ZodType = - z - .object({ - warehouses: z.array(z.lazy(() => unmarshalEndpointInfoSchema)).optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - warehouses: d.warehouses, - nextPageToken: d.next_page_token, - })); +export const unmarshalListWarehousesRequest_ResponseSchema: z.ZodType = z + .object({ + warehouses: z.array(z.lazy(() => unmarshalEndpointInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + warehouses: d.warehouses, + nextPageToken: d.next_page_token, + })); export const unmarshalStartRequestSchema: z.ZodType = z .object({ @@ -2019,8 +1975,9 @@ export const unmarshalStartRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalStartRequest_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalStartRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const unmarshalStopRequestSchema: z.ZodType = z .object({ @@ -2031,8 +1988,9 @@ export const unmarshalStopRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalStopRequest_ResponseSchema: z.ZodType = - z.object({}); +export const unmarshalStopRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalChannelSchema: z.ZodType = z .object({ @@ -2047,9 +2005,7 @@ export const marshalChannelSchema: z.ZodType = z export const marshalCreateDefaultWarehouseOverrideRequestSchema: z.ZodType = z .object({ defaultWarehouseOverrideId: z.string().optional(), - defaultWarehouseOverride: z - .lazy(() => marshalDefaultWarehouseOverrideSchema) - .optional(), + defaultWarehouseOverride: z.lazy(() => marshalDefaultWarehouseOverrideSchema).optional(), }) .transform(d => ({ default_warehouse_override_id: d.defaultWarehouseOverrideId, @@ -2154,9 +2110,9 @@ export const marshalEditWarehouseRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalEditWarehouseRequest_ResponseSchema: z.ZodType = z.object( - {} -); +export const marshalEditWarehouseRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalEndpointConfPairSchema: z.ZodType = z .object({ @@ -2311,46 +2267,36 @@ export const marshalGetWarehouse_ResponseSchema: z.ZodType = z health: d.health, })); -export const marshalGetWorkspaceWarehouseConfigRequestSchema: z.ZodType = - z.object({}); +export const marshalGetWorkspaceWarehouseConfigRequestSchema: z.ZodType = z + .object({ + }); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalGetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = - z - .object({ - securityPolicy: z.enum(EndpointSecurityPolicy).optional(), - dataAccessConfig: z - .array(z.lazy(() => marshalEndpointConfPairSchema)) - .optional(), - instanceProfileArn: z.string().optional(), - channel: z.lazy(() => marshalChannelSchema).optional(), - enableServerlessCompute: z.boolean().optional(), - globalParam: z - .lazy(() => marshalRepeatedEndpointConfPairsSchema) - .optional(), - configParam: z - .lazy(() => marshalRepeatedEndpointConfPairsSchema) - .optional(), - sqlConfigurationParameters: z - .lazy(() => marshalRepeatedEndpointConfPairsSchema) - .optional(), - googleServiceAccount: z.string().optional(), - enabledWarehouseTypes: z - .array(z.lazy(() => marshalWarehouseTypePairSchema)) - .optional(), - }) - .transform(d => ({ - security_policy: d.securityPolicy, - data_access_config: d.dataAccessConfig, - instance_profile_arn: d.instanceProfileArn, - channel: d.channel, - enable_serverless_compute: d.enableServerlessCompute, - global_param: d.globalParam, - config_param: d.configParam, - sql_configuration_parameters: d.sqlConfigurationParameters, - google_service_account: d.googleServiceAccount, - enabled_warehouse_types: d.enabledWarehouseTypes, - })); +export const marshalGetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = z + .object({ + securityPolicy: z.enum(EndpointSecurityPolicy).optional(), + dataAccessConfig: z.array(z.lazy(() => marshalEndpointConfPairSchema)).optional(), + instanceProfileArn: z.string().optional(), + channel: z.lazy(() => marshalChannelSchema).optional(), + enableServerlessCompute: z.boolean().optional(), + globalParam: z.lazy(() => marshalRepeatedEndpointConfPairsSchema).optional(), + configParam: z.lazy(() => marshalRepeatedEndpointConfPairsSchema).optional(), + sqlConfigurationParameters: z.lazy(() => marshalRepeatedEndpointConfPairsSchema).optional(), + googleServiceAccount: z.string().optional(), + enabledWarehouseTypes: z.array(z.lazy(() => marshalWarehouseTypePairSchema)).optional(), + }) + .transform(d => ({ + security_policy: d.securityPolicy, + data_access_config: d.dataAccessConfig, + instance_profile_arn: d.instanceProfileArn, + channel: d.channel, + enable_serverless_compute: d.enableServerlessCompute, + global_param: d.globalParam, + config_param: d.configParam, + sql_configuration_parameters: d.sqlConfigurationParameters, + google_service_account: d.googleServiceAccount, + enabled_warehouse_types: d.enabledWarehouseTypes, + })); export const marshalListDefaultWarehouseOverridesRequestSchema: z.ZodType = z .object({ @@ -2364,9 +2310,7 @@ export const marshalListDefaultWarehouseOverridesRequestSchema: z.ZodType = z export const marshalListDefaultWarehouseOverridesResponseSchema: z.ZodType = z .object({ - defaultWarehouseOverrides: z - .array(z.lazy(() => marshalDefaultWarehouseOverrideSchema)) - .optional(), + defaultWarehouseOverrides: z.array(z.lazy(() => marshalDefaultWarehouseOverrideSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -2391,9 +2335,7 @@ export const marshalOdbcParamsSchema: z.ZodType = z export const marshalRepeatedEndpointConfPairsSchema: z.ZodType = z .object({ configPair: z.array(z.lazy(() => marshalEndpointConfPairSchema)).optional(), - configurationPairs: z - .array(z.lazy(() => marshalEndpointConfPairSchema)) - .optional(), + configurationPairs: z.array(z.lazy(() => marshalEndpointConfPairSchema)).optional(), }) .transform(d => ({ config_pair: d.configPair, @@ -2403,25 +2345,15 @@ export const marshalRepeatedEndpointConfPairsSchema: z.ZodType = z export const marshalSetWorkspaceWarehouseConfigRequestSchema: z.ZodType = z .object({ securityPolicy: z.enum(EndpointSecurityPolicy).optional(), - dataAccessConfig: z - .array(z.lazy(() => marshalEndpointConfPairSchema)) - .optional(), + dataAccessConfig: z.array(z.lazy(() => marshalEndpointConfPairSchema)).optional(), instanceProfileArn: z.string().optional(), channel: z.lazy(() => marshalChannelSchema).optional(), enableServerlessCompute: z.boolean().optional(), - globalParam: z - .lazy(() => marshalRepeatedEndpointConfPairsSchema) - .optional(), - configParam: z - .lazy(() => marshalRepeatedEndpointConfPairsSchema) - .optional(), - sqlConfigurationParameters: z - .lazy(() => marshalRepeatedEndpointConfPairsSchema) - .optional(), + globalParam: z.lazy(() => marshalRepeatedEndpointConfPairsSchema).optional(), + configParam: z.lazy(() => marshalRepeatedEndpointConfPairsSchema).optional(), + sqlConfigurationParameters: z.lazy(() => marshalRepeatedEndpointConfPairsSchema).optional(), googleServiceAccount: z.string().optional(), - enabledWarehouseTypes: z - .array(z.lazy(() => marshalWarehouseTypePairSchema)) - .optional(), + enabledWarehouseTypes: z.array(z.lazy(() => marshalWarehouseTypePairSchema)).optional(), }) .transform(d => ({ security_policy: d.securityPolicy, @@ -2437,8 +2369,9 @@ export const marshalSetWorkspaceWarehouseConfigRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalSetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = - z.object({}); +export const marshalSetWorkspaceWarehouseConfigRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalTerminationReasonSchema: z.ZodType = z .object({ @@ -2465,10 +2398,8 @@ export const marshalTerminationReason_ParametersEntrySchema: z.ZodType = z export const marshalUpdateDefaultWarehouseOverrideRequestSchema: z.ZodType = z .object({ - defaultWarehouseOverride: z - .lazy(() => marshalDefaultWarehouseOverrideSchema) - .optional(), - updateMask: z.string().optional(), + defaultWarehouseOverride: z.lazy(() => marshalDefaultWarehouseOverrideSchema).optional(), + updateMask: z.any().transform((d: FieldMask>) => d.paths.join(',')).optional(), allowMissing: z.boolean().optional(), }) .transform(d => ({ @@ -2496,9 +2427,9 @@ export const marshalDeleteWarehouseRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalDeleteWarehouseRequest_ResponseSchema: z.ZodType = z.object( - {} -); +export const marshalDeleteWarehouseRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalListWarehousesRequestSchema: z.ZodType = z .object({ @@ -2532,7 +2463,9 @@ export const marshalStartRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalStartRequest_ResponseSchema: z.ZodType = z.object({}); +export const marshalStartRequest_ResponseSchema: z.ZodType = z + .object({ + }); export const marshalStopRequestSchema: z.ZodType = z .object({ @@ -2543,4 +2476,6 @@ export const marshalStopRequestSchema: z.ZodType = z })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const marshalStopRequest_ResponseSchema: z.ZodType = z.object({}); +export const marshalStopRequest_ResponseSchema: z.ZodType = z + .object({ + }); diff --git a/packages/warehouses/src/v1/utils.ts b/packages/warehouses/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/warehouses/src/v1/utils.ts +++ b/packages/warehouses/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/warehouses/tsconfig.json b/packages/warehouses/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/warehouses/tsconfig.json +++ b/packages/warehouses/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/workspaceassignment/package.json b/packages/workspaceassignment/package.json new file mode 100644 index 00000000..92bd4f3f --- /dev/null +++ b/packages/workspaceassignment/package.json @@ -0,0 +1,38 @@ +{ + "name": "@databricks/sdk-workspaceassignment", + "version": "0.1.0", + "description": "", + "type": "module", + "exports": { + "./v1": { + "types": "./dist/v1/index.d.ts", + "import": "./dist/v1/index.js" + } + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "tsc -b", + "lint": "eslint src --ext .ts", + "lint:fix": "eslint src --ext .ts --fix", + "format": "prettier --write \"src/**/*.ts\"", + "format:check": "prettier --check \"src/**/*.ts\"", + "typecheck": "tsc --noEmit", + "clean": "rm -rf dist tsconfig.tsbuildinfo", + "test": "echo 'no tests'", + "test:browser": "echo 'no tests'" + }, + "author": "Databricks", + "license": "Apache-2.0", + "dependencies": { + "@databricks/sdk-core": "*", + "@databricks/sdk-databricks": "*", + "@js-temporal/polyfill": "^0.5.0", + "zod": "^4.3.6" + }, + "engines": { + "node": ">=22.0.0" + } +} diff --git a/packages/workspaceassignment/src/v1/client.ts b/packages/workspaceassignment/src/v1/client.ts new file mode 100644 index 00000000..d566a815 --- /dev/null +++ b/packages/workspaceassignment/src/v1/client.ts @@ -0,0 +1,134 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import type {Call, Options} from '@databricks/sdk-databricks/api'; +import {execute} from '@databricks/sdk-databricks/api'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import {NoOpLogger} from '@databricks/sdk-databricks/logger'; +import type {ClientOptions} from '@databricks/sdk-databricks/options'; +import type {HttpClient} from '@databricks/sdk-databricks/transport'; +import {newHttpClient} from '@databricks/sdk-databricks/transport'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + DeleteWorkspacePermissionAssignment, + DeleteWorkspacePermissionAssignment_Response, + GetWorkspacePermissionAssignments, + GetWorkspacePermissionAssignments_Response, + ListWorkspacePermissions, + ListWorkspacePermissions_Response, + UpdateWorkspacePermissionAssignment, + WorkspacePermissionAssignmentOutput, +} from './model'; +import { + marshalUpdateWorkspacePermissionAssignmentSchema, + unmarshalDeleteWorkspacePermissionAssignment_ResponseSchema, + unmarshalGetWorkspacePermissionAssignments_ResponseSchema, + unmarshalListWorkspacePermissions_ResponseSchema, + unmarshalWorkspacePermissionAssignmentOutputSchema, +} from './model'; + +export class Client { + private readonly host: string; + private readonly httpClient: HttpClient; + private readonly logger: Logger; + + constructor(options: ClientOptions) { + if (options.host === undefined) { + throw new Error('Host is required.'); + } + this.host = options.host.replace(/\/$/, ''); + this.logger = options.logger ?? new NoOpLogger(); + this.httpClient = newHttpClient(options); + } + + /** Deletes the workspace permissions assignment in a given account and workspace for the specified principal. */ + async deleteWorkspacePermissionAssignment(signal: AbortSignal | undefined, req: DeleteWorkspacePermissionAssignment, options?: Options): Promise { + const url = `${this.host}/api/2.0/accounts//workspaces/${String(req.workspaceId ?? '')}/permissionassignments/principals/${String(req.principalId ?? '')}`; + const params = new URLSearchParams(); + if (req.accountId !== undefined) { + params.append('account_id', req.accountId); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: DeleteWorkspacePermissionAssignment_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('DELETE', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalDeleteWorkspacePermissionAssignment_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Get the permission assignments for the specified and . */ + async getWorkspacePermissionAssignments(signal: AbortSignal | undefined, req: GetWorkspacePermissionAssignments, options?: Options): Promise { + const url = `${this.host}/api/2.0/accounts//workspaces/${String(req.workspaceId ?? '')}/permissionassignments`; + const params = new URLSearchParams(); + if (req.accountId !== undefined) { + params.append('account_id', req.accountId); + } + if (req.pageToken !== undefined) { + params.append('page_token', req.pageToken); + } + if (req.maxResults !== undefined) { + params.append('max_results', String(req.maxResults)); + } + if (req.filter !== undefined) { + params.append('filter', req.filter); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: GetWorkspacePermissionAssignments_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetWorkspacePermissionAssignments_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Get an array of workspace permissions for the specified account and workspace. */ + async listWorkspacePermissions(signal: AbortSignal | undefined, req: ListWorkspacePermissions, options?: Options): Promise { + const url = `${this.host}/api/2.0/accounts//workspaces/${String(req.workspaceId ?? '')}/permissionassignments/permissions`; + const params = new URLSearchParams(); + if (req.accountId !== undefined) { + params.append('account_id', req.accountId); + } + const query = params.toString(); + const fullUrl = query !== '' ? `${url}?${query}` : url; + let resp: ListWorkspacePermissions_Response | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('GET', fullUrl, callSignal); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalListWorkspacePermissions_ResponseSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } + + /** Creates or updates the workspace permissions assignment in a given account and workspace for the specified principal. */ + async updateWorkspacePermissionAssignment(signal: AbortSignal | undefined, req: UpdateWorkspacePermissionAssignment, options?: Options): Promise { + const url = `${this.host}/api/2.0/accounts//workspaces/${String(req.workspaceId ?? '')}/permissionassignments/principals/${String(req.principalId ?? '')}`; + const body = marshalRequest(req, marshalUpdateWorkspacePermissionAssignmentSchema); + let resp: WorkspacePermissionAssignmentOutput | undefined; + const call: Call = async (callSignal?: AbortSignal): Promise => { + const httpReq = buildHttpRequest('PUT', url, callSignal, body); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalWorkspacePermissionAssignmentOutputSchema); + }; + await execute(signal, call, options); + if (resp === undefined) { + throw new Error('API call completed without a result.'); + } + return resp; + } +} diff --git a/packages/workspaceassignment/src/v1/index.ts b/packages/workspaceassignment/src/v1/index.ts new file mode 100644 index 00000000..48d261c4 --- /dev/null +++ b/packages/workspaceassignment/src/v1/index.ts @@ -0,0 +1,21 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + + +export {Client} from './client'; + +export { + Permission, +} from './model'; + +export type { + DeleteWorkspacePermissionAssignment, + DeleteWorkspacePermissionAssignment_Response, + GetWorkspacePermissionAssignments, + GetWorkspacePermissionAssignments_Response, + ListWorkspacePermissions, + ListWorkspacePermissions_Response, + PermissionOutput, + PrincipalOutput, + UpdateWorkspacePermissionAssignment, + WorkspacePermissionAssignmentOutput, +} from './model'; diff --git a/packages/workspaceassignment/src/v1/model.ts b/packages/workspaceassignment/src/v1/model.ts new file mode 100644 index 00000000..7bbecf2c --- /dev/null +++ b/packages/workspaceassignment/src/v1/model.ts @@ -0,0 +1,345 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {z} from 'zod'; + +export enum Permission { + UNKNOWN = 'UNKNOWN', + /** The most basic workspace permission */ + USER = 'USER', + ADMIN = 'ADMIN', +} + +/** Removes all permission assignments for a workspace given a principal. */ +export interface DeleteWorkspacePermissionAssignment { + /** The account ID. */ + accountId?: string | undefined; + /** The workspace ID for the account. */ + workspaceId?: number | undefined; + /** The ID of the user, service principal, or group. */ + principalId?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-object-type -- Proto-style nested message name. +export interface DeleteWorkspacePermissionAssignment_Response {} + +/** Gets all the permission assignments for a workspace, given an account and a workspace. */ +export interface GetWorkspacePermissionAssignments { + /** The account ID. */ + accountId?: string | undefined; + /** The workspace ID for the account. */ + workspaceId?: number | undefined; + /** Page token returned by previous call to retrieve the next page of results. */ + pageToken?: string | undefined; + /** Maximum number of permission assignments to return. */ + maxResults?: number | undefined; + /** Filter string to search principals. */ + filter?: string | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface GetWorkspacePermissionAssignments_Response { + /** Array of permissions assignments defined for a workspace. */ + permissionAssignments?: WorkspacePermissionAssignmentOutput[] | undefined; + /** Token to retrieve the next page of results. */ + nextPageToken?: string | undefined; + /** Token to retrieve the previous page of results. */ + prevPageToken?: string | undefined; +} + +/** List permissions for a workspace, given an account and a workspace. */ +export interface ListWorkspacePermissions { + /** The account ID. */ + accountId?: string | undefined; + /** The workspace ID. */ + workspaceId?: number | undefined; +} + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export interface ListWorkspacePermissions_Response { + /** Array of permissions defined for a workspace. */ + permissions?: PermissionOutput[] | undefined; +} + +export interface PermissionOutput { + permissionLevel?: Permission | undefined; + /** The results of a permissions query. */ + description?: string | undefined; +} + +/** Information about the principal assigned to the workspace. */ +export interface PrincipalOutput { + /** The username of the user. Present only if the principal is a user. */ + userName?: string | undefined; + /** The group name of the group. Present only if the principal is a group. */ + groupName?: string | undefined; + /** The name of the service principal. Present only if the principal is a service principal. */ + servicePrincipalName?: string | undefined; + /** The unique, opaque id of the principal. */ + principalId?: number | undefined; + /** The display name of the principal. */ + displayName?: string | undefined; +} + +export interface UpdateWorkspacePermissionAssignment { + /** The account ID. */ + accountId?: string | undefined; + /** The workspace ID. */ + workspaceId?: number | undefined; + /** The ID of the user, service principal, or group. */ + principalId?: number | undefined; + /** + * 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?: Permission[] | undefined; +} + +/** + * The output format for existing workspace PermissionAssignment records, which contains some info for + * user consumption. + */ +export interface WorkspacePermissionAssignmentOutput { + /** Information about the principal assigned to the workspace. */ + principal?: PrincipalOutput | undefined; + /** The permissions level of the principal. */ + permissions?: Permission[] | undefined; + /** Error response associated with a workspace permission assignment, if any. */ + error?: string | undefined; +} + +export const unmarshalDeleteWorkspacePermissionAssignmentSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + principal_id: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + principalId: d.principal_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalDeleteWorkspacePermissionAssignment_ResponseSchema: z.ZodType = z + .object({ + }); + +export const unmarshalGetWorkspacePermissionAssignmentsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + page_token: z.string().optional(), + max_results: z.number().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + pageToken: d.page_token, + maxResults: d.max_results, + filter: d.filter, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalGetWorkspacePermissionAssignments_ResponseSchema: z.ZodType = z + .object({ + permission_assignments: z.array(z.lazy(() => unmarshalWorkspacePermissionAssignmentOutputSchema)).optional(), + next_page_token: z.string().optional(), + prev_page_token: z.string().optional(), + }) + .transform(d => ({ + permissionAssignments: d.permission_assignments, + nextPageToken: d.next_page_token, + prevPageToken: d.prev_page_token, + })); + +export const unmarshalListWorkspacePermissionsSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const unmarshalListWorkspacePermissions_ResponseSchema: z.ZodType = z + .object({ + permissions: z.array(z.lazy(() => unmarshalPermissionOutputSchema)).optional(), + }) + .transform(d => ({ + permissions: d.permissions, + })); + +export const unmarshalPermissionOutputSchema: z.ZodType = z + .object({ + permission_level: z.enum(Permission).optional(), + description: z.string().optional(), + }) + .transform(d => ({ + permissionLevel: d.permission_level, + description: d.description, + })); + +export const unmarshalPrincipalOutputSchema: z.ZodType = z + .object({ + user_name: z.string().optional(), + group_name: z.string().optional(), + service_principal_name: z.string().optional(), + principal_id: z.number().optional(), + display_name: z.string().optional(), + }) + .transform(d => ({ + userName: d.user_name, + groupName: d.group_name, + servicePrincipalName: d.service_principal_name, + principalId: d.principal_id, + displayName: d.display_name, + })); + +export const unmarshalUpdateWorkspacePermissionAssignmentSchema: z.ZodType = z + .object({ + account_id: z.string().optional(), + workspace_id: z.number().optional(), + principal_id: z.number().optional(), + permissions: z.array(z.enum(Permission)).optional(), + }) + .transform(d => ({ + accountId: d.account_id, + workspaceId: d.workspace_id, + principalId: d.principal_id, + permissions: d.permissions, + })); + +export const unmarshalWorkspacePermissionAssignmentOutputSchema: z.ZodType = z + .object({ + principal: z.lazy(() => unmarshalPrincipalOutputSchema).optional(), + permissions: z.array(z.enum(Permission)).optional(), + error: z.string().optional(), + }) + .transform(d => ({ + principal: d.principal, + permissions: d.permissions, + error: d.error, + })); + +export const marshalDeleteWorkspacePermissionAssignmentSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + workspaceId: z.number().optional(), + principalId: z.number().optional(), + }) + .transform(d => ({ + account_id: d.accountId, + workspace_id: d.workspaceId, + principal_id: d.principalId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalDeleteWorkspacePermissionAssignment_ResponseSchema: z.ZodType = z + .object({ + }); + +export const marshalGetWorkspacePermissionAssignmentsSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + workspaceId: z.number().optional(), + pageToken: z.string().optional(), + maxResults: z.number().optional(), + filter: z.string().optional(), + }) + .transform(d => ({ + account_id: d.accountId, + workspace_id: d.workspaceId, + page_token: d.pageToken, + max_results: d.maxResults, + filter: d.filter, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalGetWorkspacePermissionAssignments_ResponseSchema: z.ZodType = z + .object({ + permissionAssignments: z.array(z.lazy(() => marshalWorkspacePermissionAssignmentOutputSchema)).optional(), + nextPageToken: z.string().optional(), + prevPageToken: z.string().optional(), + }) + .transform(d => ({ + permission_assignments: d.permissionAssignments, + next_page_token: d.nextPageToken, + prev_page_token: d.prevPageToken, + })); + +export const marshalListWorkspacePermissionsSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + workspaceId: z.number().optional(), + }) + .transform(d => ({ + account_id: d.accountId, + workspace_id: d.workspaceId, + })); + +// eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. +export const marshalListWorkspacePermissions_ResponseSchema: z.ZodType = z + .object({ + permissions: z.array(z.lazy(() => marshalPermissionOutputSchema)).optional(), + }) + .transform(d => ({ + permissions: d.permissions, + })); + +export const marshalPermissionOutputSchema: z.ZodType = z + .object({ + permissionLevel: z.enum(Permission).optional(), + description: z.string().optional(), + }) + .transform(d => ({ + permission_level: d.permissionLevel, + description: d.description, + })); + +export const marshalPrincipalOutputSchema: z.ZodType = z + .object({ + userName: z.string().optional(), + groupName: z.string().optional(), + servicePrincipalName: z.string().optional(), + principalId: z.number().optional(), + displayName: z.string().optional(), + }) + .transform(d => ({ + user_name: d.userName, + group_name: d.groupName, + service_principal_name: d.servicePrincipalName, + principal_id: d.principalId, + display_name: d.displayName, + })); + +export const marshalUpdateWorkspacePermissionAssignmentSchema: z.ZodType = z + .object({ + accountId: z.string().optional(), + workspaceId: z.number().optional(), + principalId: z.number().optional(), + permissions: z.array(z.enum(Permission)).optional(), + }) + .transform(d => ({ + account_id: d.accountId, + workspace_id: d.workspaceId, + principal_id: d.principalId, + permissions: d.permissions, + })); + +export const marshalWorkspacePermissionAssignmentOutputSchema: z.ZodType = z + .object({ + principal: z.lazy(() => marshalPrincipalOutputSchema).optional(), + permissions: z.array(z.enum(Permission)).optional(), + error: z.string().optional(), + }) + .transform(d => ({ + principal: d.principal, + permissions: d.permissions, + error: d.error, + })); diff --git a/packages/workspaceassignment/src/v1/utils.ts b/packages/workspaceassignment/src/v1/utils.ts new file mode 100644 index 00000000..8aa7a525 --- /dev/null +++ b/packages/workspaceassignment/src/v1/utils.ts @@ -0,0 +1,130 @@ +// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + +import {APIError} from '@databricks/sdk-databricks/apierror'; +import type {Logger} from '@databricks/sdk-databricks/logger'; +import type { + HttpClient, + HttpRequest, + HttpResponse, +} from '@databricks/sdk-databricks/transport'; +import type {z} from 'zod'; + +export interface HttpCallOptions { + readonly request: HttpRequest; + readonly httpClient: HttpClient; + readonly logger: Logger; +} + +async function readAll( + body: ReadableStream | null, +): Promise { + if (body === null) { + return new Uint8Array(0); + } + const reader = body.getReader(); + const chunks: Uint8Array[] = []; + for (;;) { + const {done, value} = await reader.read(); + if (done) { + break; + } + chunks.push(value); + } + const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0); + const result = new Uint8Array(totalLength); + let offset = 0; + for (const chunk of chunks) { + result.set(chunk, offset); + offset += chunk.length; + } + return result; +} + +export async function executeHttpCall( + opts: HttpCallOptions, +): Promise { + opts.logger.debug('HTTP request', { + method: opts.request.method, + url: opts.request.url, + }); + + let resp: HttpResponse; + try { + resp = await opts.httpClient.send(opts.request); + } catch (e: unknown) { + opts.logger.debug('HTTP request failed'); + throw e; + } + + const body = await readAll(resp.body); + + opts.logger.debug('HTTP response', { + statusCode: resp.statusCode, + body: new TextDecoder().decode(body), + }); + + const apiErr = APIError.fromHttpError(resp.statusCode, resp.headers, body); + if (apiErr !== undefined) { + throw apiErr; + } + + return body; +} + +export function buildHttpRequest( + method: string, + url: string, + signal?: AbortSignal, + body?: string, +): HttpRequest { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + + const req: HttpRequest = {url, method, headers}; + if (body !== undefined) { + req.body = body; + } + if (signal !== undefined) { + req.signal = signal; + } + return req; +} + +export function parseResponse(body: Uint8Array, schema: z.ZodType): T { + const text = new TextDecoder().decode(body); + const parsed: unknown = JSON.parse(text); + return schema.parse(parsed); +} + +export function marshalRequest(data: unknown, schema: z.ZodType): string { + return JSON.stringify(schema.parse(data)); +} + +export function flattenQueryParams( + prefix: string, + value: unknown, + params: URLSearchParams +): void { + if (value === null || value === undefined) { + return; + } + if (Array.isArray(value)) { + // arrays of objects are not yet supported + for (const item of value) { + params.append(prefix, String(item)); + } + } else if (typeof value === 'object') { + for (const [key, val] of Object.entries(value as Record)) { + flattenQueryParams(`${prefix}.${key}`, val, params); + } + } else if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' || + typeof value === 'bigint' + ) { + params.append(prefix, String(value)); + } else { + throw new Error(`Unsupported query parameter type: ${typeof value}`); + } +} diff --git a/packages/workspaceassignment/tsconfig.json b/packages/workspaceassignment/tsconfig.json new file mode 100644 index 00000000..8214ba8c --- /dev/null +++ b/packages/workspaceassignment/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"], + "exclude": ["dist", "node_modules", "tests"], + "references": [{"path": "../core"}, {"path": "../databricks"}] +} diff --git a/packages/workspacebindings/package.json b/packages/workspacebindings/package.json index ae001665..2f02868b 100644 --- a/packages/workspacebindings/package.json +++ b/packages/workspacebindings/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/workspacebindings/src/v1/client.ts b/packages/workspacebindings/src/v1/client.ts index a6159e19..aa363773 100644 --- a/packages/workspacebindings/src/v1/client.ts +++ b/packages/workspacebindings/src/v1/client.ts @@ -7,12 +7,7 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; import type { GetCatalogWorkspaceBindings, GetCatalogWorkspaceBindings_Response, @@ -51,24 +46,13 @@ export class Client { * Gets workspace bindings of the catalog. * The caller must be a metastore admin or an owner of the catalog. */ - async getCatalogWorkspaceBindings( - signal: AbortSignal | undefined, - req: GetCatalogWorkspaceBindings, - options?: Options - ): Promise { + async getCatalogWorkspaceBindings(signal: AbortSignal | undefined, req: GetCatalogWorkspaceBindings, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/workspace-bindings/catalogs/${req.catalogName ?? ''}`; let resp: GetCatalogWorkspaceBindings_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', url, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetCatalogWorkspaceBindings_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetCatalogWorkspaceBindings_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -80,17 +64,13 @@ export class Client { /** * Gets workspace bindings of the securable. * The caller must be a metastore admin or an owner of the securable. - * + * * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon. - * + * * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token. * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached. */ - async getWorkspaceBindings( - signal: AbortSignal | undefined, - req: GetWorkspaceBindings, - options?: Options - ): Promise { + async getWorkspaceBindings(signal: AbortSignal | undefined, req: GetWorkspaceBindings, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/bindings/${req.securableType ?? ''}/${req.securableFullName ?? ''}`; const params = new URLSearchParams(); if (req.maxResults !== undefined) { @@ -104,15 +84,8 @@ export class Client { let resp: GetWorkspaceBindings_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalGetWorkspaceBindings_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalGetWorkspaceBindings_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -121,11 +94,8 @@ export class Client { return resp; } - async *getWorkspaceBindingsIter( - signal: AbortSignal | undefined, - req: GetWorkspaceBindings, - options?: Options - ): AsyncGenerator { + + async *getWorkspaceBindingsIter(signal: AbortSignal | undefined, req: GetWorkspaceBindings, options?: Options): AsyncGenerator { const pageReq: GetWorkspaceBindings = {...req}; for (;;) { const resp = await this.getWorkspaceBindings(signal, pageReq, options); @@ -139,32 +109,19 @@ export class Client { } } + /** * Updates workspace bindings of the catalog. * The caller must be a metastore admin or an owner of the catalog. */ - async updateCatalogWorkspaceBindings( - signal: AbortSignal | undefined, - req: UpdateCatalogWorkspaceBindings, - options?: Options - ): Promise { + async updateCatalogWorkspaceBindings(signal: AbortSignal | undefined, req: UpdateCatalogWorkspaceBindings, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/workspace-bindings/catalogs/${req.catalogName ?? ''}`; - const body = marshalRequest( - req, - marshalUpdateCatalogWorkspaceBindingsSchema - ); + const body = marshalRequest(req, marshalUpdateCatalogWorkspaceBindingsSchema); let resp: UpdateCatalogWorkspaceBindings_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalUpdateCatalogWorkspaceBindings_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdateCatalogWorkspaceBindings_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { @@ -177,25 +134,14 @@ export class Client { * Updates workspace bindings of the securable. * The caller must be a metastore admin or an owner of the securable. */ - async updateWorkspaceBindings( - signal: AbortSignal | undefined, - req: UpdateWorkspaceBindings, - options?: Options - ): Promise { + async updateWorkspaceBindings(signal: AbortSignal | undefined, req: UpdateWorkspaceBindings, options?: Options): Promise { const url = `${this.host}/api/2.1/unity-catalog/bindings/${req.securableType ?? ''}/${req.securableFullName ?? ''}`; const body = marshalRequest(req, marshalUpdateWorkspaceBindingsSchema); let resp: UpdateWorkspaceBindings_Response | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); - resp = parseResponse( - respBody, - unmarshalUpdateWorkspaceBindings_ResponseSchema - ); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); + resp = parseResponse(respBody, unmarshalUpdateWorkspaceBindings_ResponseSchema); }; await execute(signal, call, options); if (resp === undefined) { diff --git a/packages/workspacebindings/src/v1/index.ts b/packages/workspacebindings/src/v1/index.ts index 2a8da3f4..192fa6fb 100644 --- a/packages/workspacebindings/src/v1/index.ts +++ b/packages/workspacebindings/src/v1/index.ts @@ -1,8 +1,11 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {BindingType} from './model'; +export { + BindingType, +} from './model'; export type { GetCatalogWorkspaceBindings, diff --git a/packages/workspacebindings/src/v1/model.ts b/packages/workspacebindings/src/v1/model.ts index eb88c91f..732b97af 100644 --- a/packages/workspacebindings/src/v1/model.ts +++ b/packages/workspacebindings/src/v1/model.ts @@ -92,118 +92,101 @@ export interface WorkspaceBindingInfo { bindingType?: BindingType | undefined; } -export const unmarshalGetCatalogWorkspaceBindingsSchema: z.ZodType = - z - .object({ - catalog_name: z.string().optional(), - }) - .transform(d => ({ - catalogName: d.catalog_name, - })); +export const unmarshalGetCatalogWorkspaceBindingsSchema: z.ZodType = z + .object({ + catalog_name: z.string().optional(), + }) + .transform(d => ({ + catalogName: d.catalog_name, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetCatalogWorkspaceBindings_ResponseSchema: z.ZodType = - z - .object({ - workspaces: z.array(z.number()).optional(), - }) - .transform(d => ({ - workspaces: d.workspaces, - })); +export const unmarshalGetCatalogWorkspaceBindings_ResponseSchema: z.ZodType = z + .object({ + workspaces: z.array(z.number()).optional(), + }) + .transform(d => ({ + workspaces: d.workspaces, + })); -export const unmarshalGetWorkspaceBindingsSchema: z.ZodType = - z - .object({ - securable_type: z.string().optional(), - securable_full_name: z.string().optional(), - max_results: z.number().optional(), - page_token: z.string().optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - securableFullName: d.securable_full_name, - maxResults: d.max_results, - pageToken: d.page_token, - })); +export const unmarshalGetWorkspaceBindingsSchema: z.ZodType = z + .object({ + securable_type: z.string().optional(), + securable_full_name: z.string().optional(), + max_results: z.number().optional(), + page_token: z.string().optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + securableFullName: d.securable_full_name, + maxResults: d.max_results, + pageToken: d.page_token, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalGetWorkspaceBindings_ResponseSchema: z.ZodType = - z - .object({ - bindings: z - .array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)) - .optional(), - next_page_token: z.string().optional(), - }) - .transform(d => ({ - bindings: d.bindings, - nextPageToken: d.next_page_token, - })); +export const unmarshalGetWorkspaceBindings_ResponseSchema: z.ZodType = z + .object({ + bindings: z.array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)).optional(), + next_page_token: z.string().optional(), + }) + .transform(d => ({ + bindings: d.bindings, + nextPageToken: d.next_page_token, + })); -export const unmarshalUpdateCatalogWorkspaceBindingsSchema: z.ZodType = - z - .object({ - catalog_name: z.string().optional(), - assign_workspaces: z.array(z.number()).optional(), - unassign_workspaces: z.array(z.number()).optional(), - }) - .transform(d => ({ - catalogName: d.catalog_name, - assignWorkspaces: d.assign_workspaces, - unassignWorkspaces: d.unassign_workspaces, - })); +export const unmarshalUpdateCatalogWorkspaceBindingsSchema: z.ZodType = z + .object({ + catalog_name: z.string().optional(), + assign_workspaces: z.array(z.number()).optional(), + unassign_workspaces: z.array(z.number()).optional(), + }) + .transform(d => ({ + catalogName: d.catalog_name, + assignWorkspaces: d.assign_workspaces, + unassignWorkspaces: d.unassign_workspaces, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateCatalogWorkspaceBindings_ResponseSchema: z.ZodType = - z - .object({ - workspaces: z.array(z.number()).optional(), - }) - .transform(d => ({ - workspaces: d.workspaces, - })); +export const unmarshalUpdateCatalogWorkspaceBindings_ResponseSchema: z.ZodType = z + .object({ + workspaces: z.array(z.number()).optional(), + }) + .transform(d => ({ + workspaces: d.workspaces, + })); -export const unmarshalUpdateWorkspaceBindingsSchema: z.ZodType = - z - .object({ - securable_type: z.string().optional(), - securable_full_name: z.string().optional(), - add: z - .array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)) - .optional(), - remove: z - .array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)) - .optional(), - }) - .transform(d => ({ - securableType: d.securable_type, - securableFullName: d.securable_full_name, - add: d.add, - remove: d.remove, - })); +export const unmarshalUpdateWorkspaceBindingsSchema: z.ZodType = z + .object({ + securable_type: z.string().optional(), + securable_full_name: z.string().optional(), + add: z.array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)).optional(), + remove: z.array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)).optional(), + }) + .transform(d => ({ + securableType: d.securable_type, + securableFullName: d.securable_full_name, + add: d.add, + remove: d.remove, + })); // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. -export const unmarshalUpdateWorkspaceBindings_ResponseSchema: z.ZodType = - z - .object({ - bindings: z - .array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)) - .optional(), - }) - .transform(d => ({ - bindings: d.bindings, - })); +export const unmarshalUpdateWorkspaceBindings_ResponseSchema: z.ZodType = z + .object({ + bindings: z.array(z.lazy(() => unmarshalWorkspaceBindingInfoSchema)).optional(), + }) + .transform(d => ({ + bindings: d.bindings, + })); -export const unmarshalWorkspaceBindingInfoSchema: z.ZodType = - z - .object({ - workspace_id: z.number().optional(), - binding_type: z.enum(BindingType).optional(), - }) - .transform(d => ({ - workspaceId: d.workspace_id, - bindingType: d.binding_type, - })); +export const unmarshalWorkspaceBindingInfoSchema: z.ZodType = z + .object({ + workspace_id: z.number().optional(), + binding_type: z.enum(BindingType).optional(), + }) + .transform(d => ({ + workspaceId: d.workspace_id, + bindingType: d.binding_type, + })); export const marshalGetCatalogWorkspaceBindingsSchema: z.ZodType = z .object({ @@ -239,9 +222,7 @@ export const marshalGetWorkspaceBindingsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalGetWorkspaceBindings_ResponseSchema: z.ZodType = z .object({ - bindings: z - .array(z.lazy(() => marshalWorkspaceBindingInfoSchema)) - .optional(), + bindings: z.array(z.lazy(() => marshalWorkspaceBindingInfoSchema)).optional(), nextPageToken: z.string().optional(), }) .transform(d => ({ @@ -287,9 +268,7 @@ export const marshalUpdateWorkspaceBindingsSchema: z.ZodType = z // eslint-disable-next-line @typescript-eslint/naming-convention -- Proto-style nested message name. export const marshalUpdateWorkspaceBindings_ResponseSchema: z.ZodType = z .object({ - bindings: z - .array(z.lazy(() => marshalWorkspaceBindingInfoSchema)) - .optional(), + bindings: z.array(z.lazy(() => marshalWorkspaceBindingInfoSchema)).optional(), }) .transform(d => ({ bindings: d.bindings, diff --git a/packages/workspacebindings/src/v1/utils.ts b/packages/workspacebindings/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/workspacebindings/src/v1/utils.ts +++ b/packages/workspacebindings/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/workspacebindings/tsconfig.json b/packages/workspacebindings/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/workspacebindings/tsconfig.json +++ b/packages/workspacebindings/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] } diff --git a/packages/workspaceconf/package.json b/packages/workspaceconf/package.json index 7935d8f0..bc9c04f6 100644 --- a/packages/workspaceconf/package.json +++ b/packages/workspaceconf/package.json @@ -27,6 +27,7 @@ "author": "Databricks", "license": "Apache-2.0", "dependencies": { + "@databricks/sdk-core": "*", "@databricks/sdk-databricks": "*", "@js-temporal/polyfill": "^0.5.0", "zod": "^4.3.6" diff --git a/packages/workspaceconf/src/v1/client.ts b/packages/workspaceconf/src/v1/client.ts index 9c6336ca..e129aa4d 100644 --- a/packages/workspaceconf/src/v1/client.ts +++ b/packages/workspaceconf/src/v1/client.ts @@ -7,13 +7,11 @@ import {NoOpLogger} from '@databricks/sdk-databricks/logger'; import type {ClientOptions} from '@databricks/sdk-databricks/options'; import type {HttpClient} from '@databricks/sdk-databricks/transport'; import {newHttpClient} from '@databricks/sdk-databricks/transport'; -import { - buildHttpRequest, - executeHttpCall, - marshalRequest, - parseResponse, -} from './utils'; -import type {GetWorkspaceConfRequest, WorkspaceConf} from './model'; +import {buildHttpRequest, executeHttpCall, marshalRequest, parseResponse} from './utils'; +import type { + GetWorkspaceConfRequest, + WorkspaceConf, +} from './model'; import { marshalWorkspaceConfSchema, unmarshalWorkspaceConfSchema, @@ -34,11 +32,7 @@ export class Client { } /** Gets the configuration status for a workspace. */ - async getWorkspaceConf( - signal: AbortSignal | undefined, - req: GetWorkspaceConfRequest, - options?: Options - ): Promise { + async getWorkspaceConf(signal: AbortSignal | undefined, req: GetWorkspaceConfRequest, options?: Options): Promise { const url = `${this.host}/api/2.0/workspace-conf`; const params = new URLSearchParams(); if (req.keys !== undefined) { @@ -49,11 +43,7 @@ export class Client { let resp: WorkspaceConf | undefined; const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('GET', fullUrl, callSignal); - const respBody = await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + const respBody = await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); resp = parseResponse(respBody, unmarshalWorkspaceConfSchema); }; await execute(signal, call, options); @@ -64,20 +54,12 @@ export class Client { } /** Sets the configuration status for a workspace, including enabling or disabling it. */ - async updateWorkspaceConf( - signal: AbortSignal | undefined, - req: WorkspaceConf, - options?: Options - ): Promise { + async updateWorkspaceConf(signal: AbortSignal | undefined, req: WorkspaceConf, options?: Options): Promise { const url = `${this.host}/api/2.0/workspace-conf`; const body = marshalRequest(req, marshalWorkspaceConfSchema); const call: Call = async (callSignal?: AbortSignal): Promise => { const httpReq = buildHttpRequest('PATCH', url, callSignal, body); - await executeHttpCall({ - request: httpReq, - httpClient: this.httpClient, - logger: this.logger, - }); + await executeHttpCall({request: httpReq, httpClient: this.httpClient, logger: this.logger}); }; await execute(signal, call, options); } diff --git a/packages/workspaceconf/src/v1/index.ts b/packages/workspaceconf/src/v1/index.ts index 873ef874..28abe323 100644 --- a/packages/workspaceconf/src/v1/index.ts +++ b/packages/workspaceconf/src/v1/index.ts @@ -1,7 +1,12 @@ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT. + export {Client} from './client'; -export {} from './model'; +export { +} from './model'; -export type {GetWorkspaceConfRequest, WorkspaceConf} from './model'; +export type { + GetWorkspaceConfRequest, + WorkspaceConf, +} from './model'; diff --git a/packages/workspaceconf/src/v1/model.ts b/packages/workspaceconf/src/v1/model.ts index 79717f91..9cd5cda8 100644 --- a/packages/workspaceconf/src/v1/model.ts +++ b/packages/workspaceconf/src/v1/model.ts @@ -11,14 +11,13 @@ export interface WorkspaceConf { value?: string | undefined; } -export const unmarshalGetWorkspaceConfRequestSchema: z.ZodType = - z - .object({ - keys: z.string().optional(), - }) - .transform(d => ({ - keys: d.keys, - })); +export const unmarshalGetWorkspaceConfRequestSchema: z.ZodType = z + .object({ + keys: z.string().optional(), + }) + .transform(d => ({ + keys: d.keys, + })); export const unmarshalWorkspaceConfSchema: z.ZodType = z .object({ diff --git a/packages/workspaceconf/src/v1/utils.ts b/packages/workspaceconf/src/v1/utils.ts index 6a711598..8aa7a525 100644 --- a/packages/workspaceconf/src/v1/utils.ts +++ b/packages/workspaceconf/src/v1/utils.ts @@ -16,7 +16,7 @@ export interface HttpCallOptions { } async function readAll( - body: ReadableStream | null + body: ReadableStream | null, ): Promise { if (body === null) { return new Uint8Array(0); @@ -41,7 +41,7 @@ async function readAll( } export async function executeHttpCall( - opts: HttpCallOptions + opts: HttpCallOptions, ): Promise { opts.logger.debug('HTTP request', { method: opts.request.method, @@ -75,7 +75,7 @@ export function buildHttpRequest( method: string, url: string, signal?: AbortSignal, - body?: string + body?: string, ): HttpRequest { const headers = new Headers(); headers.set('Content-Type', 'application/json'); diff --git a/packages/workspaceconf/tsconfig.json b/packages/workspaceconf/tsconfig.json index 19cf553a..8214ba8c 100644 --- a/packages/workspaceconf/tsconfig.json +++ b/packages/workspaceconf/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src"], "exclude": ["dist", "node_modules", "tests"], - "references": [{"path": "../databricks"}] + "references": [{"path": "../core"}, {"path": "../databricks"}] }