@databricks/sdk-settings 0.34.0 → 0.36.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.
package/dist/v2/client.js CHANGED
@@ -1,349 +1,282 @@
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 { marshalSettingSchema, marshalUserPreferenceSchema, unmarshalListAccountSettingsMetadataResponseSchema, unmarshalListAccountUserPreferencesMetadataResponseSchema, unmarshalListWorkspaceSettingsMetadataResponseSchema, unmarshalSettingSchema, unmarshalUserPreferenceSchema, } 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 { marshalSettingSchema, marshalUserPreferenceSchema, unmarshalListAccountSettingsMetadataResponseSchema, unmarshalListAccountUserPreferencesMetadataResponseSchema, unmarshalListWorkspaceSettingsMetadataResponseSchema, unmarshalSettingSchema, unmarshalUserPreferenceSchema } 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/v2/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 SettingsClient {
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
- /** Get a setting value at account level. See :method:settingsv2/listaccountsettingsmetadata for list of setting available via public APIs at account level. */
39
- async getPublicAccountSetting(req, options) {
40
- const { host, accountId, httpClient } = await this.resolveConfig();
41
- const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ''}/settings/${req.name ?? ''}`;
42
- let resp;
43
- const call = async (callSignal) => {
44
- const headers = new Headers();
45
- headers.set('User-Agent', this.userAgent);
46
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
47
- const respBody = await executeHttpCall({
48
- request: httpReq,
49
- httpClient,
50
- logger: this.logger,
51
- });
52
- resp = parseResponse(respBody, unmarshalSettingSchema);
53
- };
54
- await executeCall(call, options);
55
- if (resp === undefined) {
56
- throw new Error('operation completed without a result.');
57
- }
58
- return resp;
59
- }
60
- /**
61
- * Get a user preference for a specific user.
62
- * User preferences are personal settings that allow individual customization without affecting other users.
63
- * See :method:settingsv2/listaccountuserpreferencesmetadata for list of user preferences available via public APIs.
64
- */
65
- async getPublicAccountUserPreference(req, options) {
66
- const { host, accountId, httpClient } = await this.resolveConfig();
67
- const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ''}/users/${req.userId ?? ''}/settings/${req.name ?? ''}`;
68
- let resp;
69
- const call = async (callSignal) => {
70
- const headers = new Headers();
71
- headers.set('User-Agent', this.userAgent);
72
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
73
- const respBody = await executeHttpCall({
74
- request: httpReq,
75
- httpClient,
76
- logger: this.logger,
77
- });
78
- resp = parseResponse(respBody, unmarshalUserPreferenceSchema);
79
- };
80
- await executeCall(call, options);
81
- if (resp === undefined) {
82
- throw new Error('operation completed without a result.');
83
- }
84
- return resp;
85
- }
86
- /** Get a setting value at workspace level. See :method:settingsv2/listworkspacesettingsmetadata for list of setting available via public APIs. */
87
- async getPublicWorkspaceSetting(req, options) {
88
- const { host, workspaceId, httpClient } = await this.resolveConfig();
89
- const url = `${host}/api/2.1/settings/${req.name ?? ''}`;
90
- let resp;
91
- const call = async (callSignal) => {
92
- const headers = new Headers();
93
- if (workspaceId !== undefined) {
94
- headers.set('X-Databricks-Workspace-Id', workspaceId);
95
- }
96
- headers.set('User-Agent', this.userAgent);
97
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
98
- const respBody = await executeHttpCall({
99
- request: httpReq,
100
- httpClient,
101
- logger: this.logger,
102
- });
103
- resp = parseResponse(respBody, unmarshalSettingSchema);
104
- };
105
- await executeCall(call, options);
106
- if (resp === undefined) {
107
- throw new Error('operation completed without a result.');
108
- }
109
- return resp;
110
- }
111
- /**
112
- * List valid setting keys and metadata. These settings are available to be referenced via
113
- * GET :method:settingsv2/getpublicaccountsetting and
114
- * PATCH :method:settingsv2/patchpublicaccountsetting APIs
115
- */
116
- async listAccountSettingsMetadata(req, options) {
117
- const { host, accountId, httpClient } = await this.resolveConfig();
118
- const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ''}/settings-metadata`;
119
- const params = new URLSearchParams();
120
- if (req.pageSize !== undefined) {
121
- params.append('page_size', String(req.pageSize));
122
- }
123
- if (req.pageToken !== undefined) {
124
- params.append('page_token', req.pageToken);
125
- }
126
- const query = params.toString();
127
- const fullUrl = query !== '' ? `${url}?${query}` : url;
128
- let resp;
129
- const call = async (callSignal) => {
130
- const headers = new Headers();
131
- headers.set('User-Agent', this.userAgent);
132
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
133
- const respBody = await executeHttpCall({
134
- request: httpReq,
135
- httpClient,
136
- logger: this.logger,
137
- });
138
- resp = parseResponse(respBody, unmarshalListAccountSettingsMetadataResponseSchema);
139
- };
140
- await executeCall(call, options);
141
- if (resp === undefined) {
142
- throw new Error('operation completed without a result.');
143
- }
144
- return resp;
145
- }
146
- async *listAccountSettingsMetadataIter(req, options) {
147
- const pageReq = { ...req };
148
- for (;;) {
149
- const resp = await this.listAccountSettingsMetadata(pageReq, options);
150
- for (const item of resp.settingsMetadata ?? []) {
151
- yield item;
152
- }
153
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
154
- return;
155
- }
156
- pageReq.pageToken = resp.nextPageToken;
157
- }
158
- }
159
- /**
160
- * List valid user preferences and their metadata for a specific user.
161
- * User preferences are personal settings that allow individual customization without affecting other users.
162
- * These settings are available to be referenced via
163
- * GET :method:settingsv2/getpublicaccountuserpreference and
164
- * PATCH :method:settingsv2/patchpublicaccountuserpreference APIs
165
- */
166
- async listAccountUserPreferencesMetadata(req, options) {
167
- const { host, accountId, httpClient } = await this.resolveConfig();
168
- const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ''}/users/${req.userId ?? ''}/settings-metadata`;
169
- const params = new URLSearchParams();
170
- if (req.pageSize !== undefined) {
171
- params.append('page_size', String(req.pageSize));
172
- }
173
- if (req.pageToken !== undefined) {
174
- params.append('page_token', req.pageToken);
175
- }
176
- const query = params.toString();
177
- const fullUrl = query !== '' ? `${url}?${query}` : url;
178
- let resp;
179
- const call = async (callSignal) => {
180
- const headers = new Headers();
181
- headers.set('User-Agent', this.userAgent);
182
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
183
- const respBody = await executeHttpCall({
184
- request: httpReq,
185
- httpClient,
186
- logger: this.logger,
187
- });
188
- resp = parseResponse(respBody, unmarshalListAccountUserPreferencesMetadataResponseSchema);
189
- };
190
- await executeCall(call, options);
191
- if (resp === undefined) {
192
- throw new Error('operation completed without a result.');
193
- }
194
- return resp;
195
- }
196
- async *listAccountUserPreferencesMetadataIter(req, options) {
197
- const pageReq = { ...req };
198
- for (;;) {
199
- const resp = await this.listAccountUserPreferencesMetadata(pageReq, options);
200
- for (const item of resp.settingsMetadata ?? []) {
201
- yield item;
202
- }
203
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
204
- return;
205
- }
206
- pageReq.pageToken = resp.nextPageToken;
207
- }
208
- }
209
- /**
210
- * List valid setting keys and metadata. These settings are available to be referenced via
211
- * GET :method:settingsv2/getpublicworkspacesetting and
212
- * PATCH :method:settingsv2/patchpublicworkspacesetting APIs
213
- */
214
- async listWorkspaceSettingsMetadata(req, options) {
215
- const { host, workspaceId, httpClient } = await this.resolveConfig();
216
- const url = `${host}/api/2.1/settings-metadata`;
217
- const params = new URLSearchParams();
218
- if (req.pageSize !== undefined) {
219
- params.append('page_size', String(req.pageSize));
220
- }
221
- if (req.pageToken !== undefined) {
222
- params.append('page_token', req.pageToken);
223
- }
224
- const query = params.toString();
225
- const fullUrl = query !== '' ? `${url}?${query}` : url;
226
- let resp;
227
- const call = async (callSignal) => {
228
- const headers = new Headers();
229
- if (workspaceId !== undefined) {
230
- headers.set('X-Databricks-Workspace-Id', workspaceId);
231
- }
232
- headers.set('User-Agent', this.userAgent);
233
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
234
- const respBody = await executeHttpCall({
235
- request: httpReq,
236
- httpClient,
237
- logger: this.logger,
238
- });
239
- resp = parseResponse(respBody, unmarshalListWorkspaceSettingsMetadataResponseSchema);
240
- };
241
- await executeCall(call, options);
242
- if (resp === undefined) {
243
- throw new Error('operation completed without a result.');
244
- }
245
- return resp;
246
- }
247
- async *listWorkspaceSettingsMetadataIter(req, options) {
248
- const pageReq = { ...req };
249
- for (;;) {
250
- const resp = await this.listWorkspaceSettingsMetadata(pageReq, options);
251
- for (const item of resp.settingsMetadata ?? []) {
252
- yield item;
253
- }
254
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
255
- return;
256
- }
257
- pageReq.pageToken = resp.nextPageToken;
258
- }
259
- }
260
- /**
261
- * Patch a setting value at account level. See :method:settingsv2/listaccountsettingsmetadata for list of setting available via public APIs at account level.
262
- * 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.
263
- *
264
- * Note: Page refresh is required for changes to take effect in UI.
265
- */
266
- async patchPublicAccountSetting(req, options) {
267
- const { host, accountId, httpClient } = await this.resolveConfig();
268
- const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ''}/settings/${req.name ?? ''}`;
269
- const body = marshalRequest(req.setting, marshalSettingSchema);
270
- let resp;
271
- const call = async (callSignal) => {
272
- const headers = new Headers({ 'Content-Type': 'application/json' });
273
- headers.set('User-Agent', this.userAgent);
274
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
275
- const respBody = await executeHttpCall({
276
- request: httpReq,
277
- httpClient,
278
- logger: this.logger,
279
- });
280
- resp = parseResponse(respBody, unmarshalSettingSchema);
281
- };
282
- await executeCall(call, options);
283
- if (resp === undefined) {
284
- throw new Error('operation completed without a result.');
285
- }
286
- return resp;
287
- }
288
- /**
289
- * Update a user preference for a specific user.
290
- * User preferences are personal settings that allow individual customization without affecting other users.
291
- * See :method:settingsv2/listaccountuserpreferencesmetadata for list of user preferences available via public APIs.
292
- *
293
- * Note: Page refresh is required for changes to take effect in UI.
294
- */
295
- async patchPublicAccountUserPreference(req, options) {
296
- const { host, accountId, httpClient } = await this.resolveConfig();
297
- const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ''}/users/${req.userId ?? ''}/settings/${req.name ?? ''}`;
298
- const body = marshalRequest(req.setting, marshalUserPreferenceSchema);
299
- let resp;
300
- const call = async (callSignal) => {
301
- const headers = new Headers({ 'Content-Type': 'application/json' });
302
- headers.set('User-Agent', this.userAgent);
303
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
304
- const respBody = await executeHttpCall({
305
- request: httpReq,
306
- httpClient,
307
- logger: this.logger,
308
- });
309
- resp = parseResponse(respBody, unmarshalUserPreferenceSchema);
310
- };
311
- await executeCall(call, options);
312
- if (resp === undefined) {
313
- throw new Error('operation completed without a result.');
314
- }
315
- return resp;
316
- }
317
- /**
318
- * Patch a setting value at workspace level. See :method:settingsv2/listworkspacesettingsmetadata for list of setting available via public APIs at workspace level.
319
- * 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.
320
- *
321
- * Note: Page refresh is required for changes to take effect in UI.
322
- */
323
- async patchPublicWorkspaceSetting(req, options) {
324
- const { host, workspaceId, httpClient } = await this.resolveConfig();
325
- const url = `${host}/api/2.1/settings/${req.name ?? ''}`;
326
- const body = marshalRequest(req.setting, marshalSettingSchema);
327
- let resp;
328
- const call = async (callSignal) => {
329
- const headers = new Headers({ 'Content-Type': 'application/json' });
330
- if (workspaceId !== undefined) {
331
- headers.set('X-Databricks-Workspace-Id', workspaceId);
332
- }
333
- headers.set('User-Agent', this.userAgent);
334
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
335
- const respBody = await executeHttpCall({
336
- request: httpReq,
337
- httpClient,
338
- logger: this.logger,
339
- });
340
- resp = parseResponse(respBody, unmarshalSettingSchema);
341
- };
342
- await executeCall(call, options);
343
- if (resp === undefined) {
344
- throw new Error('operation completed without a result.');
345
- }
346
- return resp;
347
- }
348
- }
14
+ var SettingsClient = 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
+ /** Get a setting value at account level. See :method:settingsv2/listaccountsettingsmetadata for list of setting available via public APIs at account level. */
35
+ async getPublicAccountSetting(req, options) {
36
+ const { host, accountId, httpClient } = await this.resolveConfig();
37
+ const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ""}/settings/${req.name ?? ""}`;
38
+ let resp;
39
+ const call = async (callSignal) => {
40
+ const headers = new Headers();
41
+ headers.set("User-Agent", this.userAgent);
42
+ resp = parseResponse(await executeHttpCall({
43
+ request: buildHttpRequest("GET", url, headers, callSignal),
44
+ httpClient,
45
+ logger: this.logger
46
+ }), unmarshalSettingSchema);
47
+ };
48
+ await executeCall(call, options);
49
+ if (resp === void 0) throw new Error("operation completed without a result.");
50
+ return resp;
51
+ }
52
+ /**
53
+ * Get a user preference for a specific user.
54
+ * User preferences are personal settings that allow individual customization without affecting other users.
55
+ * See :method:settingsv2/listaccountuserpreferencesmetadata for list of user preferences available via public APIs.
56
+ */
57
+ async getPublicAccountUserPreference(req, options) {
58
+ const { host, accountId, httpClient } = await this.resolveConfig();
59
+ const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ""}/users/${req.userId ?? ""}/settings/${req.name ?? ""}`;
60
+ let resp;
61
+ const call = async (callSignal) => {
62
+ const headers = new Headers();
63
+ headers.set("User-Agent", this.userAgent);
64
+ resp = parseResponse(await executeHttpCall({
65
+ request: buildHttpRequest("GET", url, headers, callSignal),
66
+ httpClient,
67
+ logger: this.logger
68
+ }), unmarshalUserPreferenceSchema);
69
+ };
70
+ await executeCall(call, options);
71
+ if (resp === void 0) throw new Error("operation completed without a result.");
72
+ return resp;
73
+ }
74
+ /** Get a setting value at workspace level. See :method:settingsv2/listworkspacesettingsmetadata for list of setting available via public APIs. */
75
+ async getPublicWorkspaceSetting(req, options) {
76
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
77
+ const url = `${host}/api/2.1/settings/${req.name ?? ""}`;
78
+ let resp;
79
+ const call = async (callSignal) => {
80
+ const headers = new Headers();
81
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
82
+ headers.set("User-Agent", this.userAgent);
83
+ resp = parseResponse(await executeHttpCall({
84
+ request: buildHttpRequest("GET", url, headers, callSignal),
85
+ httpClient,
86
+ logger: this.logger
87
+ }), unmarshalSettingSchema);
88
+ };
89
+ await executeCall(call, options);
90
+ if (resp === void 0) throw new Error("operation completed without a result.");
91
+ return resp;
92
+ }
93
+ /**
94
+ * List valid setting keys and metadata. These settings are available to be referenced via
95
+ * GET :method:settingsv2/getpublicaccountsetting and
96
+ * PATCH :method:settingsv2/patchpublicaccountsetting APIs
97
+ */
98
+ async listAccountSettingsMetadata(req, options) {
99
+ const { host, accountId, httpClient } = await this.resolveConfig();
100
+ const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ""}/settings-metadata`;
101
+ const params = new URLSearchParams();
102
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
103
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
104
+ const query = params.toString();
105
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
106
+ let resp;
107
+ const call = async (callSignal) => {
108
+ const headers = new Headers();
109
+ headers.set("User-Agent", this.userAgent);
110
+ resp = parseResponse(await executeHttpCall({
111
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
112
+ httpClient,
113
+ logger: this.logger
114
+ }), unmarshalListAccountSettingsMetadataResponseSchema);
115
+ };
116
+ await executeCall(call, options);
117
+ if (resp === void 0) throw new Error("operation completed without a result.");
118
+ return resp;
119
+ }
120
+ async *listAccountSettingsMetadataIter(req, options) {
121
+ const pageReq = { ...req };
122
+ for (;;) {
123
+ const resp = await this.listAccountSettingsMetadata(pageReq, options);
124
+ for (const item of resp.settingsMetadata ?? []) yield item;
125
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
126
+ pageReq.pageToken = resp.nextPageToken;
127
+ }
128
+ }
129
+ /**
130
+ * List valid user preferences and their metadata for a specific user.
131
+ * User preferences are personal settings that allow individual customization without affecting other users.
132
+ * These settings are available to be referenced via
133
+ * GET :method:settingsv2/getpublicaccountuserpreference and
134
+ * PATCH :method:settingsv2/patchpublicaccountuserpreference APIs
135
+ */
136
+ async listAccountUserPreferencesMetadata(req, options) {
137
+ const { host, accountId, httpClient } = await this.resolveConfig();
138
+ const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ""}/users/${req.userId ?? ""}/settings-metadata`;
139
+ const params = new URLSearchParams();
140
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
141
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
142
+ const query = params.toString();
143
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
144
+ let resp;
145
+ const call = async (callSignal) => {
146
+ const headers = new Headers();
147
+ headers.set("User-Agent", this.userAgent);
148
+ resp = parseResponse(await executeHttpCall({
149
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
150
+ httpClient,
151
+ logger: this.logger
152
+ }), unmarshalListAccountUserPreferencesMetadataResponseSchema);
153
+ };
154
+ await executeCall(call, options);
155
+ if (resp === void 0) throw new Error("operation completed without a result.");
156
+ return resp;
157
+ }
158
+ async *listAccountUserPreferencesMetadataIter(req, options) {
159
+ const pageReq = { ...req };
160
+ for (;;) {
161
+ const resp = await this.listAccountUserPreferencesMetadata(pageReq, options);
162
+ for (const item of resp.settingsMetadata ?? []) yield item;
163
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
164
+ pageReq.pageToken = resp.nextPageToken;
165
+ }
166
+ }
167
+ /**
168
+ * List valid setting keys and metadata. These settings are available to be referenced via
169
+ * GET :method:settingsv2/getpublicworkspacesetting and
170
+ * PATCH :method:settingsv2/patchpublicworkspacesetting APIs
171
+ */
172
+ async listWorkspaceSettingsMetadata(req, options) {
173
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
174
+ const url = `${host}/api/2.1/settings-metadata`;
175
+ const params = new URLSearchParams();
176
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
177
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
178
+ const query = params.toString();
179
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
180
+ let resp;
181
+ const call = async (callSignal) => {
182
+ const headers = new Headers();
183
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
184
+ headers.set("User-Agent", this.userAgent);
185
+ resp = parseResponse(await executeHttpCall({
186
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
187
+ httpClient,
188
+ logger: this.logger
189
+ }), unmarshalListWorkspaceSettingsMetadataResponseSchema);
190
+ };
191
+ await executeCall(call, options);
192
+ if (resp === void 0) throw new Error("operation completed without a result.");
193
+ return resp;
194
+ }
195
+ async *listWorkspaceSettingsMetadataIter(req, options) {
196
+ const pageReq = { ...req };
197
+ for (;;) {
198
+ const resp = await this.listWorkspaceSettingsMetadata(pageReq, options);
199
+ for (const item of resp.settingsMetadata ?? []) yield item;
200
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
201
+ pageReq.pageToken = resp.nextPageToken;
202
+ }
203
+ }
204
+ /**
205
+ * Patch a setting value at account level. See :method:settingsv2/listaccountsettingsmetadata for list of setting available via public APIs at account level.
206
+ * 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.
207
+ *
208
+ * Note: Page refresh is required for changes to take effect in UI.
209
+ */
210
+ async patchPublicAccountSetting(req, options) {
211
+ const { host, accountId, httpClient } = await this.resolveConfig();
212
+ const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ""}/settings/${req.name ?? ""}`;
213
+ const body = marshalRequest(req.setting, marshalSettingSchema);
214
+ let resp;
215
+ const call = async (callSignal) => {
216
+ const headers = new Headers({ "Content-Type": "application/json" });
217
+ headers.set("User-Agent", this.userAgent);
218
+ resp = parseResponse(await executeHttpCall({
219
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
220
+ httpClient,
221
+ logger: this.logger
222
+ }), unmarshalSettingSchema);
223
+ };
224
+ await executeCall(call, options);
225
+ if (resp === void 0) throw new Error("operation completed without a result.");
226
+ return resp;
227
+ }
228
+ /**
229
+ * Update a user preference for a specific user.
230
+ * User preferences are personal settings that allow individual customization without affecting other users.
231
+ * See :method:settingsv2/listaccountuserpreferencesmetadata for list of user preferences available via public APIs.
232
+ *
233
+ * Note: Page refresh is required for changes to take effect in UI.
234
+ */
235
+ async patchPublicAccountUserPreference(req, options) {
236
+ const { host, accountId, httpClient } = await this.resolveConfig();
237
+ const url = `${host}/api/2.1/accounts/${req.accountId ?? accountId ?? ""}/users/${req.userId ?? ""}/settings/${req.name ?? ""}`;
238
+ const body = marshalRequest(req.setting, marshalUserPreferenceSchema);
239
+ let resp;
240
+ const call = async (callSignal) => {
241
+ const headers = new Headers({ "Content-Type": "application/json" });
242
+ headers.set("User-Agent", this.userAgent);
243
+ resp = parseResponse(await executeHttpCall({
244
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
245
+ httpClient,
246
+ logger: this.logger
247
+ }), unmarshalUserPreferenceSchema);
248
+ };
249
+ await executeCall(call, options);
250
+ if (resp === void 0) throw new Error("operation completed without a result.");
251
+ return resp;
252
+ }
253
+ /**
254
+ * Patch a setting value at workspace level. See :method:settingsv2/listworkspacesettingsmetadata for list of setting available via public APIs at workspace level.
255
+ * 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.
256
+ *
257
+ * Note: Page refresh is required for changes to take effect in UI.
258
+ */
259
+ async patchPublicWorkspaceSetting(req, options) {
260
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
261
+ const url = `${host}/api/2.1/settings/${req.name ?? ""}`;
262
+ const body = marshalRequest(req.setting, marshalSettingSchema);
263
+ let resp;
264
+ const call = async (callSignal) => {
265
+ const headers = new Headers({ "Content-Type": "application/json" });
266
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
267
+ headers.set("User-Agent", this.userAgent);
268
+ resp = parseResponse(await executeHttpCall({
269
+ request: buildHttpRequest("PATCH", url, headers, callSignal, body),
270
+ httpClient,
271
+ logger: this.logger
272
+ }), unmarshalSettingSchema);
273
+ };
274
+ await executeCall(call, options);
275
+ if (resp === void 0) throw new Error("operation completed without a result.");
276
+ return resp;
277
+ }
278
+ };
279
+
280
+ //#endregion
281
+ export { SettingsClient };
349
282
  //# sourceMappingURL=client.js.map