@databricks/sdk-uc-connections 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,250 +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
- ConnectionInfo,
21
- CreateConnectionRequest,
22
- DeleteConnectionRequest,
23
- DeleteConnectionResponse,
24
- GetConnectionRequest,
25
- ListConnectionsRequest,
26
- ListConnectionsResponse,
27
- UpdateConnectionRequest,
28
- } from './model';
29
- import {
30
- marshalCreateConnectionRequestSchema,
31
- marshalUpdateConnectionRequestSchema,
32
- unmarshalConnectionInfoSchema,
33
- unmarshalDeleteConnectionResponseSchema,
34
- unmarshalListConnectionsResponseSchema,
35
- } from './model';
36
-
37
- // Package identity segment for this client to be used in the User-Agent header.
38
- const PACKAGE_SEGMENT = {
39
- key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
40
- value: pkgJson.version,
41
- };
42
-
43
- export class ConnectionsClient {
44
- private readonly host: string;
45
- // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
46
- // When set, workspace-level methods send X-Databricks-Org-Id on every
47
- // request.
48
- private readonly workspaceId: string | undefined;
49
- private readonly httpClient: HttpClient;
50
- private readonly logger: Logger;
51
- // User-Agent header value. Composed once at construction from
52
- // createDefault() merged with this package's identity and the active
53
- // credential's name.
54
- private readonly userAgent: string;
55
-
56
- constructor(options: ClientOptions) {
57
- if (options.host === undefined) {
58
- throw new Error('Host is required.');
59
- }
60
- this.host = options.host.replace(/\/$/, '');
61
- this.workspaceId = options.workspaceId;
62
- this.logger = options.logger ?? new NoOpLogger();
63
- const info = createDefault()
64
- .with(PACKAGE_SEGMENT)
65
- .with({key: 'sdk-js-auth', value: AUTH_VERSION})
66
- .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
67
- this.userAgent = info.toString();
68
- this.httpClient = newHttpClient(options);
69
- }
70
-
71
- /**
72
- * Creates a new connection
73
- *
74
- * Creates a new connection to an external data source. It allows users to specify connection details and
75
- * configurations for interaction with the external server.
76
- */
77
- async createConnection(
78
- req: CreateConnectionRequest,
79
- options?: CallOptions
80
- ): Promise<ConnectionInfo> {
81
- const url = `${this.host}/api/2.1/unity-catalog/connections`;
82
- const body = marshalRequest(req, marshalCreateConnectionRequestSchema);
83
- let resp: ConnectionInfo | 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, unmarshalConnectionInfoSchema);
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
- /** Deletes the connection that matches the supplied name. */
106
- async deleteConnection(
107
- req: DeleteConnectionRequest,
108
- options?: CallOptions
109
- ): Promise<DeleteConnectionResponse> {
110
- const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`;
111
- let resp: DeleteConnectionResponse | undefined;
112
- const call = async (callSignal?: AbortSignal): Promise<void> => {
113
- const headers = new Headers();
114
- if (this.workspaceId !== undefined) {
115
- headers.set('X-Databricks-Org-Id', this.workspaceId);
116
- }
117
- headers.set('User-Agent', this.userAgent);
118
- const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
119
- const respBody = await executeHttpCall({
120
- request: httpReq,
121
- httpClient: this.httpClient,
122
- logger: this.logger,
123
- });
124
- resp = parseResponse(respBody, unmarshalDeleteConnectionResponseSchema);
125
- };
126
- await executeCall(call, options);
127
- if (resp === undefined) {
128
- throw new Error('operation completed without a result.');
129
- }
130
- return resp;
131
- }
132
-
133
- /** Gets a connection from it's name. */
134
- async getConnection(
135
- req: GetConnectionRequest,
136
- options?: CallOptions
137
- ): Promise<ConnectionInfo> {
138
- const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`;
139
- let resp: ConnectionInfo | undefined;
140
- const call = async (callSignal?: AbortSignal): Promise<void> => {
141
- const headers = new Headers();
142
- if (this.workspaceId !== undefined) {
143
- headers.set('X-Databricks-Org-Id', this.workspaceId);
144
- }
145
- headers.set('User-Agent', this.userAgent);
146
- const httpReq = buildHttpRequest('GET', url, headers, callSignal);
147
- const respBody = await executeHttpCall({
148
- request: httpReq,
149
- httpClient: this.httpClient,
150
- logger: this.logger,
151
- });
152
- resp = parseResponse(respBody, unmarshalConnectionInfoSchema);
153
- };
154
- await executeCall(call, options);
155
- if (resp === undefined) {
156
- throw new Error('operation completed without a result.');
157
- }
158
- return resp;
159
- }
160
-
161
- /**
162
- * List all connections.
163
- *
164
- * NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
165
- *
166
- * PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
167
- * Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
168
- */
169
- async listConnections(
170
- req: ListConnectionsRequest,
171
- options?: CallOptions
172
- ): Promise<ListConnectionsResponse> {
173
- const url = `${this.host}/api/2.1/unity-catalog/connections`;
174
- const params = new URLSearchParams();
175
- if (req.maxResults !== undefined) {
176
- params.append('max_results', String(req.maxResults));
177
- }
178
- if (req.pageToken !== undefined) {
179
- params.append('page_token', req.pageToken);
180
- }
181
- const query = params.toString();
182
- const fullUrl = query !== '' ? `${url}?${query}` : url;
183
- let resp: ListConnectionsResponse | undefined;
184
- const call = async (callSignal?: AbortSignal): Promise<void> => {
185
- const headers = new Headers();
186
- if (this.workspaceId !== undefined) {
187
- headers.set('X-Databricks-Org-Id', this.workspaceId);
188
- }
189
- headers.set('User-Agent', this.userAgent);
190
- const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
191
- const respBody = await executeHttpCall({
192
- request: httpReq,
193
- httpClient: this.httpClient,
194
- logger: this.logger,
195
- });
196
- resp = parseResponse(respBody, unmarshalListConnectionsResponseSchema);
197
- };
198
- await executeCall(call, options);
199
- if (resp === undefined) {
200
- throw new Error('operation completed without a result.');
201
- }
202
- return resp;
203
- }
204
-
205
- async *listConnectionsIter(
206
- req: ListConnectionsRequest,
207
- options?: CallOptions
208
- ): AsyncGenerator<ConnectionInfo> {
209
- const pageReq: ListConnectionsRequest = {...req};
210
- for (;;) {
211
- const resp = await this.listConnections(pageReq, options);
212
- for (const item of resp.connections ?? []) {
213
- yield item;
214
- }
215
- if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
216
- return;
217
- }
218
- pageReq.pageToken = resp.nextPageToken;
219
- }
220
- }
221
-
222
- /** Updates the connection that matches the supplied name. */
223
- async updateConnection(
224
- req: UpdateConnectionRequest,
225
- options?: CallOptions
226
- ): Promise<ConnectionInfo> {
227
- const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`;
228
- const body = marshalRequest(req, marshalUpdateConnectionRequestSchema);
229
- let resp: ConnectionInfo | undefined;
230
- const call = async (callSignal?: AbortSignal): Promise<void> => {
231
- const headers = new Headers({'Content-Type': 'application/json'});
232
- if (this.workspaceId !== undefined) {
233
- headers.set('X-Databricks-Org-Id', this.workspaceId);
234
- }
235
- headers.set('User-Agent', this.userAgent);
236
- const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
237
- const respBody = await executeHttpCall({
238
- request: httpReq,
239
- httpClient: this.httpClient,
240
- logger: this.logger,
241
- });
242
- resp = parseResponse(respBody, unmarshalConnectionInfoSchema);
243
- };
244
- await executeCall(call, options);
245
- if (resp === undefined) {
246
- throw new Error('operation completed without a result.');
247
- }
248
- return resp;
249
- }
250
- }
package/src/v1/index.ts DELETED
@@ -1,28 +0,0 @@
1
- // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
-
3
- export {ConnectionsClient} from './client';
4
-
5
- export {
6
- ConnectionType,
7
- CredentialType,
8
- SecurableType,
9
- ProvisioningInfo_State,
10
- } from './model';
11
-
12
- export type {
13
- ConnectionInfo,
14
- ConnectionInfo_OptionsEntry,
15
- ConnectionInfo_PropertiesEntry,
16
- CreateConnectionRequest,
17
- CreateConnectionRequest_OptionsEntry,
18
- CreateConnectionRequest_PropertiesEntry,
19
- DeleteConnectionRequest,
20
- DeleteConnectionResponse,
21
- GetConnectionRequest,
22
- ListConnectionsRequest,
23
- ListConnectionsResponse,
24
- ProvisioningInfo,
25
- UpdateConnectionRequest,
26
- UpdateConnectionRequest_OptionsEntry,
27
- UpdateConnectionRequest_PropertiesEntry,
28
- } from './model';