@databricks/sdk-queries 0.1.0-dev.3 → 0.1.0-dev.4

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/src/v1/client.ts DELETED
@@ -1,297 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
- import {createDefault} from '@databricks/sdk-core/clientinfo';
5
- import type {Logger} from '@databricks/sdk-core/logger';
6
- import {NoOpLogger} from '@databricks/sdk-core/logger';
7
- import type {CallOptions} from '@databricks/sdk-options/call';
8
- import type {ClientOptions} from '@databricks/sdk-options/client';
9
- import type {HttpClient} from '@databricks/sdk-core/http';
10
- import {newHttpClient} from './transport';
11
- import {
12
- buildHttpRequest,
13
- executeCall,
14
- executeHttpCall,
15
- marshalRequest,
16
- parseResponse,
17
- } from './utils';
18
- import pkgJson from '../../package.json' with {type: 'json'};
19
- import type {
20
- CreateQueryRequest,
21
- Empty,
22
- GetQueryRequest,
23
- ListQueriesRequest,
24
- ListQueriesResponse,
25
- ListQueryObjectsResponseQuery,
26
- ListVisualizationsForQueryRequest,
27
- ListVisualizationsForQueryResponse,
28
- Query,
29
- TrashQueryRequest,
30
- UpdateQueryRequest,
31
- Visualization,
32
- } from './model';
33
- import {
34
- marshalCreateQueryRequestSchema,
35
- marshalUpdateQueryRequestSchema,
36
- unmarshalEmptySchema,
37
- unmarshalListQueriesResponseSchema,
38
- unmarshalListVisualizationsForQueryResponseSchema,
39
- unmarshalQuerySchema,
40
- } from './model';
41
-
42
- // Package identity segment for this client to be used in the User-Agent header.
43
- const PACKAGE_SEGMENT = {
44
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
45
- value: pkgJson.version,
46
- };
47
-
48
- export class QueriesClient {
49
- private readonly host: string;
50
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
51
- // When set, workspace-level methods send X-Databricks-Org-Id on every
52
- // request.
53
- private readonly workspaceId: string | undefined;
54
- private readonly httpClient: HttpClient;
55
- private readonly logger: Logger;
56
- // User-Agent header value. Composed once at construction from
57
- // createDefault() merged with this package's identity and the active
58
- // credential's name.
59
- private readonly userAgent: string;
60
-
61
- constructor(options: ClientOptions) {
62
- if (options.host === undefined) {
63
- throw new Error('Host is required.');
64
- }
65
- this.host = options.host.replace(/\/$/, '');
66
- this.workspaceId = options.workspaceId;
67
- this.logger = options.logger ?? new NoOpLogger();
68
- const info = createDefault()
69
- .with(PACKAGE_SEGMENT)
70
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
71
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
72
- this.userAgent = info.toString();
73
- this.httpClient = newHttpClient(options);
74
- }
75
-
76
- /** Creates a query. */
77
- async createQuery(
78
- req: CreateQueryRequest,
79
- options?: CallOptions
80
- ): Promise<Query> {
81
- const url = `${this.host}/api/2.0/sql/queries`;
82
- const body = marshalRequest(req, marshalCreateQueryRequestSchema);
83
- let resp: Query | undefined;
84
- const call = async (callSignal?: AbortSignal): Promise<void> => {
85
- const headers = new Headers({'Content-Type': 'application/json'});
86
- if (this.workspaceId !== undefined) {
87
- headers.set('X-Databricks-Org-Id', this.workspaceId);
88
- }
89
- headers.set('User-Agent', this.userAgent);
90
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
91
- const respBody = await executeHttpCall({
92
- request: httpReq,
93
- httpClient: this.httpClient,
94
- logger: this.logger,
95
- });
96
- resp = parseResponse(respBody, unmarshalQuerySchema);
97
- };
98
- await executeCall(call, options);
99
- if (resp === undefined) {
100
- throw new Error('operation completed without a result.');
101
- }
102
- return resp;
103
- }
104
-
105
- /** Gets a query. */
106
- async getQuery(req: GetQueryRequest, options?: CallOptions): Promise<Query> {
107
- const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}`;
108
- let resp: Query | undefined;
109
- const call = async (callSignal?: AbortSignal): Promise<void> => {
110
- const headers = new Headers();
111
- if (this.workspaceId !== undefined) {
112
- headers.set('X-Databricks-Org-Id', this.workspaceId);
113
- }
114
- headers.set('User-Agent', this.userAgent);
115
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
116
- const respBody = await executeHttpCall({
117
- request: httpReq,
118
- httpClient: this.httpClient,
119
- logger: this.logger,
120
- });
121
- resp = parseResponse(respBody, unmarshalQuerySchema);
122
- };
123
- await executeCall(call, options);
124
- if (resp === undefined) {
125
- throw new Error('operation completed without a result.');
126
- }
127
- return resp;
128
- }
129
-
130
- /** 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. */
131
- async listQueries(
132
- req: ListQueriesRequest,
133
- options?: CallOptions
134
- ): Promise<ListQueriesResponse> {
135
- const url = `${this.host}/api/2.0/sql/queries`;
136
- const params = new URLSearchParams();
137
- if (req.pageToken !== undefined) {
138
- params.append('page_token', req.pageToken);
139
- }
140
- if (req.pageSize !== undefined) {
141
- params.append('page_size', String(req.pageSize));
142
- }
143
- const query = params.toString();
144
- const fullUrl = query !== '' ? `${url}?${query}` : url;
145
- let resp: ListQueriesResponse | undefined;
146
- const call = async (callSignal?: AbortSignal): Promise<void> => {
147
- const headers = new Headers();
148
- if (this.workspaceId !== undefined) {
149
- headers.set('X-Databricks-Org-Id', this.workspaceId);
150
- }
151
- headers.set('User-Agent', this.userAgent);
152
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
153
- const respBody = await executeHttpCall({
154
- request: httpReq,
155
- httpClient: this.httpClient,
156
- logger: this.logger,
157
- });
158
- resp = parseResponse(respBody, unmarshalListQueriesResponseSchema);
159
- };
160
- await executeCall(call, options);
161
- if (resp === undefined) {
162
- throw new Error('operation completed without a result.');
163
- }
164
- return resp;
165
- }
166
-
167
- async *listQueriesIter(
168
- req: ListQueriesRequest,
169
- options?: CallOptions
170
- ): AsyncGenerator<ListQueryObjectsResponseQuery> {
171
- const pageReq: ListQueriesRequest = {...req};
172
- for (;;) {
173
- const resp = await this.listQueries(pageReq, options);
174
- for (const item of resp.results ?? []) {
175
- yield item;
176
- }
177
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
178
- return;
179
- }
180
- pageReq.pageToken = resp.nextPageToken;
181
- }
182
- }
183
-
184
- /** Gets a list of visualizations on a query. */
185
- async listVisualizationsForQuery(
186
- req: ListVisualizationsForQueryRequest,
187
- options?: CallOptions
188
- ): Promise<ListVisualizationsForQueryResponse> {
189
- const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}/visualizations`;
190
- const params = new URLSearchParams();
191
- if (req.pageToken !== undefined) {
192
- params.append('page_token', req.pageToken);
193
- }
194
- if (req.pageSize !== undefined) {
195
- params.append('page_size', String(req.pageSize));
196
- }
197
- const query = params.toString();
198
- const fullUrl = query !== '' ? `${url}?${query}` : url;
199
- let resp: ListVisualizationsForQueryResponse | undefined;
200
- const call = async (callSignal?: AbortSignal): Promise<void> => {
201
- const headers = new Headers();
202
- if (this.workspaceId !== undefined) {
203
- headers.set('X-Databricks-Org-Id', this.workspaceId);
204
- }
205
- headers.set('User-Agent', this.userAgent);
206
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
207
- const respBody = await executeHttpCall({
208
- request: httpReq,
209
- httpClient: this.httpClient,
210
- logger: this.logger,
211
- });
212
- resp = parseResponse(
213
- respBody,
214
- unmarshalListVisualizationsForQueryResponseSchema
215
- );
216
- };
217
- await executeCall(call, options);
218
- if (resp === undefined) {
219
- throw new Error('operation completed without a result.');
220
- }
221
- return resp;
222
- }
223
-
224
- async *listVisualizationsForQueryIter(
225
- req: ListVisualizationsForQueryRequest,
226
- options?: CallOptions
227
- ): AsyncGenerator<Visualization> {
228
- const pageReq: ListVisualizationsForQueryRequest = {...req};
229
- for (;;) {
230
- const resp = await this.listVisualizationsForQuery(pageReq, options);
231
- for (const item of resp.results ?? []) {
232
- yield item;
233
- }
234
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
235
- return;
236
- }
237
- pageReq.pageToken = resp.nextPageToken;
238
- }
239
- }
240
-
241
- /** 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. */
242
- async trashQuery(
243
- req: TrashQueryRequest,
244
- options?: CallOptions
245
- ): Promise<Empty> {
246
- const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}`;
247
- let resp: Empty | undefined;
248
- const call = async (callSignal?: AbortSignal): Promise<void> => {
249
- const headers = new Headers();
250
- if (this.workspaceId !== undefined) {
251
- headers.set('X-Databricks-Org-Id', this.workspaceId);
252
- }
253
- headers.set('User-Agent', this.userAgent);
254
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
255
- const respBody = await executeHttpCall({
256
- request: httpReq,
257
- httpClient: this.httpClient,
258
- logger: this.logger,
259
- });
260
- resp = parseResponse(respBody, unmarshalEmptySchema);
261
- };
262
- await executeCall(call, options);
263
- if (resp === undefined) {
264
- throw new Error('operation completed without a result.');
265
- }
266
- return resp;
267
- }
268
-
269
- /** Updates a query. */
270
- async updateQuery(
271
- req: UpdateQueryRequest,
272
- options?: CallOptions
273
- ): Promise<Query> {
274
- const url = `${this.host}/api/2.0/sql/queries/${req.id ?? ''}`;
275
- const body = marshalRequest(req, marshalUpdateQueryRequestSchema);
276
- let resp: Query | undefined;
277
- const call = async (callSignal?: AbortSignal): Promise<void> => {
278
- const headers = new Headers({'Content-Type': 'application/json'});
279
- if (this.workspaceId !== undefined) {
280
- headers.set('X-Databricks-Org-Id', this.workspaceId);
281
- }
282
- headers.set('User-Agent', this.userAgent);
283
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
284
- const respBody = await executeHttpCall({
285
- request: httpReq,
286
- httpClient: this.httpClient,
287
- logger: this.logger,
288
- });
289
- resp = parseResponse(respBody, unmarshalQuerySchema);
290
- };
291
- await executeCall(call, options);
292
- if (resp === undefined) {
293
- throw new Error('operation completed without a result.');
294
- }
295
- return resp;
296
- }
297
- }
package/src/v1/index.ts DELETED
@@ -1,39 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- export {QueriesClient} from './client';
4
-
5
- export {
6
- DatePrecision,
7
- LifecycleState,
8
- RunAsMode,
9
- DateRangeValue_DynamicDateRange,
10
- DateValue_DynamicDate,
11
- } from './model';
12
-
13
- export type {
14
- CreateQueryRequest,
15
- CreateQueryRequestQuery,
16
- DateRange,
17
- DateRangeValue,
18
- DateValue,
19
- Empty,
20
- EnumValue,
21
- GetQueryRequest,
22
- ListQueriesRequest,
23
- ListQueriesResponse,
24
- ListQueryObjectsResponseQuery,
25
- ListVisualizationsForQueryRequest,
26
- ListVisualizationsForQueryResponse,
27
- MultiValuesOptions,
28
- NumericValue,
29
- Query,
30
- QueryBackedValue,
31
- QueryParameter,
32
- TextValue,
33
- TrashQueryRequest,
34
- UpdateQueryRequest,
35
- UpdateQueryRequestQuery,
36
- Visualization,
37
- } from './model';
38
-
39
- export {updateQueryRequestQueryFieldMask} from './model';