@databricks/sdk-uc-secrets 0.27.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ //#region package.json
2
+ var name = "@databricks/sdk-uc-secrets";
3
+ var version = "0.35.0";
4
+
5
+ //#endregion
6
+ export { name, version };
7
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,60 +1,64 @@
1
- import type { CallOptions } from '@databricks/sdk-options/call';
2
- import type { ClientOptions } from '@databricks/sdk-options/client';
3
- import type { CreateSecretRequest, DeleteSecretRequest, GetSecretRequest, ListSecretsRequest, ListSecretsResponse, Secret, UpdateSecretRequest } from './model';
4
- export declare class SecretsClient {
5
- private readonly options;
6
- private readonly logger;
7
- private readonly userAgent;
8
- private config;
9
- constructor(options: ClientOptions);
10
- private resolveConfig;
11
- /**
12
- * Creates a new secret in Unity Catalog.
13
- *
14
- * You must be the owner of the parent schema or have the **CREATE_SECRET** and **USE SCHEMA**
15
- * privileges on the parent schema and **USE CATALOG** on the parent catalog.
16
- *
17
- * The secret is stored in the specified catalog and schema, and the **value** field
18
- * contains the sensitive data to be securely stored.
19
- */
20
- createSecret(req: CreateSecretRequest, options?: CallOptions): Promise<Secret>;
21
- /**
22
- * Deletes a secret by its three-level (fully qualified) name.
23
- *
24
- * You must be the owner of the secret or a metastore admin.
25
- */
26
- deleteSecret(req: DeleteSecretRequest, options?: CallOptions): Promise<void>;
27
- /**
28
- * Gets a secret by its three-level (fully qualified) name.
29
- *
30
- * You must be a metastore admin, the owner of the secret, or have the **MANAGE**
31
- * privilege on the secret.
32
- *
33
- * The secret value isn't returned by default. To retrieve it, you must also have the
34
- * **READ_SECRET** privilege and set **include_value** to true in the request.
35
- */
36
- getSecret(req: GetSecretRequest, options?: CallOptions): Promise<Secret>;
37
- /**
38
- * Lists secrets in Unity Catalog.
39
- *
40
- * You must be a metastore admin, the owner of the secret, or have the
41
- * **MANAGE** privilege on the secret.
42
- *
43
- * Both **catalog_name** and **schema_name** must be specified together to filter secrets within
44
- * a specific schema. Results are paginated; use the **page_token** field from the response
45
- * to retrieve subsequent pages.
46
- */
47
- listSecrets(req: ListSecretsRequest, options?: CallOptions): Promise<ListSecretsResponse>;
48
- listSecretsIter(req: ListSecretsRequest, options?: CallOptions): AsyncGenerator<Secret>;
49
- /**
50
- * Updates an existing secret in Unity Catalog.
51
- *
52
- * You must be the owner of the secret or a metastore admin. If you are a metastore
53
- * admin, only the **owner** field can be changed.
54
- *
55
- * Use the **update_mask** field to specify which fields to update. Supported updatable fields
56
- * include **value**, **comment**, **owner**, and **expire_time**.
57
- */
58
- updateSecret(req: UpdateSecretRequest, options?: CallOptions): Promise<Secret>;
1
+ import { CreateSecretRequest, DeleteSecretRequest, GetSecretRequest, ListSecretsRequest, ListSecretsResponse, Secret, UpdateSecretRequest } from "./model.js";
2
+ import { CallOptions } from "@databricks/sdk-options/call";
3
+ import { ClientOptions } from "@databricks/sdk-options/client";
4
+
5
+ //#region src/v1/client.d.ts
6
+ declare class SecretsClient {
7
+ private readonly options;
8
+ private readonly logger;
9
+ private readonly userAgent;
10
+ private config;
11
+ constructor(options: ClientOptions);
12
+ private resolveConfig;
13
+ /**
14
+ * Creates a new secret in Unity Catalog.
15
+ *
16
+ * You must be the owner of the parent schema or have the **CREATE_SECRET** and **USE SCHEMA**
17
+ * privileges on the parent schema and **USE CATALOG** on the parent catalog.
18
+ *
19
+ * The secret is stored in the specified catalog and schema, and the **value** field
20
+ * contains the sensitive data to be securely stored.
21
+ */
22
+ createSecret(req: CreateSecretRequest, options?: CallOptions): Promise<Secret>;
23
+ /**
24
+ * Deletes a secret by its three-level (fully qualified) name.
25
+ *
26
+ * You must be the owner of the secret or a metastore admin.
27
+ */
28
+ deleteSecret(req: DeleteSecretRequest, options?: CallOptions): Promise<void>;
29
+ /**
30
+ * Gets a secret by its three-level (fully qualified) name.
31
+ *
32
+ * You must be a metastore admin, the owner of the secret, or have the **MANAGE**
33
+ * privilege on the secret.
34
+ *
35
+ * The secret value isn't returned by default. To retrieve it, you must also have the
36
+ * **READ_SECRET** privilege and set **include_value** to true in the request.
37
+ */
38
+ getSecret(req: GetSecretRequest, options?: CallOptions): Promise<Secret>;
39
+ /**
40
+ * Lists secrets in Unity Catalog.
41
+ *
42
+ * You must be a metastore admin, the owner of the secret, or have the
43
+ * **MANAGE** privilege on the secret.
44
+ *
45
+ * Both **catalog_name** and **schema_name** must be specified together to filter secrets within
46
+ * a specific schema. Results are paginated; use the **page_token** field from the response
47
+ * to retrieve subsequent pages.
48
+ */
49
+ listSecrets(req: ListSecretsRequest, options?: CallOptions): Promise<ListSecretsResponse>;
50
+ listSecretsIter(req: ListSecretsRequest, options?: CallOptions): AsyncGenerator<Secret>;
51
+ /**
52
+ * Updates an existing secret in Unity Catalog.
53
+ *
54
+ * You must be the owner of the secret or a metastore admin. If you are a metastore
55
+ * admin, only the **owner** field can be changed.
56
+ *
57
+ * Use the **update_mask** field to specify which fields to update. Supported updatable fields
58
+ * include **value**, **comment**, **owner**, and **expire_time**.
59
+ */
60
+ updateSecret(req: UpdateSecretRequest, options?: CallOptions): Promise<Secret>;
59
61
  }
62
+ //#endregion
63
+ export { SecretsClient };
60
64
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAWlE,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,EACN,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAajB,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAIhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAInC,OAAO,CAAC,MAAM,CAA4C;gBAE9C,OAAO,EAAE,aAAa;IAUlC,OAAO,CAAC,aAAa;IAKrB;;;;;;;;OAQG;IACG,YAAY,CAChB,GAAG,EAAE,mBAAmB,EACxB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC;IA0BlB;;;;OAIG;IACG,YAAY,CAChB,GAAG,EAAE,mBAAmB,EACxB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;;;;;OAQG;IACG,SAAS,CACb,GAAG,EAAE,gBAAgB,EACrB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC;IAyBlB;;;;;;;;;OASG;IACG,WAAW,CACf,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAwCxB,eAAe,CACpB,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,MAAM,CAAC;IAczB;;;;;;;;OAQG;IACG,YAAY,CAChB,GAAG,EAAE,mBAAmB,EACxB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC;CAqCnB"}
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/v1/client.ts"],"mappings":";;;;;cAuCa,aAAA;EAAA,iBACM,OAAA;EAAA,iBACA,MAAA;EAAA,iBAIA,SAAA;EAAA,QAIT,MAAA;cAEI,OAAA,EAAS,aAAA;EAAA,QAUb,aAAA;EAgBI;;;;;;;;;EAFN,YAAA,CACJ,GAAA,EAAK,mBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,MAAA;EA2GJ;;;;;EA5ED,YAAA,CACJ,GAAA,EAAK,mBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA;EAsHe;;;;;;;;;EA1FZ,SAAA,CACJ,GAAA,EAAK,gBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,MAAA;EAlGM;;;;;;;;;;EA2IX,WAAA,CACJ,GAAA,EAAK,kBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,mBAAA;EAwCJ,eAAA,CACL,GAAA,EAAK,kBAAA,EACL,OAAA,GAAU,WAAA,GACT,cAAA,CAAe,MAAA;EAxJP;;;;;;;;;EA+KL,YAAA,CACJ,GAAA,EAAK,mBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,MAAA;AAAA"}
package/dist/v1/client.js CHANGED
@@ -1,231 +1,193 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
- import { VERSION as AUTH_VERSION } from '@databricks/sdk-auth';
3
- import { createDefault } from '@databricks/sdk-core/clientinfo';
4
- import { NoOpLogger } from '@databricks/sdk-core/logger';
5
- import { resolveClientConfig } from './transport';
6
- import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse, } from './utils';
7
- import pkgJson from '../../package.json' with { type: 'json' };
8
- import { marshalSecretSchema, unmarshalListSecretsResponseSchema, unmarshalSecretSchema, } from './model';
9
- // Package identity segment for this client to be used in the User-Agent header.
1
+ import { resolveClientConfig } from "./transport.js";
2
+ import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
3
+ import { name, version } from "../package.js";
4
+ import { marshalSecretSchema, unmarshalListSecretsResponseSchema, unmarshalSecretSchema } from "./model.js";
5
+ import { VERSION } from "@databricks/sdk-auth";
6
+ import { createDefault } from "@databricks/sdk-core/clientinfo";
7
+ import { NoOpLogger } from "@databricks/sdk-core/logger";
8
+
9
+ //#region src/v1/client.ts
10
10
  const PACKAGE_SEGMENT = {
11
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
12
- value: pkgJson.version,
11
+ key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
12
+ value: version
13
13
  };
