# Eventarc Publishing v1 API - Class PublisherClient (2.0.0-beta08)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.0.0-beta08 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient)
- [2.0.0-beta07](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/2.0.0-beta07/Google.Cloud.Eventarc.Publishing.V1.PublisherClient)
- [1.0.0-beta02](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/1.0.0-beta02/Google.Cloud.Eventarc.Publishing.V1.PublisherClient)

    public abstract class PublisherClient

Reference documentation and code samples for the Eventarc Publishing v1 API class PublisherClient.

Publisher client wrapper, for convenient use.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> PublisherClient

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Derived Types

[PublisherClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClientImpl)

## Namespace

[Google.Cloud.Eventarc.Publishing.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1)

## Assembly

Google.Cloud.Eventarc.Publishing.V1.dll

## Remarks

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 Google Cloud customer interested in receiving events.

Channel is a first-class Eventarc resource that is created and managed
by the subscriber in their Google Cloud 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 Google Cloud 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.

Bus is a first-class Eventarc resource that is created and managed in a
Google Cloud project. A Bus provides a discoverable endpoint for events and
is a router that receives all events published by event providers and
delivers them to zero or more subscribers.

Publisher allows an event provider to publish events to Eventarc.

## Properties

### DefaultEndpoint

    public static string DefaultEndpoint { get; }

The default endpoint for the Publisher service, which is a host of "eventarcpublishing.googleapis.com" and a
port of 443.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DefaultScopes

    public static IReadOnlyList<string> DefaultScopes { get; }

The default Publisher scopes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** The default Publisher scopes are:

- <https://www.googleapis.com/auth/cloud-platform>

<br />

### GrpcClient

    public virtual Publisher.PublisherClient GrpcClient { get; }

The underlying gRPC Publisher client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.Publisherhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.Publisher.PublisherClient` |   |

### ServiceMetadata

    public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ServiceMetadata.html` |   |

## Methods

### Create()

    public static PublisherClient Create()

Synchronously creates a [PublisherClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient) using the default credentials, endpoint and settings.
To specify custom credentials or other settings, use [PublisherClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClientBuilder).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient` | The created [PublisherClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient). |

### CreateAsync(CancellationToken)

    public static Task<PublisherClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a [PublisherClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient) using the default credentials, endpoint and settings.
To specify custom credentials or other settings, use [PublisherClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClientBuilder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use while creating the client. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient` | The task representing the created [PublisherClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient). |

### Publish(PublishRequest, CallSettings)

    public virtual PublishResponse Publish(PublishRequest request, CallSettings callSettings = null)

Publish events to a message bus.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishResponse` | The RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = PublisherClient.Create();
    // Initialize request argument(s)
    PublishRequest request = new PublishRequest
    {
        MessageBus = "",
        ProtoMessage = new CloudEvent(),
    };
    // Make the request
    PublishResponse response = publisherClient.Publish(request);

### PublishAsync(PublishRequest, CallSettings)

    public virtual Task<PublishResponse> PublishAsync(PublishRequest request, CallSettings callSettings = null)

Publish events to a message bus.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = await PublisherClient.CreateAsync();
    // Initialize request argument(s)
    PublishRequest request = new PublishRequest
    {
        MessageBus = "",
        ProtoMessage = new CloudEvent(),
    };
    // Make the request
    PublishResponse response = await publisherClient.PublishAsync(request);

### PublishAsync(PublishRequest, CancellationToken)

    public virtual Task<PublishResponse> PublishAsync(PublishRequest request, CancellationToken cancellationToken)

Publish events to a message bus.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = await PublisherClient.CreateAsync();
    // Initialize request argument(s)
    PublishRequest request = new PublishRequest
    {
        MessageBus = "",
        ProtoMessage = new CloudEvent(),
    };
    // Make the request
    PublishResponse response = await publisherClient.PublishAsync(request);

### PublishChannelConnectionEvents(PublishChannelConnectionEventsRequest, CallSettings)

    public virtual PublishChannelConnectionEventsResponse PublishChannelConnectionEvents(PublishChannelConnectionEventsRequest request, CallSettings callSettings = null)

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishChannelConnectionEventsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishChannelConnectionEventsResponse` | The RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = PublisherClient.Create();
    // Initialize request argument(s)
    PublishChannelConnectionEventsRequest request = new PublishChannelConnectionEventsRequest
    {
        ChannelConnection = "",
        Events = { new Any(), },
        TextEvents = { "", },
    };
    // Make the request
    PublishChannelConnectionEventsResponse response = publisherClient.PublishChannelConnectionEvents(request);

