@maxim_mazurok/gapi.client.cloudtrace-v2beta1 0.0.20220728

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/index.d.ts ADDED
@@ -0,0 +1,303 @@
1
+ /* Type definitions for non-npm package Cloud Trace API v2beta1 0.0 */
2
+ // Project: https://cloud.google.com/trace
3
+ // Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
4
+ // Nick Amoscato <https://github.com/namoscato>
5
+ // Declan Vong <https://github.com/declanvong>
6
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
+ // TypeScript Version: 2.8
8
+
9
+ // IMPORTANT
10
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
11
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
12
+ // Generated from: https://cloudtrace.googleapis.com/$discovery/rest?version=v2beta1
13
+ // Revision: 20220728
14
+
15
+ /// <reference types="gapi.client" />
16
+
17
+ declare namespace gapi.client {
18
+ /** Load Cloud Trace API v2beta1 */
19
+ function load(urlOrObject: "https://cloudtrace.googleapis.com/$discovery/rest?version=v2beta1"): Promise<void>;
20
+ /** @deprecated Please load APIs with discovery documents. */
21
+ function load(name: "cloudtrace", version: "v2beta1"): Promise<void>;
22
+ /** @deprecated Please load APIs with discovery documents. */
23
+ function load(name: "cloudtrace", version: "v2beta1", callback: () => any): void;
24
+
25
+ namespace cloudtrace {
26
+ // tslint:disable-next-line:no-empty-interface
27
+ interface Empty {
28
+ }
29
+ interface ListTraceSinksResponse {
30
+ /**
31
+ * A paginated response where more pages might be available has `next_page_token` set. To get the next set of results, call the same method again using the value of `next_page_token`
32
+ * as `page_token`.
33
+ */
34
+ nextPageToken?: string;
35
+ /** A list of sinks. */
36
+ sinks?: TraceSink[];
37
+ }
38
+ interface OutputConfig {
39
+ /** The destination for writing trace data. Supported formats include: "bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]" */
40
+ destination?: string;
41
+ }
42
+ interface TraceSink {
43
+ /**
44
+ * Required. The canonical sink resource name, unique within the project. Must be of the form: projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]. E.g.:
45
+ * `"projects/12345/traceSinks/my-project-trace-sink"`. Sink identifiers are limited to 256 characters and can include only the following characters: upper and lower-case alphanumeric
46
+ * characters, underscores, hyphens, and periods.
47
+ */
48
+ name?: string;
49
+ /** Required. The export destination. */
50
+ outputConfig?: OutputConfig;
51
+ /**
52
+ * Output only. A service account name for exporting the data. This field is set by sinks.create and sinks.update. The service account will need to be granted write access to the
53
+ * destination specified in the output configuration, see [Granting access for a
54
+ * resource](/iam/docs/granting-roles-to-service-accounts#granting_access_to_a_service_account_for_a_resource). To create tables and to write data, this account needs the `dataEditor`
55
+ * role. Read more about roles in the [BigQuery documentation](https://cloud.google.com/bigquery/docs/access-control). E.g.: "service-00000001@00000002.iam.gserviceaccount.com"
56
+ */
57
+ writerIdentity?: string;
58
+ }
59
+ interface TraceSinksResource {
60
+ /**
61
+ * Creates a sink that exports trace spans to a destination. The export of newly-ingested traces begins immediately, unless the sink's `writer_identity` is not permitted to write to
62
+ * the destination. A sink can export traces only from the resource owning the sink (the 'parent').
63
+ */
64
+ create(request: {
65
+ /** V1 error format. */
66
+ "$.xgafv"?: string;
67
+ /** OAuth access token. */
68
+ access_token?: string;
69
+ /** Data format for response. */
70
+ alt?: string;
71
+ /** JSONP */
72
+ callback?: string;
73
+ /** Selector specifying which fields to include in a partial response. */
74
+ fields?: string;
75
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
76
+ key?: string;
77
+ /** OAuth 2.0 token for the current user. */
78
+ oauth_token?: string;
79
+ /**
80
+ * Required. The resource in which to create the sink (currently only project sinks are supported): "projects/[PROJECT_ID]" Examples: `"projects/my-trace-project"`,
81
+ * `"projects/123456789"`.
82
+ */
83
+ parent: string;
84
+ /** Returns response with indentations and line breaks. */
85
+ prettyPrint?: boolean;
86
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
87
+ quotaUser?: string;
88
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
89
+ upload_protocol?: string;
90
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
91
+ uploadType?: string;
92
+ /** Request body */
93
+ resource: TraceSink;
94
+ }): Request<TraceSink>;
95
+ create(request: {
96
+ /** V1 error format. */
97
+ "$.xgafv"?: string;
98
+ /** OAuth access token. */
99
+ access_token?: string;
100
+ /** Data format for response. */
101
+ alt?: string;
102
+ /** JSONP */
103
+ callback?: string;
104
+ /** Selector specifying which fields to include in a partial response. */
105
+ fields?: string;
106
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
107
+ key?: string;
108
+ /** OAuth 2.0 token for the current user. */
109
+ oauth_token?: string;
110
+ /**
111
+ * Required. The resource in which to create the sink (currently only project sinks are supported): "projects/[PROJECT_ID]" Examples: `"projects/my-trace-project"`,
112
+ * `"projects/123456789"`.
113
+ */
114
+ parent: string;
115
+ /** Returns response with indentations and line breaks. */
116
+ prettyPrint?: boolean;
117
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
118
+ quotaUser?: string;
119
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
120
+ upload_protocol?: string;
121
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
122
+ uploadType?: string;
123
+ },
124
+ body: TraceSink): Request<TraceSink>;
125
+ /** Deletes a sink. */
126
+ delete(request?: {
127
+ /** V1 error format. */
128
+ "$.xgafv"?: string;
129
+ /** OAuth access token. */
130
+ access_token?: string;
131
+ /** Data format for response. */
132
+ alt?: string;
133
+ /** JSONP */
134
+ callback?: string;
135
+ /** Selector specifying which fields to include in a partial response. */
136
+ fields?: string;
137
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
138
+ key?: string;
139
+ /**
140
+ * Required. The full resource name of the sink to delete, including the parent resource and the sink identifier: "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example:
141
+ * `"projects/12345/traceSinks/my-sink-id"`.
142
+ */
143
+ name: string;
144
+ /** OAuth 2.0 token for the current user. */
145
+ oauth_token?: string;
146
+ /** Returns response with indentations and line breaks. */
147
+ prettyPrint?: boolean;
148
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
149
+ quotaUser?: string;
150
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
151
+ upload_protocol?: string;
152
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
153
+ uploadType?: string;
154
+ }): Request<{}>;
155
+ /** Get a trace sink by name under the parent resource (GCP project). */
156
+ get(request?: {
157
+ /** V1 error format. */
158
+ "$.xgafv"?: string;
159
+ /** OAuth access token. */
160
+ access_token?: string;
161
+ /** Data format for response. */
162
+ alt?: string;
163
+ /** JSONP */
164
+ callback?: string;
165
+ /** Selector specifying which fields to include in a partial response. */
166
+ fields?: string;
167
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
168
+ key?: string;
169
+ /** Required. The resource name of the sink: "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example: `"projects/12345/traceSinks/my-sink-id"`. */
170
+ name: string;
171
+ /** OAuth 2.0 token for the current user. */
172
+ oauth_token?: string;
173
+ /** Returns response with indentations and line breaks. */
174
+ prettyPrint?: boolean;
175
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
176
+ quotaUser?: string;
177
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
178
+ upload_protocol?: string;
179
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
180
+ uploadType?: string;
181
+ }): Request<TraceSink>;
182
+ /** List all sinks for the parent resource (GCP project). */
183
+ list(request?: {
184
+ /** V1 error format. */
185
+ "$.xgafv"?: string;
186
+ /** OAuth access token. */
187
+ access_token?: string;
188
+ /** Data format for response. */
189
+ alt?: string;
190
+ /** JSONP */
191
+ callback?: string;
192
+ /** Selector specifying which fields to include in a partial response. */
193
+ fields?: string;
194
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
195
+ key?: string;
196
+ /** OAuth 2.0 token for the current user. */
197
+ oauth_token?: string;
198
+ /**
199
+ * Optional. The maximum number of results to return from this request. Non-positive values are ignored. The presence of `next_page_token` in the response indicates that more
200
+ * results might be available.
201
+ */
202
+ pageSize?: number;
203
+ /**
204
+ * Optional. If present, then retrieve the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous
205
+ * response. The values of other method parameters should be identical to those in the previous call.
206
+ */
207
+ pageToken?: string;
208
+ /** Required. The parent resource whose sinks are to be listed (currently only project parent resources are supported): "projects/[PROJECT_ID]" */
209
+ parent: string;
210
+ /** Returns response with indentations and line breaks. */
211
+ prettyPrint?: boolean;
212
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
213
+ quotaUser?: string;
214
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
215
+ upload_protocol?: string;
216
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
217
+ uploadType?: string;
218
+ }): Request<ListTraceSinksResponse>;
219
+ /**
220
+ * Updates a sink. This method updates fields in the existing sink according to the provided update mask. The sink's name cannot be changed nor any output-only fields (e.g. the
221
+ * writer_identity).
222
+ */
223
+ patch(request: {
224
+ /** V1 error format. */
225
+ "$.xgafv"?: string;
226
+ /** OAuth access token. */
227
+ access_token?: string;
228
+ /** Data format for response. */
229
+ alt?: string;
230
+ /** JSONP */
231
+ callback?: string;
232
+ /** Selector specifying which fields to include in a partial response. */
233
+ fields?: string;
234
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
235
+ key?: string;
236
+ /**
237
+ * Required. The full resource name of the sink to update, including the parent resource and the sink identifier: "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example:
238
+ * `"projects/12345/traceSinks/my-sink-id"`.
239
+ */
240
+ name: string;
241
+ /** OAuth 2.0 token for the current user. */
242
+ oauth_token?: string;
243
+ /** Returns response with indentations and line breaks. */
244
+ prettyPrint?: boolean;
245
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
246
+ quotaUser?: string;
247
+ /**
248
+ * Required. Field mask that specifies the fields in `trace_sink` that are to be updated. A sink field is overwritten if, and only if, it is in the update mask. `name` and
249
+ * `writer_identity` fields cannot be updated. An empty `update_mask` is considered an error. For a detailed `FieldMask` definition, see
250
+ * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask Example: `updateMask=output_config`.
251
+ */
252
+ updateMask?: string;
253
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
254
+ upload_protocol?: string;
255
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
256
+ uploadType?: string;
257
+ /** Request body */
258
+ resource: TraceSink;
259
+ }): Request<TraceSink>;
260
+ patch(request: {
261
+ /** V1 error format. */
262
+ "$.xgafv"?: string;
263
+ /** OAuth access token. */
264
+ access_token?: string;
265
+ /** Data format for response. */
266
+ alt?: string;
267
+ /** JSONP */
268
+ callback?: string;
269
+ /** Selector specifying which fields to include in a partial response. */
270
+ fields?: string;
271
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
272
+ key?: string;
273
+ /**
274
+ * Required. The full resource name of the sink to update, including the parent resource and the sink identifier: "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example:
275
+ * `"projects/12345/traceSinks/my-sink-id"`.
276
+ */
277
+ name: string;
278
+ /** OAuth 2.0 token for the current user. */
279
+ oauth_token?: string;
280
+ /** Returns response with indentations and line breaks. */
281
+ prettyPrint?: boolean;
282
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
283
+ quotaUser?: string;
284
+ /**
285
+ * Required. Field mask that specifies the fields in `trace_sink` that are to be updated. A sink field is overwritten if, and only if, it is in the update mask. `name` and
286
+ * `writer_identity` fields cannot be updated. An empty `update_mask` is considered an error. For a detailed `FieldMask` definition, see
287
+ * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask Example: `updateMask=output_config`.
288
+ */
289
+ updateMask?: string;
290
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
291
+ upload_protocol?: string;
292
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
293
+ uploadType?: string;
294
+ },
295
+ body: TraceSink): Request<TraceSink>;
296
+ }
297
+ interface ProjectsResource {
298
+ traceSinks: TraceSinksResource;
299
+ }
300
+
301
+ const projects: ProjectsResource;
302
+ }
303
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.cloudtrace-v2beta1",
3
+ "version": "0.0.20220728",
4
+ "description": "TypeScript typings for Cloud Trace API v2beta1",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,74 @@
1
+ # TypeScript typings for Cloud Trace API v2beta1
2
+
3
+ Sends application trace data to Cloud Trace for viewing. Trace data is collected for all App Engine applications by default. Trace data from other applications can be provided using this API. This library is used to interact with the Cloud Trace API directly. If you are looking to instrument your application for Cloud Trace, we recommend using OpenTelemetry.
4
+ For detailed description please check [documentation](https://cloud.google.com/trace).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Cloud Trace API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.cloudtrace-v2beta1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://cloudtrace.googleapis.com/$discovery/rest?version=v2beta1', () => {
29
+ // now we can use:
30
+ // gapi.client.cloudtrace
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('cloudtrace', 'v2beta1', () => {
37
+ // now we can use:
38
+ // gapi.client.cloudtrace
39
+ });
40
+ ```
41
+
42
+ Don't forget to authenticate your client before sending any request to resources:
43
+
44
+ ```typescript
45
+ // declare client_id registered in Google Developers Console
46
+ var client_id = '',
47
+ scope = [
48
+ // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
49
+ 'https://www.googleapis.com/auth/cloud-platform',
50
+
51
+ // Write Trace data for a project or application
52
+ 'https://www.googleapis.com/auth/trace.append',
53
+
54
+ // Read Trace data for a project or application
55
+ 'https://www.googleapis.com/auth/trace.readonly',
56
+ ],
57
+ immediate = true;
58
+ // ...
59
+
60
+ gapi.auth.authorize(
61
+ { client_id: client_id, scope: scope, immediate: immediate },
62
+ authResult => {
63
+ if (authResult && !authResult.error) {
64
+ /* handle successful authorization */
65
+ } else {
66
+ /* handle authorization error */
67
+ }
68
+ });
69
+ ```
70
+
71
+ After that you can use Cloud Trace API resources: <!-- TODO: make this work for multiple namespaces -->
72
+
73
+ ```typescript
74
+ ```
package/tests.ts ADDED
@@ -0,0 +1,78 @@
1
+ /* This is stub file for gapi.client.cloudtrace-v2beta1 definition tests */
2
+ // IMPORTANT
3
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
4
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
5
+
6
+ // Revision: 20220728
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://cloudtrace.googleapis.com/$discovery/rest?version=v2beta1');
12
+ /** now we can use gapi.client.cloudtrace */
13
+
14
+ /** don't forget to authenticate your client before sending any request to resources: */
15
+ /** declare client_id registered in Google Developers Console */
16
+ const client_id = '<<PUT YOUR CLIENT ID HERE>>';
17
+ const scope = [
18
+ /** See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. */
19
+ 'https://www.googleapis.com/auth/cloud-platform',
20
+ /** Write Trace data for a project or application */
21
+ 'https://www.googleapis.com/auth/trace.append',
22
+ /** Read Trace data for a project or application */
23
+ 'https://www.googleapis.com/auth/trace.readonly',
24
+ ];
25
+ const immediate = false;
26
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
27
+ if (authResult && !authResult.error) {
28
+ /** handle successful authorization */
29
+ run();
30
+ } else {
31
+ /** handle authorization error */
32
+ }
33
+ });
34
+
35
+ async function run() {
36
+ /**
37
+ * Creates a sink that exports trace spans to a destination. The export of newly-ingested traces begins immediately, unless the sink's `writer_identity` is not permitted to write to the
38
+ * destination. A sink can export traces only from the resource owning the sink (the 'parent').
39
+ */
40
+ await gapi.client.cloudtrace.projects.traceSinks.create({
41
+ parent: "Test string",
42
+ }, {
43
+ name: "Test string",
44
+ outputConfig: {
45
+ destination: "Test string",
46
+ },
47
+ writerIdentity: "Test string",
48
+ });
49
+ /** Deletes a sink. */
50
+ await gapi.client.cloudtrace.projects.traceSinks.delete({
51
+ name: "Test string",
52
+ });
53
+ /** Get a trace sink by name under the parent resource (GCP project). */
54
+ await gapi.client.cloudtrace.projects.traceSinks.get({
55
+ name: "Test string",
56
+ });
57
+ /** List all sinks for the parent resource (GCP project). */
58
+ await gapi.client.cloudtrace.projects.traceSinks.list({
59
+ pageSize: 42,
60
+ pageToken: "Test string",
61
+ parent: "Test string",
62
+ });
63
+ /**
64
+ * Updates a sink. This method updates fields in the existing sink according to the provided update mask. The sink's name cannot be changed nor any output-only fields (e.g. the
65
+ * writer_identity).
66
+ */
67
+ await gapi.client.cloudtrace.projects.traceSinks.patch({
68
+ name: "Test string",
69
+ updateMask: "Test string",
70
+ }, {
71
+ name: "Test string",
72
+ outputConfig: {
73
+ destination: "Test string",
74
+ },
75
+ writerIdentity: "Test string",
76
+ });
77
+ }
78
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6", "dom"],
5
+ "noImplicitAny": true,
6
+ "noImplicitThis": true,
7
+ "strictNullChecks": true,
8
+ "baseUrl": "../",
9
+ "typeRoots": [
10
+ "../"
11
+ ],
12
+ "types": [],
13
+ "noEmit": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "strictFunctionTypes": true
16
+ },
17
+ "files": ["index.d.ts", "tests.ts"]
18
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }