@maxim_mazurok/gapi.client.pubsub-v1beta2 0.0.20220729

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/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.pubsub-v1beta2",
3
+ "version": "0.0.20220729",
4
+ "description": "TypeScript typings for Cloud Pub/Sub API v1beta2",
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,71 @@
1
+ # TypeScript typings for Cloud Pub/Sub API v1beta2
2
+
3
+ Provides reliable, many-to-many, asynchronous messaging between applications.
4
+ For detailed description please check [documentation](https://cloud.google.com/pubsub/docs).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Cloud Pub/Sub API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.pubsub-v1beta2 --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://pubsub.googleapis.com/$discovery/rest?version=v1beta2', () => {
29
+ // now we can use:
30
+ // gapi.client.pubsub
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('pubsub', 'v1beta2', () => {
37
+ // now we can use:
38
+ // gapi.client.pubsub
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
+ // View and manage Pub/Sub topics and subscriptions
52
+ 'https://www.googleapis.com/auth/pubsub',
53
+ ],
54
+ immediate = true;
55
+ // ...
56
+
57
+ gapi.auth.authorize(
58
+ { client_id: client_id, scope: scope, immediate: immediate },
59
+ authResult => {
60
+ if (authResult && !authResult.error) {
61
+ /* handle successful authorization */
62
+ } else {
63
+ /* handle authorization error */
64
+ }
65
+ });
66
+ ```
67
+
68
+ After that you can use Cloud Pub/Sub API resources: <!-- TODO: make this work for multiple namespaces -->
69
+
70
+ ```typescript
71
+ ```
package/tests.ts ADDED
@@ -0,0 +1,250 @@
1
+ /* This is stub file for gapi.client.pubsub-v1beta2 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: 20220729
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://pubsub.googleapis.com/$discovery/rest?version=v1beta2');
12
+ /** now we can use gapi.client.pubsub */
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
+ /** View and manage Pub/Sub topics and subscriptions */
21
+ 'https://www.googleapis.com/auth/pubsub',
22
+ ];
23
+ const immediate = false;
24
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
25
+ if (authResult && !authResult.error) {
26
+ /** handle successful authorization */
27
+ run();
28
+ } else {
29
+ /** handle authorization error */
30
+ }
31
+ });
32
+
33
+ async function run() {
34
+ /**
35
+ * Acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message
36
+ * whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.
37
+ */
38
+ await gapi.client.pubsub.projects.subscriptions.acknowledge({
39
+ subscription: "Test string",
40
+ }, {
41
+ ackIds: [
42
+ "Test string"
43
+ ],
44
+ });
45
+ /**
46
+ * Creates a subscription to a given topic. If the subscription already exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns `NOT_FOUND`. If the name is not
47
+ * provided in the request, the server will assign a random name for this subscription on the same project as the topic. Note that for REST API requests, you must specify a name.
48
+ */
49
+ await gapi.client.pubsub.projects.subscriptions.create({
50
+ name: "Test string",
51
+ }, {
52
+ ackDeadlineSeconds: 42,
53
+ name: "Test string",
54
+ pushConfig: {
55
+ attributes: {
56
+ A: "Test string"
57
+ },
58
+ oidcToken: {
59
+ audience: "Test string",
60
+ serviceAccountEmail: "Test string",
61
+ },
62
+ pushEndpoint: "Test string",
63
+ },
64
+ topic: "Test string",
65
+ });
66
+ /**
67
+ * Deletes an existing subscription. All pending messages in the subscription are immediately dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is
68
+ * deleted, a new one may be created with the same name, but the new one has no association with the old subscription, or its topic unless the same topic is specified.
69
+ */
70
+ await gapi.client.pubsub.projects.subscriptions.delete({
71
+ subscription: "Test string",
72
+ });
73
+ /** Gets the configuration details of a subscription. */
74
+ await gapi.client.pubsub.projects.subscriptions.get({
75
+ subscription: "Test string",
76
+ });
77
+ /** Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. */
78
+ await gapi.client.pubsub.projects.subscriptions.getIamPolicy({
79
+ "options.requestedPolicyVersion": 42,
80
+ resource: "Test string",
81
+ });
82
+ /** Lists matching subscriptions. */
83
+ await gapi.client.pubsub.projects.subscriptions.list({
84
+ pageSize: 42,
85
+ pageToken: "Test string",
86
+ project: "Test string",
87
+ });
88
+ /**
89
+ * Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for
90
+ * redelivery if the processing was interrupted. Note that this does not modify the subscription-level `ackDeadlineSeconds` used for subsequent messages.
91
+ */
92
+ await gapi.client.pubsub.projects.subscriptions.modifyAckDeadline({
93
+ subscription: "Test string",
94
+ }, {
95
+ ackDeadlineSeconds: 42,
96
+ ackId: "Test string",
97
+ ackIds: [
98
+ "Test string"
99
+ ],
100
+ });
101
+ /**
102
+ * Modifies the `PushConfig` for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty `PushConfig`) or vice versa, or change the
103
+ * endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the `PushConfig`.
104
+ */
105
+ await gapi.client.pubsub.projects.subscriptions.modifyPushConfig({
106
+ subscription: "Test string",
107
+ }, {
108
+ pushConfig: {
109
+ attributes: {
110
+ A: "Test string"
111
+ },
112
+ oidcToken: {
113
+ audience: "Test string",
114
+ serviceAccountEmail: "Test string",
115
+ },
116
+ pushEndpoint: "Test string",
117
+ },
118
+ });
119
+ /**
120
+ * Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return `UNAVAILABLE` if there are too many concurrent pull
121
+ * requests pending for the given subscription.
122
+ */
123
+ await gapi.client.pubsub.projects.subscriptions.pull({
124
+ subscription: "Test string",
125
+ }, {
126
+ maxMessages: 42,
127
+ returnImmediately: true,
128
+ });
129
+ /** Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. */
130
+ await gapi.client.pubsub.projects.subscriptions.setIamPolicy({
131
+ resource: "Test string",
132
+ }, {
133
+ policy: {
134
+ bindings: [
135
+ {
136
+ condition: {
137
+ description: "Test string",
138
+ expression: "Test string",
139
+ location: "Test string",
140
+ title: "Test string",
141
+ },
142
+ members: [
143
+ "Test string"
144
+ ],
145
+ role: "Test string",
146
+ }
147
+ ],
148
+ etag: "Test string",
149
+ version: 42,
150
+ },
151
+ });
152
+ /**
153
+ * Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This
154
+ * operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
155
+ */
156
+ await gapi.client.pubsub.projects.subscriptions.testIamPermissions({
157
+ resource: "Test string",
158
+ }, {
159
+ permissions: [
160
+ "Test string"
161
+ ],
162
+ });
163
+ /** Creates the given topic with the given name. */
164
+ await gapi.client.pubsub.projects.topics.create({
165
+ name: "Test string",
166
+ }, {
167
+ name: "Test string",
168
+ });
169
+ /**
170
+ * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new
171
+ * topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.
172
+ */
173
+ await gapi.client.pubsub.projects.topics.delete({
174
+ topic: "Test string",
175
+ });
176
+ /** Gets the configuration of a topic. */
177
+ await gapi.client.pubsub.projects.topics.get({
178
+ topic: "Test string",
179
+ });
180
+ /** Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. */
181
+ await gapi.client.pubsub.projects.topics.getIamPolicy({
182
+ "options.requestedPolicyVersion": 42,
183
+ resource: "Test string",
184
+ });
185
+ /** Lists matching topics. */
186
+ await gapi.client.pubsub.projects.topics.list({
187
+ pageSize: 42,
188
+ pageToken: "Test string",
189
+ project: "Test string",
190
+ });
191
+ /**
192
+ * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist. The message payload must not be empty; it must contain either a non-empty data field, or at
193
+ * least one attribute.
194
+ */
195
+ await gapi.client.pubsub.projects.topics.publish({
196
+ topic: "Test string",
197
+ }, {
198
+ messages: [
199
+ {
200
+ attributes: {
201
+ A: "Test string"
202
+ },
203
+ data: "Test string",
204
+ messageId: "Test string",
205
+ publishTime: "Test string",
206
+ }
207
+ ],
208
+ });
209
+ /** Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. */
210
+ await gapi.client.pubsub.projects.topics.setIamPolicy({
211
+ resource: "Test string",
212
+ }, {
213
+ policy: {
214
+ bindings: [
215
+ {
216
+ condition: {
217
+ description: "Test string",
218
+ expression: "Test string",
219
+ location: "Test string",
220
+ title: "Test string",
221
+ },
222
+ members: [
223
+ "Test string"
224
+ ],
225
+ role: "Test string",
226
+ }
227
+ ],
228
+ etag: "Test string",
229
+ version: 42,
230
+ },
231
+ });
232
+ /**
233
+ * Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This
234
+ * operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
235
+ */
236
+ await gapi.client.pubsub.projects.topics.testIamPermissions({
237
+ resource: "Test string",
238
+ }, {
239
+ permissions: [
240
+ "Test string"
241
+ ],
242
+ });
243
+ /** Lists the name of the subscriptions for this topic. */
244
+ await gapi.client.pubsub.projects.topics.subscriptions.list({
245
+ pageSize: 42,
246
+ pageToken: "Test string",
247
+ topic: "Test string",
248
+ });
249
+ }
250
+ });
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
+ }