@databricks/sdk-uc-connections 0.1.0-dev.2 → 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/dist/v1/client.d.ts +3 -3
- package/dist/v1/client.d.ts.map +1 -1
- package/dist/v1/client.js +3 -3
- package/dist/v1/client.js.map +1 -1
- package/dist/v1/index.d.ts +1 -1
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/model.d.ts +95 -79
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +122 -95
- package/dist/v1/model.js.map +1 -1
- package/dist/v1/utils.d.ts.map +1 -1
- package/dist/v1/utils.js +2 -1
- package/dist/v1/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/v1/client.ts +0 -256
- package/src/v1/index.ts +0 -28
- package/src/v1/model.ts +0 -451
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -156
package/src/v1/client.ts
DELETED
|
@@ -1,256 +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
|
-
DeleteConnectionRequest_Response,
|
|
24
|
-
GetConnectionRequest,
|
|
25
|
-
ListConnectionsRequest,
|
|
26
|
-
ListConnectionsRequest_Response,
|
|
27
|
-
UpdateConnectionRequest,
|
|
28
|
-
} from './model';
|
|
29
|
-
import {
|
|
30
|
-
marshalCreateConnectionRequestSchema,
|
|
31
|
-
marshalUpdateConnectionRequestSchema,
|
|
32
|
-
unmarshalConnectionInfoSchema,
|
|
33
|
-
unmarshalDeleteConnectionRequest_ResponseSchema,
|
|
34
|
-
unmarshalListConnectionsRequest_ResponseSchema,
|
|
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<DeleteConnectionRequest_Response> {
|
|
110
|
-
const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`;
|
|
111
|
-
let resp: DeleteConnectionRequest_Response | 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(
|
|
125
|
-
respBody,
|
|
126
|
-
unmarshalDeleteConnectionRequest_ResponseSchema
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
await executeCall(call, options);
|
|
130
|
-
if (resp === undefined) {
|
|
131
|
-
throw new Error('operation completed without a result.');
|
|
132
|
-
}
|
|
133
|
-
return resp;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** Gets a connection from it's name. */
|
|
137
|
-
async getConnection(
|
|
138
|
-
req: GetConnectionRequest,
|
|
139
|
-
options?: CallOptions
|
|
140
|
-
): Promise<ConnectionInfo> {
|
|
141
|
-
const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`;
|
|
142
|
-
let resp: ConnectionInfo | undefined;
|
|
143
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
144
|
-
const headers = new Headers();
|
|
145
|
-
if (this.workspaceId !== undefined) {
|
|
146
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
147
|
-
}
|
|
148
|
-
headers.set('User-Agent', this.userAgent);
|
|
149
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
150
|
-
const respBody = await executeHttpCall({
|
|
151
|
-
request: httpReq,
|
|
152
|
-
httpClient: this.httpClient,
|
|
153
|
-
logger: this.logger,
|
|
154
|
-
});
|
|
155
|
-
resp = parseResponse(respBody, unmarshalConnectionInfoSchema);
|
|
156
|
-
};
|
|
157
|
-
await executeCall(call, options);
|
|
158
|
-
if (resp === undefined) {
|
|
159
|
-
throw new Error('operation completed without a result.');
|
|
160
|
-
}
|
|
161
|
-
return resp;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* List all connections.
|
|
166
|
-
*
|
|
167
|
-
* NOTE: we recommend using max_results=0 to use the paginated version of this API. Unpaginated calls will be deprecated soon.
|
|
168
|
-
*
|
|
169
|
-
* PAGINATION BEHAVIOR: When using pagination (max_results >= 0), a page may contain zero results while still providing a next_page_token.
|
|
170
|
-
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
171
|
-
*/
|
|
172
|
-
async listConnections(
|
|
173
|
-
req: ListConnectionsRequest,
|
|
174
|
-
options?: CallOptions
|
|
175
|
-
): Promise<ListConnectionsRequest_Response> {
|
|
176
|
-
const url = `${this.host}/api/2.1/unity-catalog/connections`;
|
|
177
|
-
const params = new URLSearchParams();
|
|
178
|
-
if (req.maxResults !== undefined) {
|
|
179
|
-
params.append('max_results', String(req.maxResults));
|
|
180
|
-
}
|
|
181
|
-
if (req.pageToken !== undefined) {
|
|
182
|
-
params.append('page_token', req.pageToken);
|
|
183
|
-
}
|
|
184
|
-
const query = params.toString();
|
|
185
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
186
|
-
let resp: ListConnectionsRequest_Response | 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('GET', fullUrl, headers, callSignal);
|
|
194
|
-
const respBody = await executeHttpCall({
|
|
195
|
-
request: httpReq,
|
|
196
|
-
httpClient: this.httpClient,
|
|
197
|
-
logger: this.logger,
|
|
198
|
-
});
|
|
199
|
-
resp = parseResponse(
|
|
200
|
-
respBody,
|
|
201
|
-
unmarshalListConnectionsRequest_ResponseSchema
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
await executeCall(call, options);
|
|
205
|
-
if (resp === undefined) {
|
|
206
|
-
throw new Error('operation completed without a result.');
|
|
207
|
-
}
|
|
208
|
-
return resp;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
async *listConnectionsIter(
|
|
212
|
-
req: ListConnectionsRequest,
|
|
213
|
-
options?: CallOptions
|
|
214
|
-
): AsyncGenerator<ConnectionInfo> {
|
|
215
|
-
const pageReq: ListConnectionsRequest = {...req};
|
|
216
|
-
for (;;) {
|
|
217
|
-
const resp = await this.listConnections(pageReq, options);
|
|
218
|
-
for (const item of resp.connections ?? []) {
|
|
219
|
-
yield item;
|
|
220
|
-
}
|
|
221
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** Updates the connection that matches the supplied name. */
|
|
229
|
-
async updateConnection(
|
|
230
|
-
req: UpdateConnectionRequest,
|
|
231
|
-
options?: CallOptions
|
|
232
|
-
): Promise<ConnectionInfo> {
|
|
233
|
-
const url = `${this.host}/api/2.1/unity-catalog/connections/${req.nameArg ?? ''}`;
|
|
234
|
-
const body = marshalRequest(req, marshalUpdateConnectionRequestSchema);
|
|
235
|
-
let resp: ConnectionInfo | undefined;
|
|
236
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
237
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
238
|
-
if (this.workspaceId !== undefined) {
|
|
239
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
240
|
-
}
|
|
241
|
-
headers.set('User-Agent', this.userAgent);
|
|
242
|
-
const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
|
|
243
|
-
const respBody = await executeHttpCall({
|
|
244
|
-
request: httpReq,
|
|
245
|
-
httpClient: this.httpClient,
|
|
246
|
-
logger: this.logger,
|
|
247
|
-
});
|
|
248
|
-
resp = parseResponse(respBody, unmarshalConnectionInfoSchema);
|
|
249
|
-
};
|
|
250
|
-
await executeCall(call, options);
|
|
251
|
-
if (resp === undefined) {
|
|
252
|
-
throw new Error('operation completed without a result.');
|
|
253
|
-
}
|
|
254
|
-
return resp;
|
|
255
|
-
}
|
|
256
|
-
}
|
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
|
-
DeleteConnectionRequest_Response,
|
|
21
|
-
GetConnectionRequest,
|
|
22
|
-
ListConnectionsRequest,
|
|
23
|
-
ListConnectionsRequest_Response,
|
|
24
|
-
ProvisioningInfo,
|
|
25
|
-
UpdateConnectionRequest,
|
|
26
|
-
UpdateConnectionRequest_OptionsEntry,
|
|
27
|
-
UpdateConnectionRequest_PropertiesEntry,
|
|
28
|
-
} from './model';
|