14
- export class SecretsClient {
15
- options;
16
- logger;
17
- // User-Agent header value. Composed once at construction from
18
- // createDefault() merged with this package's identity and the active
19
- // credential's name.
20
- userAgent;
21
- // Memoized configuration. The profile is resolved once, lazily, on the first
22
- // request, then reused; host, workspaceId/accountId, and credentials are
23
- // filled from it when not set explicitly on the options.
24
- config;
25
- constructor(options) {
26
- this.options = options;
27
- this.logger = options.logger ?? new NoOpLogger();
28
- const info = createDefault()
29
- .with(PACKAGE_SEGMENT)
30
- .with({ key: 'sdk-js-auth', value: AUTH_VERSION })
31
- .with({ key: 'auth', value: options.credentials?.name() ?? 'default' });
32
- this.userAgent = info.toString();
33
- }
34
- resolveConfig() {
35
- this.config ??= resolveClientConfig(this.options);
36
- return this.config;
37
- }
38
- /**
39
- * Creates a new secret in Unity Catalog.
40
- *
41
- * You must be the owner of the parent schema or have the **CREATE_SECRET** and **USE SCHEMA**
42
- * privileges on the parent schema and **USE CATALOG** on the parent catalog.
43
- *
44
- * The secret is stored in the specified catalog and schema, and the **value** field
45
- * contains the sensitive data to be securely stored.
46
- */
47
- async createSecret(req, options) {
48
- const { host, workspaceId, httpClient } = await this.resolveConfig();
49
- const url = `${host}/api/2.1/unity-catalog/secrets`;
50
- const body = marshalRequest(req.secret, marshalSecretSchema);
51
- let resp;
52
- const call = async (callSignal) => {
53
- const headers = new Headers({ 'Content-Type': 'application/json' });
54
- if (workspaceId !== undefined) {
55
- headers.set('X-Databricks-Workspace-Id', workspaceId);
56
- }
57
- headers.set('User-Agent', this.userAgent);
58
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
59
- const respBody = await executeHttpCall({
60
- request: httpReq,
61
- httpClient,
62
- logger: this.logger,
63
- });
64
- resp = parseResponse(respBody, unmarshalSecretSchema);
65
- };
66
- await executeCall(call, options);
67
- if (resp === undefined) {
68
- throw new Error('operation completed without a result.');
69
- }
70
- return resp;
71
- }
72
- /**
73
- * Deletes a secret by its three-level (fully qualified) name.
74
- *
75
- * You must be the owner of the secret or a metastore admin.
76
- */
77
- async deleteSecret(req, options) {
78
- const { host, workspaceId, httpClient } = await this.resolveConfig();
79
- const url = `${host}/api/2.1/unity-catalog/secrets/${req.fullName ?? ''}`;
80
- const call = async (callSignal) => {
81
- const headers = new Headers();
82
- if (workspaceId !== undefined) {
83
- headers.set('X-Databricks-Workspace-Id', workspaceId);
84
- }
85
- headers.set('User-Agent', this.userAgent);
86
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
87
- await executeHttpCall({
88
- request: httpReq,
89
- httpClient,
90
- logger: this.logger,
91
- });
92
- };
93
- await executeCall(call, options);
94
- }
95
- /**
96
- * Gets a secret by its three-level (fully qualified) name.
97
- *
98
- * You must be a metastore admin, the owner of the secret, or have the **MANAGE**
99
- * privilege on the secret.
100
- *
101
- * The secret value isn't returned by default. To retrieve it, you must also have the
102
- * **READ_SECRET** privilege and set **include_value** to true in the request.
103
- */
104
- async getSecret(req, options) {
105
- const { host, workspaceId, httpClient } = await this.resolveConfig();
106
- const url = `${host}/api/2.1/unity-catalog/secrets/${req.fullName ?? ''}`;
107
- let resp;
108
- const call = async (callSignal) => {
109
- const headers = new Headers();
110
- if (workspaceId !== undefined) {
111
- headers.set('X-Databricks-Workspace-Id', workspaceId);
112
- }
113
- headers.set('User-Agent', this.userAgent);
114
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
115
- const respBody = await executeHttpCall({
116
- request: httpReq,
117
- httpClient,
118
- logger: this.logger,
119
- });
120
- resp = parseResponse(respBody, unmarshalSecretSchema);
121
- };
122
- await executeCall(call, options);
123
- if (resp === undefined) {
124
- throw new Error('operation completed without a result.');
125
- }
126
- return resp;
127
- }
128
- /**
129
- * Lists secrets in Unity Catalog.
130
- *
131
- * You must be a metastore admin, the owner of the secret, or have the
132
- * **MANAGE** privilege on the secret.
133
- *
134
- * Both **catalog_name** and **schema_name** must be specified together to filter secrets within
135
- * a specific schema. Results are paginated; use the **page_token** field from the response
136
- * to retrieve subsequent pages.
137
- */
138
- async listSecrets(req, options) {
139
- const { host, workspaceId, httpClient } = await this.resolveConfig();
140
- const url = `${host}/api/2.1/unity-catalog/secrets`;
141
- const params = new URLSearchParams();
142
- if (req.catalogName !== undefined) {
143
- params.append('catalog_name', req.catalogName);
144
- }
145
- if (req.schemaName !== undefined) {
146
- params.append('schema_name', req.schemaName);
147
- }
148
- if (req.pageToken !== undefined) {
149
- params.append('page_token', req.pageToken);
150
- }
151
- if (req.pageSize !== undefined) {
152
- params.append('page_size', String(req.pageSize));
153
- }
154
- const query = params.toString();
155
- const fullUrl = query !== '' ? `${url}?${query}` : url;
156
- let resp;
157
- const call = async (callSignal) => {
158
- const headers = new Headers();
159
- if (workspaceId !== undefined) {
160
- headers.set('X-Databricks-Workspace-Id', workspaceId);
161
- }
162
- headers.set('User-Agent', this.userAgent);
163
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
164
- const respBody = await executeHttpCall({
165
- request: httpReq,
166
- httpClient,
167
- logger: this.logger,
168
- });
169
- resp = parseResponse(respBody, unmarshalListSecretsResponseSchema);
170
- };
171
- await executeCall(call, options);
172
- if (resp === undefined) {
173
- throw new Error('operation completed without a result.');
174
- }
175
- return resp;
176
- }
177
- async *listSecretsIter(req, options) {
178
- const pageReq = { ...req };
179
- for (;;) {
180
- const resp = await this.listSecrets(pageReq, options);
181
- for (const item of resp.secrets ?? []) {
182
- yield item;
183
- }
184
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
185
- return;
186
- }
187
- pageReq.pageToken = resp.nextPageToken;
188
- }
189
- }
190
- /**
191
- * Updates an existing secret in Unity Catalog.
192
- *
193
- * You must be the owner of the secret or a metastore admin. If you are a metastore
194
- * admin, only the **owner** field can be changed.
195
- *
196
- * Use the **update_mask** field to specify which fields to update. Supported updatable fields
197
- * include **value**, **comment**, **owner**, and **expire_time**.
198
- */
199
- async updateSecret(req, options) {
200
- const { host, workspaceId, httpClient } = await this.resolveConfig();
201
- const url = `${host}/api/2.1/unity-catalog/secrets/${req.fullName ?? ''}`;
202
- const params = new URLSearchParams();
203
- if (req.updateMask !== undefined) {
204
- params.append('update_mask', req.updateMask.toString());
205
- }
206
- const query = params.toString();
207
- const fullUrl = query !== '' ? `${url}?${query}` : url;
208
- const body = marshalRequest(req.secret, marshalSecretSchema);
209
- let resp;
210
- const call = async (callSignal) => {
211
- const headers = new Headers({ 'Content-Type': 'application/json' });
212
- if (workspaceId !== undefined) {
213
- headers.set('X-Databricks-Workspace-Id', workspaceId);
214
- }
215
- headers.set('User-Agent', this.userAgent);
216
- const httpReq = buildHttpRequest('PATCH', fullUrl, headers, callSignal, body);
217
- const respBody = await executeHttpCall({
218
- request: httpReq,
219
- httpClient,
220
- logger: this.logger,
221
- });
222
- resp = parseResponse(respBody, unmarshalSecretSchema);
223
- };
224
- await executeCall(call, options);
225
- if (resp === undefined) {
226
- throw new Error('operation completed without a result.');
227
- }
228
- return resp;
229
- }
230
- }
14
+ var SecretsClient = class {
15
+ options;
16
+ logger;
17
+ userAgent;
18
+ config;
19
+ constructor(options) {
20
+ this.options = options;
21
+ this.logger = options.logger ?? new NoOpLogger();
22
+ this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
23
+ key: "sdk-js-auth",
24
+ value: VERSION
25
+ }).with({
26
+ key: "auth",
27
+ value: options.credentials?.name() ?? "default"
28
+ }).toString();
29
+ }
30
+ resolveConfig() {
31
+ this.config ??= resolveClientConfig(this.options);
32
+ return this.config;
33
+ }
34
+ /**
35
+ * Creates a new secret in Unity Catalog.
36
+ *
37
+ * You must be the owner of the parent schema or have the **CREATE_SECRET** and **USE SCHEMA**
38
+ * privileges on the parent schema and **USE CATALOG** on the parent catalog.
39
+ *
40
+ * The secret is stored in the specified catalog and schema, and the **value** field
41
+ * contains the sensitive data to be securely stored.
42
+ */
43
+ async createSecret(req, options) {
44
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
45
+ const url = `${host}/api/2.1/unity-catalog/secrets`;
46
+ const body = marshalRequest(req.secret, marshalSecretSchema);
47
+ let resp;
48
+ const call = async (callSignal) => {
49
+ const headers = new Headers({ "Content-Type": "application/json" });
50
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
51
+ headers.set("User-Agent", this.userAgent);
52
+ resp = parseResponse(await executeHttpCall({
53
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
54
+ httpClient,
55
+ logger: this.logger
56
+ }), unmarshalSecretSchema);
57
+ };
58
+ await executeCall(call, options);
59
+ if (resp === void 0) throw new Error("operation completed without a result.");
60
+ return resp;
61
+ }
62
+ /**
63
+ * Deletes a secret by its three-level (fully qualified) name.
64
+ *
65
+ * You must be the owner of the secret or a metastore admin.
66
+ */
67
+ async deleteSecret(req, options) {
68
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
69
+ const url = `${host}/api/2.1/unity-catalog/secrets/${req.fullName ?? ""}`;
70
+ const call = async (callSignal) => {
71
+ const headers = new Headers();
72
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
73
+ headers.set("User-Agent", this.userAgent);
74
+ await executeHttpCall({
75
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
76
+ httpClient,
77
+ logger: this.logger
78
+ });
79
+ };
80
+ await executeCall(call, options);
81
+ }
82
+ /**
83
+ * Gets a secret by its three-level (fully qualified) name.
84
+ *
85
+ * You must be a metastore admin, the owner of the secret, or have the **MANAGE**
86
+ * privilege on the secret.
87
+ *
88
+ * The secret value isn't returned by default. To retrieve it, you must also have the
89
+ * **READ_SECRET** privilege and set **include_value** to true in the request.
90
+ */
91
+ async getSecret(req, options) {
92
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
93
+ const url = `${host}/api/2.1/unity-catalog/secrets/${req.fullName ?? ""}`;
94
+ const params = new URLSearchParams();
95
+ if (req.includeValue !== void 0) params.append("include_value", String(req.includeValue));
96
+ const query = params.toString();
97
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
98
+ let resp;
99
+ const call = async (callSignal) => {
100
+ const headers = new Headers();
101
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
102
+ headers.set("User-Agent", this.userAgent);
103
+ resp = parseResponse(await executeHttpCall({
104
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
105
+ httpClient,
106
+ logger: this.logger
107
+ }), unmarshalSecretSchema);
108
+ };
109
+ await executeCall(call, options);
110
+ if (resp === void 0) throw new Error("operation completed without a result.");
111
+ return resp;
112
+ }
113
+ /**
114
+ * Lists secrets in Unity Catalog.
115
+ *
116
+ * You must be a metastore admin, the owner of the secret, or have the
117
+ * **MANAGE** privilege on the secret.
118
+ *
119
+ * Both **catalog_name** and **schema_name** must be specified together to filter secrets within
120
+ * a specific schema. Results are paginated; use the **page_token** field from the response
121
+ * to retrieve subsequent pages.
122
+ */
123
+ async listSecrets(req, options) {
124
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
125
+ const url = `${host}/api/2.1/unity-catalog/secrets`;
126
+ const params = new URLSearchParams();
127
+ if (req.catalogName !== void 0) params.append("catalog_name", req.catalogName);
128
+ if (req.schemaName !== void 0) params.append("schema_name", req.schemaName);
129
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
130
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
131
+ const query = params.toString();
132
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
133
+ let resp;
134
+ const call = async (callSignal) => {
135
+ const headers = new Headers();
136
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
137
+ headers.set("User-Agent", this.userAgent);
138
+ resp = parseResponse(await executeHttpCall({
139
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
140
+ httpClient,
141
+ logger: this.logger
142
+ }), unmarshalListSecretsResponseSchema);
143
+ };
144
+ await executeCall(call, options);
145
+ if (resp === void 0) throw new Error("operation completed without a result.");
146
+ return resp;
147
+ }
148
+ async *listSecretsIter(req, options) {
149
+ const pageReq = { ...req };
150
+ for (;;) {
151
+ const resp = await this.listSecrets(pageReq, options);
152
+ for (const item of resp.secrets ?? []) yield item;
153
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
154
+ pageReq.pageToken = resp.nextPageToken;
155
+ }
156
+ }
157
+ /**
158
+ * Updates an existing secret in Unity Catalog.
159
+ *
160
+ * You must be the owner of the secret or a metastore admin. If you are a metastore
161
+ * admin, only the **owner** field can be changed.
162
+ *
163
+ * Use the **update_mask** field to specify which fields to update. Supported updatable fields
164
+ * include **value**, **comment**, **owner**, and **expire_time**.
165
+ */
166
+ async updateSecret(req, options) {
167
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
168
+ const url = `${host}/api/2.1/unity-catalog/secrets/${req.fullName ?? ""}`;
169
+ const params = new URLSearchParams();
170
+ if (req.updateMask !== void 0) params.append("update_mask", req.updateMask.toString());
171
+ const query = params.toString();
172
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
173
+ const body = marshalRequest(req.secret, marshalSecretSchema);
174
+ let resp;
175
+ const call = async (callSignal) => {
176
+ const headers = new Headers({ "Content-Type": "application/json" });
177
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
178
+ headers.set("User-Agent", this.userAgent);
179
+ resp = parseResponse(await executeHttpCall({
180
+ request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
181
+ httpClient,
182
+ logger: this.logger
183
+ }), unmarshalSecretSchema);
184
+ };
185
+ await executeCall(call, options);
186
+ if (resp === void 0) throw new Error("operation completed without a result.");
187
+ return resp;
188
+ }
189
+ };
190
+
191
+ //#endregion
192
+ export { SecretsClient };
231
193
  //# sourceMappingURL=client.js.map