Class v1.PublisherClient (2.2.1)

Eventarc processes events generated by an event provider and delivers them to a subscriber.

An event provider is a software-as-a-service (SaaS) system or product that can generate and deliver events through Eventarc.

A third-party event provider is an event provider from outside of Google.

A partner is a third-party event provider that is integrated with Eventarc.

A subscriber is a GCP customer interested in receiving events.

Channel is a first-class Eventarc resource that is created and managed by the subscriber in their GCP project. A Channel represents a subscriber's intent to receive events from an event provider. A Channel is associated with exactly one event provider.

ChannelConnection is a first-class Eventarc resource that is created and managed by the partner in their GCP project. A ChannelConnection represents a connection between a partner and a subscriber's Channel. A ChannelConnection has a one-to-one mapping with a Channel.

Publisher allows an event provider to publish events to Eventarc. v1

Package

@google-cloud/eventarc-publishing

Constructors

(constructor)(opts)

constructor(opts?: ClientOptions);

Construct an instance of PublisherClient.

Parameter
NameDescription
opts ClientOptions

Properties

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

port

static get port(): number;

The port for this API service.

publisherStub

publisherStub?: Promise<{
        [name: string]: Function;
    }>;

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

publishChannelConnectionEvents(request, options)

publishChannelConnectionEvents(request?: protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsResponse,
        (protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest | undefined),
        {} | undefined
    ]>;

Publish events to a ChannelConnection in a partner's project.

Parameters
NameDescription
request protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsResponse, (protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing [PublishChannelConnectionEventsResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  The channel_connection that the events are published from. For example:
   *  `projects/{partner_project_id}/locations/{location}/channelConnections/{channel_connection_id}`.
   */
  // const channelConnection = 'abc123'
  /**
   *  The CloudEvents v1.0 events to publish. No other types are allowed.
   */
  // const events = 1234

  // Imports the Publishing library
  const {PublisherClient} = require('@google-cloud/eventarc-publishing').v1;

  // Instantiates a client
  const publishingClient = new PublisherClient();

  async function callPublishChannelConnectionEvents() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await publishingClient.publishChannelConnectionEvents(request);
    console.log(response);
  }

  callPublishChannelConnectionEvents();

publishChannelConnectionEvents(request, options, callback)

publishChannelConnectionEvents(request: protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest, options: CallOptions, callback: Callback<protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest
options CallOptions
callback Callback<protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

publishChannelConnectionEvents(request, callback)

publishChannelConnectionEvents(request: protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest, callback: Callback<protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest
callback Callback<protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishChannelConnectionEventsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

publishEvents(request, options)

publishEvents(request?: protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse,
        (protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | undefined),
        {} | undefined
    ]>;

Publish events to a subscriber's channel.

Parameters
NameDescription
request protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse, (protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing [PublishEventsResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  The full name of the channel to publish to. For example:
   *  `projects/{project}/locations/{location}/channels/{channel-id}`.
   */
  // const channel = 'abc123'
  /**
   *  The CloudEvents v1.0 events to publish. No other types are allowed.
   */
  // const events = 1234

  // Imports the Publishing library
  const {PublisherClient} = require('@google-cloud/eventarc-publishing').v1;

  // Instantiates a client
  const publishingClient = new PublisherClient();

  async function callPublishEvents() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await publishingClient.publishEvents(request);
    console.log(response);
  }

  callPublishEvents();

publishEvents(request, options, callback)

publishEvents(request: protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest, options: CallOptions, callback: Callback<protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest
options CallOptions
callback Callback<protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

publishEvents(request, callback)

publishEvents(request: protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest, callback: Callback<protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest
callback Callback<protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void