Class v1.PublisherClient (3.2.0)

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, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of PublisherClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new PublisherClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

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.

universeDomain

get universeDomain(): string;

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 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 for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * 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.
   *  If this field is set, then the `text_events` fields must not be set.
   */
  // const events = [1,2,3,4]
  /**
   *  The text representation of events to publish.
   *  CloudEvent v1.0 in JSON format is the only allowed type. Refer to
   *  https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
   *  for specification.
   *  If this field is set, then the `events` fields must not be set.
   */
  // const textEvents = ['abc','def']

  // 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 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 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 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 for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * 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.
   *  If this field is set, then the `text_events` fields must not be set.
   */
  // const events = [1,2,3,4]
  /**
   *  The text representation of events to publish.
   *  CloudEvent v1.0 in JSON format is the only allowed type. Refer to
   *  https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
   *  for specification.
   *  If this field is set, then the `events` fields must not be set.
   */
  // const textEvents = ['abc','def']

  // 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 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 IPublishEventsRequest
callback Callback<protos.google.cloud.eventarc.publishing.v1.IPublishEventsResponse, protos.google.cloud.eventarc.publishing.v1.IPublishEventsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void