@databricks/sdk-uc-entitytagassignments 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/dist/v1/model.d.ts +5 -4
- package/dist/v1/model.d.ts.map +1 -1
- package/dist/v1/model.js +7 -7
- 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 +4 -5
- package/src/v1/client.ts +0 -282
- package/src/v1/index.ts +0 -17
- package/src/v1/model.ts +0 -161
- package/src/v1/transport.ts +0 -73
- package/src/v1/utils.ts +0 -156
package/dist/v1/model.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { Temporal } from '@js-temporal/polyfill';
|
|
|
2
2
|
import { FieldMask } from '@databricks/sdk-core/wkt';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
/** Enum representing the source type of a tag assignment */
|
|
5
|
-
export declare
|
|
5
|
+
export declare const TagAssignmentSourceType: {
|
|
6
6
|
/** Includes (but not limited to) tags manually assigned by users */
|
|
7
|
-
TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED
|
|
7
|
+
readonly TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED: "TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED";
|
|
8
8
|
/** Automatically assigned by Data Classification */
|
|
9
|
-
TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION
|
|
10
|
-
}
|
|
9
|
+
readonly TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION: "TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION";
|
|
10
|
+
};
|
|
11
|
+
export type TagAssignmentSourceType = (typeof TagAssignmentSourceType)[keyof typeof TagAssignmentSourceType] | (string & {});
|
|
11
12
|
/** Request to create a new entity tag assignment */
|
|
12
13
|
export interface CreateEntityTagAssignmentRequest {
|
|
13
14
|
tagAssignment?: EntityTagAssignment | undefined;
|
package/dist/v1/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,4DAA4D;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,4DAA4D;AAE5D,eAAO,MAAM,uBAAuB;IAClC,oEAAoE;;IAGpE,oDAAoD;;CAG5C,CAAC;AACX,MAAM,MAAM,uBAAuB,GAC/B,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,GACtE,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,oDAAoD;AACpD,MAAM,WAAW,gCAAgC;IAC/C,aAAa,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACjD;AAED,iDAAiD;AACjD,MAAM,WAAW,gCAAgC;IAC/C,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,UAAU,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SAAS,CAAC;IAChD,UAAU,CAAC,EAAE,SAAS,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;CACzD;AAED,eAAO,MAAM,kCAAkC,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAsBvE,CAAC;AAER,eAAO,MAAM,+CAA+C,EAAE,CAAC,CAAC,OAAO,CAAC,gCAAgC,CAWjG,CAAC;AAER,eAAO,MAAM,gCAAgC,EAAE,CAAC,CAAC,OAqB5C,CAAC;AAYN,wBAAgB,4BAA4B,CAC1C,GAAG,KAAK,EAAE,MAAM,EAAE,GACjB,SAAS,CAAC,mBAAmB,CAAC,CAKhC"}
|
package/dist/v1/model.js
CHANGED
|
@@ -3,13 +3,13 @@ import { Temporal } from '@js-temporal/polyfill';
|
|
|
3
3
|
import { FieldMask } from '@databricks/sdk-core/wkt';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
/** Enum representing the source type of a tag assignment */
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Enum-style const object.
|
|
7
|
+
export const TagAssignmentSourceType = {
|
|
8
8
|
/** Includes (but not limited to) tags manually assigned by users */
|
|
9
|
-
|
|
9
|
+
TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED: 'TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED',
|
|
10
10
|
/** Automatically assigned by Data Classification */
|
|
11
|
-
|
|
12
|
-
}
|
|
11
|
+
TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION: 'TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION',
|
|
12
|
+
};
|
|
13
13
|
export const unmarshalEntityTagAssignmentSchema = z
|
|
14
14
|
.object({
|
|
15
15
|
entity_name: z.string().optional(),
|
|
@@ -21,7 +21,7 @@ export const unmarshalEntityTagAssignmentSchema = z
|
|
|
21
21
|
.transform(s => Temporal.Instant.from(s))
|
|
22
22
|
.optional(),
|
|
23
23
|
updated_by: z.string().optional(),
|
|
24
|
-
source_type: z.
|
|
24
|
+
source_type: z.string().optional(),
|
|
25
25
|
})
|
|
26
26
|
.transform(d => ({
|
|
27
27
|
entityName: d.entity_name,
|
|
@@ -54,7 +54,7 @@ export const marshalEntityTagAssignmentSchema = z
|
|
|
54
54
|
.transform((d) => d.toString())
|
|
55
55
|
.optional(),
|
|
56
56
|
updatedBy: z.string().optional(),
|
|
57
|
-
sourceType: z.
|
|
57
|
+
sourceType: z.string().optional(),
|
|
58
58
|
})
|
|
59
59
|
.transform(d => ({
|
|
60
60
|
entity_name: d.entityName,
|
package/dist/v1/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,4DAA4D;AAC5D,MAAM,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/v1/model.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,4DAA4D;AAC5D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,oEAAoE;IACpE,sCAAsC,EACpC,wCAAwC;IAC1C,oDAAoD;IACpD,qDAAqD,EACnD,uDAAuD;CACjD,CAAC;AAyEX,MAAM,CAAC,MAAM,kCAAkC,GAC7C,CAAC;KACE,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QA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,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,eAAe,GACtB,IAAI,CAuBN"}
|
package/dist/v1/utils.js
CHANGED
|
@@ -79,7 +79,8 @@ export function buildHttpRequest(method, url, headers, signal, body) {
|
|
|
79
79
|
}
|
|
80
80
|
export function parseResponse(body, schema) {
|
|
81
81
|
const text = new TextDecoder().decode(body);
|
|
82
|
-
|
|
82
|
+
// 204 responses return an empty body; treat as `{}`.
|
|
83
|
+
const parsed = text === '' ? {} : jsonBigint.parse(text);
|
|
83
84
|
return schema.parse(parsed);
|
|
84
85
|
}
|
|
85
86
|
export function marshalRequest(data, schema) {
|
package/dist/v1/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/v1/utils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAQvD,OAAO,OAAO,MAAM,aAAa,CAAC;AAGlC,0EAA0E;AAC1E,6EAA6E;AAC7E,gEAAgE;AAChE,MAAM,UAAU,GAAG,OAAO,CAAC,EAAC,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC;AAQpD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAA6C,EAC7C,OAAqB;IAErB,MAAM,IAAI,GAAY;QACpB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC;QACjE,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,IAAI;YACxC,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;QACF,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,IAAI,EAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAC;KACl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AAc,EACd,MAAuB;IAEvB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,0CAA0C;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@databricks/sdk-uc-entitytagassignments",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"src",
|
|
16
15
|
"LICENSE"
|
|
17
16
|
],
|
|
18
17
|
"scripts": {
|
|
@@ -29,9 +28,9 @@
|
|
|
29
28
|
"author": "Databricks",
|
|
30
29
|
"license": "Apache-2.0",
|
|
31
30
|
"dependencies": {
|
|
32
|
-
"@databricks/sdk-auth": ">=0.1.0-dev.
|
|
33
|
-
"@databricks/sdk-core": ">=0.1.0-dev.
|
|
34
|
-
"@databricks/sdk-options": ">=0.1.0-dev.
|
|
31
|
+
"@databricks/sdk-auth": ">=0.1.0-dev.5 <1.0.0",
|
|
32
|
+
"@databricks/sdk-core": ">=0.1.0-dev.6 <1.0.0",
|
|
33
|
+
"@databricks/sdk-options": ">=0.1.0-dev.5 <1.0.0",
|
|
35
34
|
"@js-temporal/polyfill": "^0.5.0",
|
|
36
35
|
"json-bigint": "^1.0.0",
|
|
37
36
|
"zod": "^4.3.6"
|
package/src/v1/client.ts
DELETED
|
@@ -1,282 +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
|
-
CreateEntityTagAssignmentRequest,
|
|
21
|
-
DeleteEntityTagAssignmentRequest,
|
|
22
|
-
EntityTagAssignment,
|
|
23
|
-
GetEntityTagAssignmentRequest,
|
|
24
|
-
ListEntityTagAssignmentsRequest,
|
|
25
|
-
ListEntityTagAssignmentsResponse,
|
|
26
|
-
UpdateEntityTagAssignmentRequest,
|
|
27
|
-
} from './model';
|
|
28
|
-
import {
|
|
29
|
-
marshalEntityTagAssignmentSchema,
|
|
30
|
-
unmarshalEntityTagAssignmentSchema,
|
|
31
|
-
unmarshalListEntityTagAssignmentsResponseSchema,
|
|
32
|
-
} from './model';
|
|
33
|
-
|
|
34
|
-
// Package identity segment for this client to be used in the User-Agent header.
|
|
35
|
-
const PACKAGE_SEGMENT = {
|
|
36
|
-
key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
|
|
37
|
-
value: pkgJson.version,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export class EntityTagAssignmentsClient {
|
|
41
|
-
private readonly host: string;
|
|
42
|
-
// Workspace ID used to route workspace-level calls on unified hosts (SPOG).
|
|
43
|
-
// When set, workspace-level methods send X-Databricks-Org-Id on every
|
|
44
|
-
// request.
|
|
45
|
-
private readonly workspaceId: string | undefined;
|
|
46
|
-
private readonly httpClient: HttpClient;
|
|
47
|
-
private readonly logger: Logger;
|
|
48
|
-
// User-Agent header value. Composed once at construction from
|
|
49
|
-
// createDefault() merged with this package's identity and the active
|
|
50
|
-
// credential's name.
|
|
51
|
-
private readonly userAgent: string;
|
|
52
|
-
|
|
53
|
-
constructor(options: ClientOptions) {
|
|
54
|
-
if (options.host === undefined) {
|
|
55
|
-
throw new Error('Host is required.');
|
|
56
|
-
}
|
|
57
|
-
this.host = options.host.replace(/\/$/, '');
|
|
58
|
-
this.workspaceId = options.workspaceId;
|
|
59
|
-
this.logger = options.logger ?? new NoOpLogger();
|
|
60
|
-
const info = createDefault()
|
|
61
|
-
.with(PACKAGE_SEGMENT)
|
|
62
|
-
.with({key: 'sdk-js-auth', value: AUTH_VERSION})
|
|
63
|
-
.with({key: 'auth', value: options.credentials?.name() ?? 'default'});
|
|
64
|
-
this.userAgent = info.toString();
|
|
65
|
-
this.httpClient = newHttpClient(options);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Creates a tag assignment for an Unity Catalog entity.
|
|
70
|
-
*
|
|
71
|
-
* To add tags to Unity Catalog entities, you must own the entity or have the following privileges:
|
|
72
|
-
* - **APPLY TAG** on the entity
|
|
73
|
-
* - **USE SCHEMA** on the entity's parent schema
|
|
74
|
-
* - **USE CATALOG** on the entity's parent catalog
|
|
75
|
-
*
|
|
76
|
-
* To add a governed tag to Unity Catalog entities, you must also have the **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy permissions](https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions).
|
|
77
|
-
*/
|
|
78
|
-
async createEntityTagAssignment(
|
|
79
|
-
req: CreateEntityTagAssignmentRequest,
|
|
80
|
-
options?: CallOptions
|
|
81
|
-
): Promise<EntityTagAssignment> {
|
|
82
|
-
const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments`;
|
|
83
|
-
const body = marshalRequest(
|
|
84
|
-
req.tagAssignment,
|
|
85
|
-
marshalEntityTagAssignmentSchema
|
|
86
|
-
);
|
|
87
|
-
let resp: EntityTagAssignment | undefined;
|
|
88
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
89
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
90
|
-
if (this.workspaceId !== undefined) {
|
|
91
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
92
|
-
}
|
|
93
|
-
headers.set('User-Agent', this.userAgent);
|
|
94
|
-
const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
|
|
95
|
-
const respBody = await executeHttpCall({
|
|
96
|
-
request: httpReq,
|
|
97
|
-
httpClient: this.httpClient,
|
|
98
|
-
logger: this.logger,
|
|
99
|
-
});
|
|
100
|
-
resp = parseResponse(respBody, unmarshalEntityTagAssignmentSchema);
|
|
101
|
-
};
|
|
102
|
-
await executeCall(call, options);
|
|
103
|
-
if (resp === undefined) {
|
|
104
|
-
throw new Error('operation completed without a result.');
|
|
105
|
-
}
|
|
106
|
-
return resp;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Deletes a tag assignment for an Unity Catalog entity by its key.
|
|
111
|
-
*
|
|
112
|
-
* To delete tags from Unity Catalog entities, you must own the entity or have the following privileges:
|
|
113
|
-
* - **APPLY TAG** on the entity
|
|
114
|
-
* - **USE_SCHEMA** on the entity's parent schema
|
|
115
|
-
* - **USE_CATALOG** on the entity's parent catalog
|
|
116
|
-
*
|
|
117
|
-
* To delete a governed tag from Unity Catalog entities, you must also have the **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy permissions](https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions).
|
|
118
|
-
*/
|
|
119
|
-
async deleteEntityTagAssignment(
|
|
120
|
-
req: DeleteEntityTagAssignmentRequest,
|
|
121
|
-
options?: CallOptions
|
|
122
|
-
): Promise<void> {
|
|
123
|
-
const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.entityType ?? ''}/${req.entityName ?? ''}/tags/${req.tagKey ?? ''}`;
|
|
124
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
125
|
-
const headers = new Headers();
|
|
126
|
-
if (this.workspaceId !== undefined) {
|
|
127
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
128
|
-
}
|
|
129
|
-
headers.set('User-Agent', this.userAgent);
|
|
130
|
-
const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
|
|
131
|
-
await executeHttpCall({
|
|
132
|
-
request: httpReq,
|
|
133
|
-
httpClient: this.httpClient,
|
|
134
|
-
logger: this.logger,
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
await executeCall(call, options);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** Gets a tag assignment for an Unity Catalog entity by tag key. */
|
|
141
|
-
async getEntityTagAssignment(
|
|
142
|
-
req: GetEntityTagAssignmentRequest,
|
|
143
|
-
options?: CallOptions
|
|
144
|
-
): Promise<EntityTagAssignment> {
|
|
145
|
-
const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.entityType ?? ''}/${req.entityName ?? ''}/tags/${req.tagKey ?? ''}`;
|
|
146
|
-
let resp: EntityTagAssignment | undefined;
|
|
147
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
148
|
-
const headers = new Headers();
|
|
149
|
-
if (this.workspaceId !== undefined) {
|
|
150
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
151
|
-
}
|
|
152
|
-
headers.set('User-Agent', this.userAgent);
|
|
153
|
-
const httpReq = buildHttpRequest('GET', url, headers, callSignal);
|
|
154
|
-
const respBody = await executeHttpCall({
|
|
155
|
-
request: httpReq,
|
|
156
|
-
httpClient: this.httpClient,
|
|
157
|
-
logger: this.logger,
|
|
158
|
-
});
|
|
159
|
-
resp = parseResponse(respBody, unmarshalEntityTagAssignmentSchema);
|
|
160
|
-
};
|
|
161
|
-
await executeCall(call, options);
|
|
162
|
-
if (resp === undefined) {
|
|
163
|
-
throw new Error('operation completed without a result.');
|
|
164
|
-
}
|
|
165
|
-
return resp;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* List tag assignments for an Unity Catalog entity
|
|
170
|
-
*
|
|
171
|
-
* PAGINATION BEHAVIOR: The API is by default paginated, a page may contain zero results while still providing a next_page_token.
|
|
172
|
-
* Clients must continue reading pages until next_page_token is absent, which is the only indication that the end of results has been reached.
|
|
173
|
-
*/
|
|
174
|
-
async listEntityTagAssignments(
|
|
175
|
-
req: ListEntityTagAssignmentsRequest,
|
|
176
|
-
options?: CallOptions
|
|
177
|
-
): Promise<ListEntityTagAssignmentsResponse> {
|
|
178
|
-
const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.entityType ?? ''}/${req.entityName ?? ''}/tags`;
|
|
179
|
-
const params = new URLSearchParams();
|
|
180
|
-
if (req.maxResults !== undefined) {
|
|
181
|
-
params.append('max_results', String(req.maxResults));
|
|
182
|
-
}
|
|
183
|
-
if (req.pageToken !== undefined) {
|
|
184
|
-
params.append('page_token', req.pageToken);
|
|
185
|
-
}
|
|
186
|
-
const query = params.toString();
|
|
187
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
188
|
-
let resp: ListEntityTagAssignmentsResponse | undefined;
|
|
189
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
190
|
-
const headers = new Headers();
|
|
191
|
-
if (this.workspaceId !== undefined) {
|
|
192
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
193
|
-
}
|
|
194
|
-
headers.set('User-Agent', this.userAgent);
|
|
195
|
-
const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
|
|
196
|
-
const respBody = await executeHttpCall({
|
|
197
|
-
request: httpReq,
|
|
198
|
-
httpClient: this.httpClient,
|
|
199
|
-
logger: this.logger,
|
|
200
|
-
});
|
|
201
|
-
resp = parseResponse(
|
|
202
|
-
respBody,
|
|
203
|
-
unmarshalListEntityTagAssignmentsResponseSchema
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
await executeCall(call, options);
|
|
207
|
-
if (resp === undefined) {
|
|
208
|
-
throw new Error('operation completed without a result.');
|
|
209
|
-
}
|
|
210
|
-
return resp;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async *listEntityTagAssignmentsIter(
|
|
214
|
-
req: ListEntityTagAssignmentsRequest,
|
|
215
|
-
options?: CallOptions
|
|
216
|
-
): AsyncGenerator<EntityTagAssignment> {
|
|
217
|
-
const pageReq: ListEntityTagAssignmentsRequest = {...req};
|
|
218
|
-
for (;;) {
|
|
219
|
-
const resp = await this.listEntityTagAssignments(pageReq, options);
|
|
220
|
-
for (const item of resp.tagAssignments ?? []) {
|
|
221
|
-
yield item;
|
|
222
|
-
}
|
|
223
|
-
if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
pageReq.pageToken = resp.nextPageToken;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Updates an existing tag assignment for an Unity Catalog entity.
|
|
232
|
-
*
|
|
233
|
-
* To update tags to Unity Catalog entities, you must own the entity or have the following privileges:
|
|
234
|
-
* - **APPLY TAG** on the entity
|
|
235
|
-
* - **USE SCHEMA** on the entity's parent schema
|
|
236
|
-
* - **USE CATALOG** on the entity's parent catalog
|
|
237
|
-
*
|
|
238
|
-
* To update a governed tag to Unity Catalog entities, you must also have the **ASSIGN** or **MANAGE** permission on the tag policy. See [Manage tag policy permissions](https://docs.databricks.com/aws/en/admin/tag-policies/manage-permissions).
|
|
239
|
-
*/
|
|
240
|
-
async updateEntityTagAssignment(
|
|
241
|
-
req: UpdateEntityTagAssignmentRequest,
|
|
242
|
-
options?: CallOptions
|
|
243
|
-
): Promise<EntityTagAssignment> {
|
|
244
|
-
const url = `${this.host}/api/2.1/unity-catalog/entity-tag-assignments/${req.tagAssignment?.entityType ?? ''}/${req.tagAssignment?.entityName ?? ''}/tags/${req.tagAssignment?.tagKey ?? ''}`;
|
|
245
|
-
const params = new URLSearchParams();
|
|
246
|
-
if (req.updateMask !== undefined) {
|
|
247
|
-
params.append('update_mask', req.updateMask.toString());
|
|
248
|
-
}
|
|
249
|
-
const query = params.toString();
|
|
250
|
-
const fullUrl = query !== '' ? `${url}?${query}` : url;
|
|
251
|
-
const body = marshalRequest(
|
|
252
|
-
req.tagAssignment,
|
|
253
|
-
marshalEntityTagAssignmentSchema
|
|
254
|
-
);
|
|
255
|
-
let resp: EntityTagAssignment | undefined;
|
|
256
|
-
const call = async (callSignal?: AbortSignal): Promise<void> => {
|
|
257
|
-
const headers = new Headers({'Content-Type': 'application/json'});
|
|
258
|
-
if (this.workspaceId !== undefined) {
|
|
259
|
-
headers.set('X-Databricks-Org-Id', this.workspaceId);
|
|
260
|
-
}
|
|
261
|
-
headers.set('User-Agent', this.userAgent);
|
|
262
|
-
const httpReq = buildHttpRequest(
|
|
263
|
-
'PATCH',
|
|
264
|
-
fullUrl,
|
|
265
|
-
headers,
|
|
266
|
-
callSignal,
|
|
267
|
-
body
|
|
268
|
-
);
|
|
269
|
-
const respBody = await executeHttpCall({
|
|
270
|
-
request: httpReq,
|
|
271
|
-
httpClient: this.httpClient,
|
|
272
|
-
logger: this.logger,
|
|
273
|
-
});
|
|
274
|
-
resp = parseResponse(respBody, unmarshalEntityTagAssignmentSchema);
|
|
275
|
-
};
|
|
276
|
-
await executeCall(call, options);
|
|
277
|
-
if (resp === undefined) {
|
|
278
|
-
throw new Error('operation completed without a result.');
|
|
279
|
-
}
|
|
280
|
-
return resp;
|
|
281
|
-
}
|
|
282
|
-
}
|
package/src/v1/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
export {EntityTagAssignmentsClient} from './client';
|
|
4
|
-
|
|
5
|
-
export {TagAssignmentSourceType} from './model';
|
|
6
|
-
|
|
7
|
-
export type {
|
|
8
|
-
CreateEntityTagAssignmentRequest,
|
|
9
|
-
DeleteEntityTagAssignmentRequest,
|
|
10
|
-
EntityTagAssignment,
|
|
11
|
-
GetEntityTagAssignmentRequest,
|
|
12
|
-
ListEntityTagAssignmentsRequest,
|
|
13
|
-
ListEntityTagAssignmentsResponse,
|
|
14
|
-
UpdateEntityTagAssignmentRequest,
|
|
15
|
-
} from './model';
|
|
16
|
-
|
|
17
|
-
export {entityTagAssignmentFieldMask} from './model';
|
package/src/v1/model.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import {Temporal} from '@js-temporal/polyfill';
|
|
4
|
-
import {FieldMask} from '@databricks/sdk-core/wkt';
|
|
5
|
-
import type {FieldMaskSchema} from '@databricks/sdk-core/wkt';
|
|
6
|
-
import {z} from 'zod';
|
|
7
|
-
|
|
8
|
-
/** Enum representing the source type of a tag assignment */
|
|
9
|
-
export enum TagAssignmentSourceType {
|
|
10
|
-
/** Includes (but not limited to) tags manually assigned by users */
|
|
11
|
-
TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED = 'TAG_ASSIGNMENT_SOURCE_TYPE_UNSPECIFIED',
|
|
12
|
-
/** Automatically assigned by Data Classification */
|
|
13
|
-
TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION = 'TAG_ASSIGNMENT_SOURCE_TYPE_SYSTEM_DATA_CLASSIFICATION',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Request to create a new entity tag assignment */
|
|
17
|
-
export interface CreateEntityTagAssignmentRequest {
|
|
18
|
-
tagAssignment?: EntityTagAssignment | undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Request to delete an entity tag assignment */
|
|
22
|
-
export interface DeleteEntityTagAssignmentRequest {
|
|
23
|
-
/** The fully qualified name of the entity to which the tag is assigned */
|
|
24
|
-
entityName?: string | undefined;
|
|
25
|
-
/** Required. The key of the tag to delete */
|
|
26
|
-
tagKey?: string | undefined;
|
|
27
|
-
/** The type of the entity to which the tag is assigned. */
|
|
28
|
-
entityType?: string | undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Represents a tag assignment to an entity */
|
|
32
|
-
export interface EntityTagAssignment {
|
|
33
|
-
/** The fully qualified name of the entity to which the tag is assigned */
|
|
34
|
-
entityName?: string | undefined;
|
|
35
|
-
/** The key of the tag */
|
|
36
|
-
tagKey?: string | undefined;
|
|
37
|
-
/** The value of the tag */
|
|
38
|
-
tagValue?: string | undefined;
|
|
39
|
-
/** The type of the entity to which the tag is assigned. */
|
|
40
|
-
entityType?: string | undefined;
|
|
41
|
-
/** The timestamp when the tag assignment was last updated */
|
|
42
|
-
updateTime?: Temporal.Instant | undefined;
|
|
43
|
-
/** The user or principal who updated the tag assignment */
|
|
44
|
-
updatedBy?: string | undefined;
|
|
45
|
-
/** The source type of the tag assignment, e.g., user-assigned or system-assigned */
|
|
46
|
-
sourceType?: TagAssignmentSourceType | undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Request to get an entity tag assignment */
|
|
50
|
-
export interface GetEntityTagAssignmentRequest {
|
|
51
|
-
/** The fully qualified name of the entity to which the tag is assigned */
|
|
52
|
-
entityName?: string | undefined;
|
|
53
|
-
/** Required. The key of the tag */
|
|
54
|
-
tagKey?: string | undefined;
|
|
55
|
-
/** The type of the entity to which the tag is assigned. */
|
|
56
|
-
entityType?: string | undefined;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Request to list entity tag assignments */
|
|
60
|
-
export interface ListEntityTagAssignmentsRequest {
|
|
61
|
-
/** The fully qualified name of the entity to which the tag is assigned */
|
|
62
|
-
entityName?: string | undefined;
|
|
63
|
-
/** Optional. Maximum number of tag assignments to return in a single page */
|
|
64
|
-
maxResults?: number | undefined;
|
|
65
|
-
/** Optional. Pagination token to retrieve the next page of results */
|
|
66
|
-
pageToken?: string | undefined;
|
|
67
|
-
/** The type of the entity to which the tag is assigned. */
|
|
68
|
-
entityType?: string | undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface ListEntityTagAssignmentsResponse {
|
|
72
|
-
/** The list of tag assignments */
|
|
73
|
-
tagAssignments?: EntityTagAssignment[] | undefined;
|
|
74
|
-
/** Optional. Pagination token for retrieving the next page of results */
|
|
75
|
-
nextPageToken?: string | undefined;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Request to update an entity tag assignment */
|
|
79
|
-
export interface UpdateEntityTagAssignmentRequest {
|
|
80
|
-
tagAssignment?: EntityTagAssignment | undefined;
|
|
81
|
-
updateMask?: FieldMask<EntityTagAssignment> | undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const unmarshalEntityTagAssignmentSchema: z.ZodType<EntityTagAssignment> =
|
|
85
|
-
z
|
|
86
|
-
.object({
|
|
87
|
-
entity_name: z.string().optional(),
|
|
88
|
-
tag_key: z.string().optional(),
|
|
89
|
-
tag_value: z.string().optional(),
|
|
90
|
-
entity_type: z.string().optional(),
|
|
91
|
-
update_time: z
|
|
92
|
-
.string()
|
|
93
|
-
.transform(s => Temporal.Instant.from(s))
|
|
94
|
-
.optional(),
|
|
95
|
-
updated_by: z.string().optional(),
|
|
96
|
-
source_type: z.enum(TagAssignmentSourceType).optional(),
|
|
97
|
-
})
|
|
98
|
-
.transform(d => ({
|
|
99
|
-
entityName: d.entity_name,
|
|
100
|
-
tagKey: d.tag_key,
|
|
101
|
-
tagValue: d.tag_value,
|
|
102
|
-
entityType: d.entity_type,
|
|
103
|
-
updateTime: d.update_time,
|
|
104
|
-
updatedBy: d.updated_by,
|
|
105
|
-
sourceType: d.source_type,
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
export const unmarshalListEntityTagAssignmentsResponseSchema: z.ZodType<ListEntityTagAssignmentsResponse> =
|
|
109
|
-
z
|
|
110
|
-
.object({
|
|
111
|
-
tag_assignments: z
|
|
112
|
-
.array(z.lazy(() => unmarshalEntityTagAssignmentSchema))
|
|
113
|
-
.optional(),
|
|
114
|
-
next_page_token: z.string().optional(),
|
|
115
|
-
})
|
|
116
|
-
.transform(d => ({
|
|
117
|
-
tagAssignments: d.tag_assignments,
|
|
118
|
-
nextPageToken: d.next_page_token,
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
export const marshalEntityTagAssignmentSchema: z.ZodType = z
|
|
122
|
-
.object({
|
|
123
|
-
entityName: z.string().optional(),
|
|
124
|
-
tagKey: z.string().optional(),
|
|
125
|
-
tagValue: z.string().optional(),
|
|
126
|
-
entityType: z.string().optional(),
|
|
127
|
-
updateTime: z
|
|
128
|
-
.any()
|
|
129
|
-
.transform((d: Temporal.Instant) => d.toString())
|
|
130
|
-
.optional(),
|
|
131
|
-
updatedBy: z.string().optional(),
|
|
132
|
-
sourceType: z.enum(TagAssignmentSourceType).optional(),
|
|
133
|
-
})
|
|
134
|
-
.transform(d => ({
|
|
135
|
-
entity_name: d.entityName,
|
|
136
|
-
tag_key: d.tagKey,
|
|
137
|
-
tag_value: d.tagValue,
|
|
138
|
-
entity_type: d.entityType,
|
|
139
|
-
update_time: d.updateTime,
|
|
140
|
-
updated_by: d.updatedBy,
|
|
141
|
-
source_type: d.sourceType,
|
|
142
|
-
}));
|
|
143
|
-
|
|
144
|
-
const entityTagAssignmentFieldMaskSchema: FieldMaskSchema = {
|
|
145
|
-
entityName: {wire: 'entity_name'},
|
|
146
|
-
entityType: {wire: 'entity_type'},
|
|
147
|
-
sourceType: {wire: 'source_type'},
|
|
148
|
-
tagKey: {wire: 'tag_key'},
|
|
149
|
-
tagValue: {wire: 'tag_value'},
|
|
150
|
-
updateTime: {wire: 'update_time'},
|
|
151
|
-
updatedBy: {wire: 'updated_by'},
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export function entityTagAssignmentFieldMask(
|
|
155
|
-
...paths: string[]
|
|
156
|
-
): FieldMask<EntityTagAssignment> {
|
|
157
|
-
return FieldMask.build<EntityTagAssignment>(
|
|
158
|
-
paths,
|
|
159
|
-
entityTagAssignmentFieldMaskSchema
|
|
160
|
-
);
|
|
161
|
-
}
|
package/src/v1/transport.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import type {Credentials} from '@databricks/sdk-auth';
|
|
4
|
-
import {defaultCredentials} from '@databricks/sdk-auth/credentials';
|
|
5
|
-
import type {
|
|
6
|
-
HttpClient,
|
|
7
|
-
HttpRequest,
|
|
8
|
-
HttpResponse,
|
|
9
|
-
} from '@databricks/sdk-core/http';
|
|
10
|
-
import {newFetchHttpClient} from '@databricks/sdk-core/http';
|
|
11
|
-
import type {ClientOptions} from '@databricks/sdk-options/client';
|
|
12
|
-
|
|
13
|
-
/** Creates a new HTTP client with the given options. */
|
|
14
|
-
export function newHttpClient(options?: ClientOptions): HttpClient {
|
|
15
|
-
const opts = options ?? {};
|
|
16
|
-
|
|
17
|
-
// If an HTTP client is provided, use it as-is. Throw if other options are
|
|
18
|
-
// also set, since they would be silently ignored.
|
|
19
|
-
if (opts.httpClient !== undefined) {
|
|
20
|
-
if (opts.credentials !== undefined || opts.timeout !== undefined) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
'httpClient cannot be combined with credentials or timeout'
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
return opts.httpClient;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const credentials = opts.credentials ?? defaultCredentials();
|
|
29
|
-
|
|
30
|
-
const base = newFetchHttpClient();
|
|
31
|
-
let client: HttpClient = new AuthHttpClient(base, credentials);
|
|
32
|
-
|
|
33
|
-
if (opts.timeout !== undefined) {
|
|
34
|
-
client = new TimeoutHttpClient(client, opts.timeout);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return client;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Wraps an HttpClient and adds authentication headers to requests. */
|
|
41
|
-
class AuthHttpClient implements HttpClient {
|
|
42
|
-
constructor(
|
|
43
|
-
private readonly base: HttpClient,
|
|
44
|
-
private readonly credentials: Credentials
|
|
45
|
-
) {}
|
|
46
|
-
|
|
47
|
-
async send(request: HttpRequest): Promise<HttpResponse> {
|
|
48
|
-
const authHeaders = await this.credentials.authHeaders();
|
|
49
|
-
// Do not modify the original request.
|
|
50
|
-
const headers = new Headers(request.headers);
|
|
51
|
-
for (const h of authHeaders) {
|
|
52
|
-
headers.set(h.key, h.value);
|
|
53
|
-
}
|
|
54
|
-
return this.base.send({...request, headers});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Wraps an HttpClient and applies a default timeout to requests. */
|
|
59
|
-
class TimeoutHttpClient implements HttpClient {
|
|
60
|
-
constructor(
|
|
61
|
-
private readonly base: HttpClient,
|
|
62
|
-
private readonly timeout: number
|
|
63
|
-
) {}
|
|
64
|
-
|
|
65
|
-
async send(request: HttpRequest): Promise<HttpResponse> {
|
|
66
|
-
const timeoutSignal = AbortSignal.timeout(this.timeout);
|
|
67
|
-
const signal =
|
|
68
|
-
request.signal !== undefined
|
|
69
|
-
? AbortSignal.any([request.signal, timeoutSignal])
|
|
70
|
-
: timeoutSignal;
|
|
71
|
-
return this.base.send({...request, signal});
|
|
72
|
-
}
|
|
73
|
-
}
|
package/src/v1/utils.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
|
|
2
|
-
|
|
3
|
-
import type {Options} from '@databricks/sdk-core/ops';
|
|
4
|
-
import {execute} from '@databricks/sdk-core/ops';
|
|
5
|
-
import {ApiError} from '@databricks/sdk-core/apierror';
|
|
6
|
-
import type {
|
|
7
|
-
HttpClient,
|
|
8
|
-
HttpRequest,
|
|
9
|
-
HttpResponse,
|
|
10
|
-
} from '@databricks/sdk-core/http';
|
|
11
|
-
import type {Logger} from '@databricks/sdk-core/logger';
|
|
12
|
-
import type {CallOptions} from '@databricks/sdk-options/call';
|
|
13
|
-
import JSONBig from 'json-bigint';
|
|
14
|
-
import type {z} from 'zod';
|
|
15
|
-
|
|
16
|
-
// JSON codec that preserves int64 precision. On the way in, large integer
|
|
17
|
-
// literals come back as bigint instead of being rounded to JS Number. On the
|
|
18
|
-
// way out, bigint values are emitted as raw JSON number digits.
|
|
19
|
-
const jsonBigint = JSONBig({useNativeBigInt: true});
|
|
20
|
-
|
|
21
|
-
export interface HttpCallOptions {
|
|
22
|
-
readonly request: HttpRequest;
|
|
23
|
-
readonly httpClient: HttpClient;
|
|
24
|
-
readonly logger: Logger;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Translates public CallOptions to the internal Options shape accepted by
|
|
29
|
-
* execute(). Even though the shapes match today, this isolates the public
|
|
30
|
-
* API from the executor's internal type so they can diverge.
|
|
31
|
-
*/
|
|
32
|
-
export async function executeCall(
|
|
33
|
-
call: (signal?: AbortSignal) => Promise<void>,
|
|
34
|
-
options?: CallOptions
|
|
35
|
-
): Promise<void> {
|
|
36
|
-
const opts: Options = {
|
|
37
|
-
...(options?.retrier !== undefined && {retrier: options.retrier}),
|
|
38
|
-
...(options?.rateLimiter !== undefined && {
|
|
39
|
-
rateLimiter: options.rateLimiter,
|
|
40
|
-
}),
|
|
41
|
-
...(options?.timeout !== undefined && {timeout: options.timeout}),
|
|
42
|
-
};
|
|
43
|
-
return execute(options?.signal, call, opts);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function readAll(
|
|
47
|
-
body: ReadableStream<Uint8Array> | null
|
|
48
|
-
): Promise<Uint8Array> {
|
|
49
|
-
if (body === null) {
|
|
50
|
-
return new Uint8Array(0);
|
|
51
|
-
}
|
|
52
|
-
const reader = body.getReader();
|
|
53
|
-
const chunks: Uint8Array[] = [];
|
|
54
|
-
for (;;) {
|
|
55
|
-
const {done, value} = await reader.read();
|
|
56
|
-
if (done) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
chunks.push(value);
|
|
60
|
-
}
|
|
61
|
-
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
62
|
-
const result = new Uint8Array(totalLength);
|
|
63
|
-
let offset = 0;
|
|
64
|
-
for (const chunk of chunks) {
|
|
65
|
-
result.set(chunk, offset);
|
|
66
|
-
offset += chunk.length;
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export async function executeHttpCall(
|
|
72
|
-
opts: HttpCallOptions
|
|
73
|
-
): Promise<Uint8Array> {
|
|
74
|
-
opts.logger.debug('HTTP request', {
|
|
75
|
-
method: opts.request.method,
|
|
76
|
-
url: opts.request.url,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
let resp: HttpResponse;
|
|
80
|
-
try {
|
|
81
|
-
resp = await opts.httpClient.send(opts.request);
|
|
82
|
-
} catch (e: unknown) {
|
|
83
|
-
opts.logger.debug('HTTP request failed');
|
|
84
|
-
throw e;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const body = await readAll(resp.body);
|
|
88
|
-
|
|
89
|
-
opts.logger.debug('HTTP response', {
|
|
90
|
-
statusCode: resp.statusCode,
|
|
91
|
-
body: new TextDecoder().decode(body),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
|
|
95
|
-
if (apiErr !== undefined) {
|
|
96
|
-
throw apiErr;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return body;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function buildHttpRequest(
|
|
103
|
-
method: string,
|
|
104
|
-
url: string,
|
|
105
|
-
headers: Headers,
|
|
106
|
-
signal?: AbortSignal,
|
|
107
|
-
body?: string | ReadableStream<Uint8Array>
|
|
108
|
-
): HttpRequest {
|
|
109
|
-
const req: HttpRequest = {url, method, headers};
|
|
110
|
-
if (body !== undefined) {
|
|
111
|
-
req.body = body;
|
|
112
|
-
}
|
|
113
|
-
if (signal !== undefined) {
|
|
114
|
-
req.signal = signal;
|
|
115
|
-
}
|
|
116
|
-
return req;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T {
|
|
120
|
-
const text = new TextDecoder().decode(body);
|
|
121
|
-
const parsed: unknown = jsonBigint.parse(text);
|
|
122
|
-
return schema.parse(parsed);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function marshalRequest(data: unknown, schema: z.ZodType): string {
|
|
126
|
-
return jsonBigint.stringify(schema.parse(data));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function flattenQueryParams(
|
|
130
|
-
prefix: string,
|
|
131
|
-
value: unknown,
|
|
132
|
-
params: URLSearchParams
|
|
133
|
-
): void {
|
|
134
|
-
if (value === null || value === undefined) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (Array.isArray(value)) {
|
|
138
|
-
// arrays of objects are not yet supported
|
|
139
|
-
for (const item of value) {
|
|
140
|
-
params.append(prefix, String(item));
|
|
141
|
-
}
|
|
142
|
-
} else if (typeof value === 'object') {
|
|
143
|
-
for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
|
|
144
|
-
flattenQueryParams(`${prefix}.${key}`, val, params);
|
|
145
|
-
}
|
|
146
|
-
} else if (
|
|
147
|
-
typeof value === 'string' ||
|
|
148
|
-
typeof value === 'number' ||
|
|
149
|
-
typeof value === 'boolean' ||
|
|
150
|
-
typeof value === 'bigint'
|
|
151
|
-
) {
|
|
152
|
-
params.append(prefix, String(value));
|
|
153
|
-
} else {
|
|
154
|
-
throw new Error(`Unsupported query parameter type: ${typeof value}`);
|
|
155
|
-
}
|
|
156
|
-
}
|