### PublishChannelConnectionEventsAsync(PublishChannelConnectionEventsRequest, CallSettings)

    public virtual Task<PublishChannelConnectionEventsResponse> PublishChannelConnectionEventsAsync(PublishChannelConnectionEventsRequest request, CallSettings callSettings = null)

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishChannelConnectionEventsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishChannelConnectionEventsResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = await PublisherClient.CreateAsync();
    // Initialize request argument(s)
    PublishChannelConnectionEventsRequest request = new PublishChannelConnectionEventsRequest
    {
        ChannelConnection = "",
        Events = { new Any(), },
        TextEvents = { "", },
    };
    // Make the request
    PublishChannelConnectionEventsResponse response = await publisherClient.PublishChannelConnectionEventsAsync(request);

### PublishChannelConnectionEventsAsync(PublishChannelConnectionEventsRequest, CancellationToken)

    public virtual Task<PublishChannelConnectionEventsResponse> PublishChannelConnectionEventsAsync(PublishChannelConnectionEventsRequest request, CancellationToken cancellationToken)

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishChannelConnectionEventsRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishChannelConnectionEventsResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = await PublisherClient.CreateAsync();
    // Initialize request argument(s)
    PublishChannelConnectionEventsRequest request = new PublishChannelConnectionEventsRequest
    {
        ChannelConnection = "",
        Events = { new Any(), },
        TextEvents = { "", },
    };
    // Make the request
    PublishChannelConnectionEventsResponse response = await publisherClient.PublishChannelConnectionEventsAsync(request);

### PublishEvents(PublishEventsRequest, CallSettings)

    public virtual PublishEventsResponse PublishEvents(PublishEventsRequest request, CallSettings callSettings = null)

Publish events to a subscriber's channel.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishEventsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishEventsResponse` | The RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = PublisherClient.Create();
    // Initialize request argument(s)
    PublishEventsRequest request = new PublishEventsRequest
    {
        Channel = "",
        Events = { new Any(), },
        TextEvents = { "", },
    };
    // Make the request
    PublishEventsResponse response = publisherClient.PublishEvents(request);

### PublishEventsAsync(PublishEventsRequest, CallSettings)

    public virtual Task<PublishEventsResponse> PublishEventsAsync(PublishEventsRequest request, CallSettings callSettings = null)

Publish events to a subscriber's channel.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishEventsRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishEventsResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = await PublisherClient.CreateAsync();
    // Initialize request argument(s)
    PublishEventsRequest request = new PublishEventsRequest
    {
        Channel = "",
        Events = { new Any(), },
        TextEvents = { "", },
    };
    // Make the request
    PublishEventsResponse response = await publisherClient.PublishEventsAsync(request);

### PublishEventsAsync(PublishEventsRequest, CancellationToken)

    public virtual Task<PublishEventsResponse> PublishEventsAsync(PublishEventsRequest request, CancellationToken cancellationToken)

Publish events to a subscriber's channel.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishEventsRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublishEventsResponse` | A Task containing the RPC response. |

**Example**

    // Create client
    PublisherClient publisherClient = await PublisherClient.CreateAsync();
    // Initialize request argument(s)
    PublishEventsRequest request = new PublishEventsRequest
    {
        Channel = "",
        Events = { new Any(), },
        TextEvents = { "", },
    };
    // Make the request
    PublishEventsResponse response = await publisherClient.PublishEventsAsync(request);

### ShutdownDefaultChannelsAsync()

    public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient#Google_Cloud_Eventarc_Publishing_V1_PublisherClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient#Google_Cloud_Eventarc_Publishing_V1_PublisherClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not
affected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous shutdown operation. |

**Remarks** After calling this method, further calls to [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient#Google_Cloud_Eventarc_Publishing_V1_PublisherClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Eventarc.Publishing.V1/latest/Google.Cloud.Eventarc.Publishing.V1.PublisherClient#Google_Cloud_Eventarc_Publishing_V1_PublisherClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.