0.0.20241022 • Published 8 months ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months 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.20241022

8 months ago

0.0.20241021

9 months ago

0.0.20240924

9 months ago

0.0.20241003

9 months ago

0.0.20241008

9 months ago

0.0.20240918

10 months ago

0.0.20240912

10 months ago

0.0.20240903

10 months ago

0.0.20240829

10 months ago

0.0.20240607

1 year ago

0.0.20240806

11 months ago

0.0.20240528

1 year ago

0.0.20240521

1 year ago

0.0.20240722

11 months ago

0.0.20240618

1 year ago

0.0.20240613

1 year ago

0.0.20240813

11 months ago

0.0.20240730

11 months ago

0.0.20240702

12 months ago

0.0.20240820

11 months ago

0.0.20240716

12 months ago

0.0.20240711

12 months ago

0.0.20240514

1 year ago

0.0.20240507

1 year ago

0.0.20240430

1 year ago

0.0.20240423

1 year ago

0.0.20240416

1 year ago

0.0.20240409

1 year ago

0.0.20240319

1 year ago

0.0.20240312

1 year ago

0.0.20240305

1 year ago

0.0.20240227

1 year ago

0.0.20240220

1 year ago

0.0.20240208

1 year ago

0.0.20240201

1 year ago

0.0.20240126

1 year ago

0.0.20240109

1 year ago

0.0.20240122

1 year ago

0.0.20240102

1 year ago

0.0.20231226

2 years ago

0.0.20231212

2 years ago

0.0.20231211

2 years ago

0.0.20231205

2 years ago

0.0.20231128

2 years ago

0.0.20231107

2 years ago

0.0.20230928

2 years ago

0.0.20230921

2 years ago

0.0.20231019

2 years ago

0.0.20230801

2 years ago

0.0.20230725

2 years ago

0.0.20231024

2 years ago

0.0.20231104

2 years ago

0.0.20230718

2 years ago

0.0.20230711

2 years ago

0.0.20230830

2 years ago

0.0.20230912

2 years ago

0.0.20231010

2 years ago

0.0.20230905

2 years ago

0.0.20230627

2 years ago

0.0.20231121

2 years ago

0.0.20231003

2 years ago

0.0.20230620

2 years ago

0.0.20230613

2 years ago

0.0.20230516

2 years ago

0.0.20230509

2 years ago

0.0.20230425

2 years ago

0.0.20230523

2 years ago

0.0.20230606

2 years ago

0.0.20230529

2 years ago

0.0.20230505

2 years ago

0.0.20230418

2 years ago

0.0.20230317

2 years ago

0.0.20230224

2 years ago

0.0.20230321

2 years ago

0.0.20230404

2 years ago

0.0.20230328

2 years ago

0.0.20230306

2 years ago

0.0.20230329

2 years ago

0.0.20230307

2 years ago

0.0.20230411

2 years ago

0.0.20230214

2 years ago

0.0.20230218

2 years ago

0.0.20230124

2 years ago

0.0.20230131

2 years ago

0.0.20221226

3 years ago

0.0.20221201

3 years ago

0.0.20221101

3 years ago

0.0.20221122

3 years ago

0.0.20230119

2 years ago

0.0.20230102

2 years ago

0.0.20221206

3 years ago

0.0.20230112

2 years ago

0.0.20221020

3 years ago

0.0.20221028

3 years ago

0.0.20220926

3 years ago

0.0.20220829

3 years ago

0.0.20220920

3 years ago

0.0.20220912

3 years ago

0.0.20220824

3 years ago

0.0.20220904

3 years ago

0.0.20220816

3 years ago

0.0.20220808

3 years ago

0.0.20220729

3 years ago