@databricks/sdk-alerts 0.1.0-dev.3 → 0.1.0-dev.5

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,236 +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
- Alert,
21
- CreateAlertRequest,
22
- Empty,
23
- GetAlertRequest,
24
- ListAlertsRequest,
25
- ListAlertsResponse,
26
- ListAlertsResponseAlert,
27
- TrashAlertRequest,
28
- UpdateAlertRequest,
29
- } from './model';
30
- import {
31
- marshalCreateAlertRequestSchema,
32
- marshalUpdateAlertRequestSchema,
33
- unmarshalAlertSchema,
34
- unmarshalEmptySchema,
35
- unmarshalListAlertsResponseSchema,
36
- } from './model';
37
-
38
- // Package identity segment for this client to be used in the User-Agent header.
39
- const PACKAGE_SEGMENT = {
40
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
41
- value: pkgJson.version,
42
- };
43
-
44
- export class AlertsClient {
45
- private readonly host: string;
46
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
47
- // When set, workspace-level methods send X-Databricks-Org-Id on every
48
- // request.
49
- private readonly workspaceId: string | undefined;
50
- private readonly httpClient: HttpClient;
51
- private readonly logger: Logger;
52
- // User-Agent header value. Composed once at construction from
53
- // createDefault() merged with this package's identity and the active
54
- // credential's name.
55
- private readonly userAgent: string;
56
-
57
- constructor(options: ClientOptions) {
58
- if (options.host === undefined) {
59
- throw new Error('Host is required.');
60
- }
61
- this.host = options.host.replace(/\/$/, '');
62
- this.workspaceId = options.workspaceId;
63
- this.logger = options.logger ?? new NoOpLogger();
64
- const info = createDefault()
65
- .with(PACKAGE_SEGMENT)
66
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
67
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
68
- this.userAgent = info.toString();
69
- this.httpClient = newHttpClient(options);
70
- }
71
-
72
- /** Creates an alert. */
73
- async createAlert(
74
- req: CreateAlertRequest,
75
- options?: CallOptions
76
- ): Promise<Alert> {
77
- const url = `${this.host}/api/2.0/sql/alerts`;
78
- const body = marshalRequest(req, marshalCreateAlertRequestSchema);
79
- let resp: Alert | undefined;
80
- const call = async (callSignal?: AbortSignal): Promise<void> => {
81
- const headers = new Headers({'Content-Type': 'application/json'});
82
- if (this.workspaceId !== undefined) {
83
- headers.set('X-Databricks-Org-Id', this.workspaceId);
84
- }
85
- headers.set('User-Agent', this.userAgent);
86
- const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
87
- const respBody = await executeHttpCall({
88
- request: httpReq,
89
- httpClient: this.httpClient,
90
- logger: this.logger,
91
- });
92
- resp = parseResponse(respBody, unmarshalAlertSchema);
93
- };
94
- await executeCall(call, options);
95
- if (resp === undefined) {
96
- throw new Error('operation completed without a result.');
97
- }
98
- return resp;
99
- }
100
-
101
- /** Gets an alert. */
102
- async getAlert(req: GetAlertRequest, options?: CallOptions): Promise<Alert> {
103
- const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`;
104
- let resp: Alert | undefined;
105
- const call = async (callSignal?: AbortSignal): Promise<void> => {
106
- const headers = new Headers();
107
- if (this.workspaceId !== undefined) {
108
- headers.set('X-Databricks-Org-Id', this.workspaceId);
109
- }
110
- headers.set('User-Agent', this.userAgent);
111
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
112
- const respBody = await executeHttpCall({
113
- request: httpReq,
114
- httpClient: this.httpClient,
115
- logger: this.logger,
116
- });
117
- resp = parseResponse(respBody, unmarshalAlertSchema);
118
- };
119
- await executeCall(call, options);
120
- if (resp === undefined) {
121
- throw new Error('operation completed without a result.');
122
- }
123
- return resp;
124
- }
125
-
126
- /** 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. */
127
- async listAlerts(
128
- req: ListAlertsRequest,
129
- options?: CallOptions
130
- ): Promise<ListAlertsResponse> {
131
- const url = `${this.host}/api/2.0/sql/alerts`;
132
- const params = new URLSearchParams();
133
- if (req.pageToken !== undefined) {
134
- params.append('page_token', req.pageToken);
135
- }
136
- if (req.pageSize !== undefined) {
137
- params.append('page_size', String(req.pageSize));
138
- }
139
- const query = params.toString();
140
- const fullUrl = query !== '' ? `${url}?${query}` : url;
141
- let resp: ListAlertsResponse | undefined;
142
- const call = async (callSignal?: AbortSignal): Promise<void> => {
143
- const headers = new Headers();
144
- if (this.workspaceId !== undefined) {
145
- headers.set('X-Databricks-Org-Id', this.workspaceId);
146
- }
147
- headers.set('User-Agent', this.userAgent);
148
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
149
- const respBody = await executeHttpCall({
150
- request: httpReq,
151
- httpClient: this.httpClient,
152
- logger: this.logger,
153
- });
154
- resp = parseResponse(respBody, unmarshalListAlertsResponseSchema);
155
- };
156
- await executeCall(call, options);
157
- if (resp === undefined) {
158
- throw new Error('operation completed without a result.');
159
- }
160
- return resp;
161
- }
162
-
163
- async *listAlertsIter(
164
- req: ListAlertsRequest,
165
- options?: CallOptions
166
- ): AsyncGenerator<ListAlertsResponseAlert> {
167
- const pageReq: ListAlertsRequest = {...req};
168
- for (;;) {
169
- const resp = await this.listAlerts(pageReq, options);
170
- for (const item of resp.results ?? []) {
171
- yield item;
172
- }
173
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
174
- return;
175
- }
176
- pageReq.pageToken = resp.nextPageToken;
177
- }
178
- }
179
-
180
- /** 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. */
181
- async trashAlert(
182
- req: TrashAlertRequest,
183
- options?: CallOptions
184
- ): Promise<Empty> {
185
- const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`;
186
- let resp: Empty | undefined;
187
- const call = async (callSignal?: AbortSignal): Promise<void> => {
188
- const headers = new Headers();
189
- if (this.workspaceId !== undefined) {
190
- headers.set('X-Databricks-Org-Id', this.workspaceId);
191
- }
192
- headers.set('User-Agent', this.userAgent);
193
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
194
- const respBody = await executeHttpCall({
195
- request: httpReq,
196
- httpClient: this.httpClient,
197
- logger: this.logger,
198
- });
199
- resp = parseResponse(respBody, unmarshalEmptySchema);
200
- };
201
- await executeCall(call, options);
202
- if (resp === undefined) {
203
- throw new Error('operation completed without a result.');
204
- }
205
- return resp;
206
- }
207
-
208
- /** Updates an alert. */
209
- async updateAlert(
210
- req: UpdateAlertRequest,
211
- options?: CallOptions
212
- ): Promise<Alert> {
213
- const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`;
214
- const body = marshalRequest(req, marshalUpdateAlertRequestSchema);
215
- let resp: Alert | undefined;
216
- const call = async (callSignal?: AbortSignal): Promise<void> => {
217
- const headers = new Headers({'Content-Type': 'application/json'});
218
- if (this.workspaceId !== undefined) {
219
- headers.set('X-Databricks-Org-Id', this.workspaceId);
220
- }
221
- headers.set('User-Agent', this.userAgent);
222
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
223
- const respBody = await executeHttpCall({
224
- request: httpReq,
225
- httpClient: this.httpClient,
226
- logger: this.logger,
227
- });
228
- resp = parseResponse(respBody, unmarshalAlertSchema);
229
- };
230
- await executeCall(call, options);
231
- if (resp === undefined) {
232
- throw new Error('operation completed without a result.');
233
- }
234
- return resp;
235
- }
236
- }
package/src/v1/index.ts DELETED
@@ -1,25 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- export {AlertsClient} from './client';
4
-
5
- export {AlertOperator, AlertState, LifecycleState} from './model';
6
-
7
- export type {
8
- Alert,
9
- AlertCondition,
10
- AlertOperand,
11
- AlertOperandColumn,
12
- AlertOperandValue,
13
- CreateAlertRequest,
14
- CreateAlertRequestAlert,
15
- Empty,
16
- GetAlertRequest,
17
- ListAlertsRequest,
18
- ListAlertsResponse,
19
- ListAlertsResponseAlert,
20
- TrashAlertRequest,
21
- UpdateAlertRequest,
22
- UpdateAlertRequestAlert,
23
- } from './model';
24
-
25
- export {updateAlertRequestAlertFieldMask} from './model';