0.0.20240430 • Published 3 days ago

@maxim_mazurok/gapi.client.pubsub-v1beta1a v0.0.20240430

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

TypeScript typings for Cloud Pub/Sub API v1beta1a

Provides reliable, many-to-many, asynchronous messaging between applications. For detailed description please check documentation.

Installing

Install typings for Cloud Pub/Sub API:

npm install @types/gapi.client.pubsub-v1beta1a --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://pubsub.googleapis.com/$discovery/rest?version=v1beta1a',
  () => {
    // now we can use:
    // gapi.client.pubsub
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('pubsub', 'v1beta1a', () => {
  // now we can use:
  // gapi.client.pubsub
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
    'https://www.googleapis.com/auth/cloud-platform',

    // View and manage Pub/Sub topics and subscriptions
    'https://www.googleapis.com/auth/pubsub',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Cloud Pub/Sub API resources:

/*
Acknowledges a particular received message: the Pub/Sub system can remove the given message from the subscription. Acknowledging a message whose Ack deadline has expired may succeed, but the message could have been already redelivered. Acknowledging a message more than once will not result in an error. This is only used for messages received via pull.
*/
await gapi.client.pubsub.subscriptions.acknowledge({});

/*
Creates a subscription on a given topic for a given subscriber. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic.
*/
await gapi.client.pubsub.subscriptions.create({});

/*
Deletes an existing subscription. All pending messages in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND.
*/
await gapi.client.pubsub.subscriptions.delete({subscription: 'subscription'});

/*
Gets the configuration details of a subscription.
*/
await gapi.client.pubsub.subscriptions.get({subscription: 'subscription'});

/*
Lists matching subscriptions.
*/
await gapi.client.pubsub.subscriptions.list({});

/*
Modifies the Ack deadline for a message received from a pull request.
*/
await gapi.client.pubsub.subscriptions.modifyAckDeadline({});

/*
Modifies the PushConfig for a specified subscription. This method can be used to suspend the flow of messages to an endpoint by clearing the PushConfig field in the request. Messages will be accumulated for delivery even if no push configuration is defined or while the configuration is modified.
*/
await gapi.client.pubsub.subscriptions.modifyPushConfig({});

/*
Pulls a single message from the server. If return_immediately is true, and no messages are available in the subscription, this method returns FAILED_PRECONDITION. The system is free to return an UNAVAILABLE error if no messages are available in a reasonable amount of time (to reduce system load).
*/
await gapi.client.pubsub.subscriptions.pull({});

/*
Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The system is free to return UNAVAILABLE if there are too many pull requests outstanding for the given subscription.
*/
await gapi.client.pubsub.subscriptions.pullBatch({});

/*
Creates the given topic with the given name.
*/
await gapi.client.pubsub.topics.create({});

/*
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.
*/
await gapi.client.pubsub.topics.delete({topic: 'topic'});

/*
Gets the configuration of a topic. Since the topic only has the name attribute, this method is only useful to check the existence of a topic. If other attributes are added in the future, they will be returned here.
*/
await gapi.client.pubsub.topics.get({topic: 'topic'});

/*
Lists matching topics.
*/
await gapi.client.pubsub.topics.list({});

/*
Adds a message to the topic. Returns NOT_FOUND if the topic does not exist.
*/
await gapi.client.pubsub.topics.publish({});

/*
Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.
*/
await gapi.client.pubsub.topics.publishBatch({});
0.0.20240430

3 days ago

0.0.20240423

10 days ago

0.0.20240416

17 days ago

0.0.20240409

24 days ago

0.0.20240319

1 month ago

0.0.20240312

2 months ago

0.0.20240305

2 months ago

0.0.20240227

2 months ago

0.0.20240220

3 months ago

0.0.20240208

3 months ago

0.0.20240201

3 months ago

0.0.20240126

3 months ago

0.0.20240109

4 months ago

0.0.20240122

4 months ago

0.0.20240102

4 months ago

0.0.20231226

4 months ago

0.0.20231212

5 months ago

0.0.20231211

5 months ago

0.0.20231205

5 months ago

0.0.20231128

5 months ago

0.0.20231107

6 months ago

0.0.20230928

7 months ago

0.0.20230921

8 months ago

0.0.20231019

7 months ago

0.0.20230801

9 months ago

0.0.20230725

9 months ago

0.0.20231024

6 months ago

0.0.20231104

6 months ago

0.0.20230718

10 months ago

0.0.20230711

10 months ago

0.0.20230830

8 months ago

0.0.20230912

8 months ago

0.0.20231010

7 months ago

0.0.20230905

8 months ago

0.0.20230627

10 months ago

0.0.20231121

5 months ago

0.0.20231003

7 months ago

0.0.20230620

11 months ago

0.0.20230613

11 months ago

0.0.20230516

12 months ago

0.0.20230509

12 months ago

0.0.20230425

1 year ago

0.0.20230523

12 months ago

0.0.20230606

11 months ago

0.0.20230529

11 months ago

0.0.20230505

1 year ago

0.0.20230418

1 year ago

0.0.20230317

1 year ago

0.0.20230224

1 year ago

0.0.20230321

1 year ago

0.0.20230404

1 year ago

0.0.20230328

1 year ago

0.0.20230306

1 year ago

0.0.20230329

1 year ago

0.0.20230307

1 year ago

0.0.20230411

1 year ago

0.0.20230214

1 year ago

0.0.20230218

1 year ago

0.0.20230124

1 year ago

0.0.20230131

1 year ago

0.0.20221226

1 year ago

0.0.20221201

1 year ago

0.0.20221101

2 years ago

0.0.20221122

1 year ago

0.0.20230119

1 year ago

0.0.20230102

1 year ago

0.0.20221206

1 year ago

0.0.20230112

1 year ago

0.0.20221020

2 years ago

0.0.20221028

2 years ago

0.0.20220926

2 years ago

0.0.20220829

2 years ago

0.0.20220920

2 years ago

0.0.20220912

2 years ago

0.0.20220824

2 years ago

0.0.20220904

2 years ago

0.0.20220816

2 years ago

0.0.20220808

2 years ago

0.0.20220729

2 years ago