Cloud Pub/Sub v1 API - Class PublisherServiceApiClient (3.12.0)

public abstract class PublisherServiceApiClient

Reference documentation and code samples for the Cloud Pub/Sub v1 API class PublisherServiceApiClient.

PublisherServiceApi client wrapper, for convenient use.

Inheritance

object > PublisherServiceApiClient

Namespace

Google.Cloud.PubSub.V1

Assembly

Google.Cloud.PubSub.V1.dll

Remarks

The service that an application uses to manipulate topics, and to send messages to a topic.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default PublisherServiceApi scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

GrpcClient

public virtual Publisher.PublisherClient GrpcClient { get; }

The underlying gRPC PublisherServiceApi client

Property Value
Type Description
PublisherPublisherClient

IAMPolicyClient

public virtual IAMPolicyClient IAMPolicyClient { get; }

The IAMPolicyClient associated with this client.

Property Value
Type Description
IAMPolicyClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static PublisherServiceApiClient Create()

Synchronously creates a PublisherServiceApiClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PublisherServiceApiClientBuilder.

Returns
Type Description
PublisherServiceApiClient

The created PublisherServiceApiClient.

CreateAsync(CancellationToken)

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

Asynchronously creates a PublisherServiceApiClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PublisherServiceApiClientBuilder.

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskPublisherServiceApiClient

The task representing the created PublisherServiceApiClient.

CreateTopic(Topic, CallSettings)

public virtual Topic CreateTopic(Topic request, CallSettings callSettings = null)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
request Topic

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
Topic request = new Topic
{
    TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
    Labels = { { "", "" }, },
    MessageStoragePolicy = new MessageStoragePolicy(),
    KmsKeyName = "",
    SchemaSettings = new SchemaSettings(),
    SatisfiesPzs = false,
    MessageRetentionDuration = new Duration(),
    State = Topic.Types.State.Unspecified,
    IngestionDataSourceSettings = new IngestionDataSourceSettings(),
};
// Make the request
Topic response = publisherServiceApiClient.CreateTopic(request);

CreateTopic(TopicName, CallSettings)

public virtual Topic CreateTopic(TopicName name, CallSettings callSettings = null)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
name TopicName

Required. The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

TopicName topicName = new TopicName(projectId, topicId);
Topic topic = client.CreateTopic(topicName);
Console.WriteLine($"Created {topic.Name}");

CreateTopic(string, CallSettings)

public virtual Topic CreateTopic(string name, CallSettings callSettings = null)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
name string

Required. The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
Topic response = publisherServiceApiClient.CreateTopic(name);

CreateTopicAsync(Topic, CallSettings)

public virtual Task<Topic> CreateTopicAsync(Topic request, CallSettings callSettings = null)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
request Topic

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
Topic request = new Topic
{
    TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
    Labels = { { "", "" }, },
    MessageStoragePolicy = new MessageStoragePolicy(),
    KmsKeyName = "",
    SchemaSettings = new SchemaSettings(),
    SatisfiesPzs = false,
    MessageRetentionDuration = new Duration(),
    State = Topic.Types.State.Unspecified,
    IngestionDataSourceSettings = new IngestionDataSourceSettings(),
};
// Make the request
Topic response = await publisherServiceApiClient.CreateTopicAsync(request);

CreateTopicAsync(Topic, CancellationToken)

public virtual Task<Topic> CreateTopicAsync(Topic request, CancellationToken cancellationToken)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
request Topic

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
Topic request = new Topic
{
    TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
    Labels = { { "", "" }, },
    MessageStoragePolicy = new MessageStoragePolicy(),
    KmsKeyName = "",
    SchemaSettings = new SchemaSettings(),
    SatisfiesPzs = false,
    MessageRetentionDuration = new Duration(),
    State = Topic.Types.State.Unspecified,
    IngestionDataSourceSettings = new IngestionDataSourceSettings(),
};
// Make the request
Topic response = await publisherServiceApiClient.CreateTopicAsync(request);

CreateTopicAsync(TopicName, CallSettings)

public virtual Task<Topic> CreateTopicAsync(TopicName name, CallSettings callSettings = null)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
name TopicName

Required. The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

TopicName topicName = new TopicName(projectId, topicId);
Topic topic = await client.CreateTopicAsync(topicName);
Console.WriteLine($"Created {topic.Name}");

CreateTopicAsync(TopicName, CancellationToken)

public virtual Task<Topic> CreateTopicAsync(TopicName name, CancellationToken cancellationToken)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
name TopicName

Required. The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

TopicName topicName = new TopicName(projectId, topicId);
Topic topic = await client.CreateTopicAsync(topicName);
Console.WriteLine($"Created {topic.Name}");

CreateTopicAsync(string, CallSettings)

public virtual Task<Topic> CreateTopicAsync(string name, CallSettings callSettings = null)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
name string

Required. The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
Topic response = await publisherServiceApiClient.CreateTopicAsync(name);

CreateTopicAsync(string, CancellationToken)

public virtual Task<Topic> CreateTopicAsync(string name, CancellationToken cancellationToken)

Creates the given topic with the given name. See the resource name rules.

Parameters
Name Description
name string

Required. The name of the topic. It must have the format "projects/{project}/topics/{topic}". {topic} must start with a letter, and contain only letters ([A-Za-z]), numbers ([0-9]), dashes (-), underscores (_), periods (.), tildes (~), plus (+) or percent signs (%). It must be between 3 and 255 characters in length, and it must not start with "goog".

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
Topic response = await publisherServiceApiClient.CreateTopicAsync(name);

DeleteTopic(DeleteTopicRequest, CallSettings)

public virtual void DeleteTopic(DeleteTopicRequest request, CallSettings callSettings = null)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
request DeleteTopicRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
DeleteTopicRequest request = new DeleteTopicRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
publisherServiceApiClient.DeleteTopic(request);

DeleteTopic(TopicName, CallSettings)

public virtual void DeleteTopic(TopicName topic, CallSettings callSettings = null)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
topic TopicName

Required. Name of the topic to delete. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

TopicName topicName = new TopicName(projectId, topicId);
client.DeleteTopic(topicName);
Console.WriteLine($"Deleted {topicName}");

DeleteTopic(string, CallSettings)

public virtual void DeleteTopic(string topic, CallSettings callSettings = null)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
topic string

Required. Name of the topic to delete. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
publisherServiceApiClient.DeleteTopic(topic);

DeleteTopicAsync(DeleteTopicRequest, CallSettings)

public virtual Task DeleteTopicAsync(DeleteTopicRequest request, CallSettings callSettings = null)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
request DeleteTopicRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
DeleteTopicRequest request = new DeleteTopicRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
await publisherServiceApiClient.DeleteTopicAsync(request);

DeleteTopicAsync(DeleteTopicRequest, CancellationToken)

public virtual Task DeleteTopicAsync(DeleteTopicRequest request, CancellationToken cancellationToken)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
request DeleteTopicRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
DeleteTopicRequest request = new DeleteTopicRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
await publisherServiceApiClient.DeleteTopicAsync(request);

DeleteTopicAsync(TopicName, CallSettings)

public virtual Task DeleteTopicAsync(TopicName topic, CallSettings callSettings = null)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
topic TopicName

Required. Name of the topic to delete. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

TopicName topicName = new TopicName(projectId, topicId);
await client.DeleteTopicAsync(topicName);
Console.WriteLine($"Deleted {topicName}");

DeleteTopicAsync(TopicName, CancellationToken)

public virtual Task DeleteTopicAsync(TopicName topic, CancellationToken cancellationToken)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
topic TopicName

Required. Name of the topic to delete. Format is projects/{project}/topics/{topic}.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

TopicName topicName = new TopicName(projectId, topicId);
await client.DeleteTopicAsync(topicName);
Console.WriteLine($"Deleted {topicName}");

DeleteTopicAsync(string, CallSettings)

public virtual Task DeleteTopicAsync(string topic, CallSettings callSettings = null)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
topic string

Required. Name of the topic to delete. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
await publisherServiceApiClient.DeleteTopicAsync(topic);

DeleteTopicAsync(string, CancellationToken)

public virtual Task DeleteTopicAsync(string topic, CancellationToken cancellationToken)

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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their topic field is set to _deleted-topic_.

Parameters
Name Description
topic string

Required. Name of the topic to delete. Format is projects/{project}/topics/{topic}.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
await publisherServiceApiClient.DeleteTopicAsync(topic);

DetachSubscription(DetachSubscriptionRequest, CallSettings)

public virtual DetachSubscriptionResponse DetachSubscription(DetachSubscriptionRequest request, CallSettings callSettings = null)

Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent Pull and StreamingPull requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.

Parameters
Name Description
request DetachSubscriptionRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
DetachSubscriptionResponse

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
    SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription("[PROJECT]", "[SUBSCRIPTION]"),
};
// Make the request
DetachSubscriptionResponse response = publisherServiceApiClient.DetachSubscription(request);

DetachSubscriptionAsync(DetachSubscriptionRequest, CallSettings)

public virtual Task<DetachSubscriptionResponse> DetachSubscriptionAsync(DetachSubscriptionRequest request, CallSettings callSettings = null)

Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent Pull and StreamingPull requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.

Parameters
Name Description
request DetachSubscriptionRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskDetachSubscriptionResponse

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
    SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription("[PROJECT]", "[SUBSCRIPTION]"),
};
// Make the request
DetachSubscriptionResponse response = await publisherServiceApiClient.DetachSubscriptionAsync(request);

DetachSubscriptionAsync(DetachSubscriptionRequest, CancellationToken)

public virtual Task<DetachSubscriptionResponse> DetachSubscriptionAsync(DetachSubscriptionRequest request, CancellationToken cancellationToken)

Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent Pull and StreamingPull requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.

Parameters
Name Description
request DetachSubscriptionRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskDetachSubscriptionResponse

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
DetachSubscriptionRequest request = new DetachSubscriptionRequest
{
    SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription("[PROJECT]", "[SUBSCRIPTION]"),
};
// Make the request
DetachSubscriptionResponse response = await publisherServiceApiClient.DetachSubscriptionAsync(request);

GetTopic(GetTopicRequest, CallSettings)

public virtual Topic GetTopic(GetTopicRequest request, CallSettings callSettings = null)

Gets the configuration of a topic.

Parameters
Name Description
request GetTopicRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
GetTopicRequest request = new GetTopicRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
Topic response = publisherServiceApiClient.GetTopic(request);

GetTopic(TopicName, CallSettings)

public virtual Topic GetTopic(TopicName topic, CallSettings callSettings = null)

Gets the configuration of a topic.

Parameters
Name Description
topic TopicName

Required. The name of the topic to get. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
Topic response = publisherServiceApiClient.GetTopic(topic);

GetTopic(string, CallSettings)

public virtual Topic GetTopic(string topic, CallSettings callSettings = null)

Gets the configuration of a topic.

Parameters
Name Description
topic string

Required. The name of the topic to get. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
Topic response = publisherServiceApiClient.GetTopic(topic);

GetTopicAsync(GetTopicRequest, CallSettings)

public virtual Task<Topic> GetTopicAsync(GetTopicRequest request, CallSettings callSettings = null)

Gets the configuration of a topic.

Parameters
Name Description
request GetTopicRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
GetTopicRequest request = new GetTopicRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
Topic response = await publisherServiceApiClient.GetTopicAsync(request);

GetTopicAsync(GetTopicRequest, CancellationToken)

public virtual Task<Topic> GetTopicAsync(GetTopicRequest request, CancellationToken cancellationToken)

Gets the configuration of a topic.

Parameters
Name Description
request GetTopicRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
GetTopicRequest request = new GetTopicRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
Topic response = await publisherServiceApiClient.GetTopicAsync(request);

GetTopicAsync(TopicName, CallSettings)

public virtual Task<Topic> GetTopicAsync(TopicName topic, CallSettings callSettings = null)

Gets the configuration of a topic.

Parameters
Name Description
topic TopicName

Required. The name of the topic to get. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
Topic response = await publisherServiceApiClient.GetTopicAsync(topic);

GetTopicAsync(TopicName, CancellationToken)

public virtual Task<Topic> GetTopicAsync(TopicName topic, CancellationToken cancellationToken)

Gets the configuration of a topic.

Parameters
Name Description
topic TopicName

Required. The name of the topic to get. Format is projects/{project}/topics/{topic}.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
Topic response = await publisherServiceApiClient.GetTopicAsync(topic);

GetTopicAsync(string, CallSettings)

public virtual Task<Topic> GetTopicAsync(string topic, CallSettings callSettings = null)

Gets the configuration of a topic.

Parameters
Name Description
topic string

Required. The name of the topic to get. Format is projects/{project}/topics/{topic}.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
Topic response = await publisherServiceApiClient.GetTopicAsync(topic);

GetTopicAsync(string, CancellationToken)

public virtual Task<Topic> GetTopicAsync(string topic, CancellationToken cancellationToken)

Gets the configuration of a topic.

Parameters
Name Description
topic string

Required. The name of the topic to get. Format is projects/{project}/topics/{topic}.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
Topic response = await publisherServiceApiClient.GetTopicAsync(topic);

ListTopicSnapshots(ListTopicSnapshotsRequest, CallSettings)

public virtual PagedEnumerable<ListTopicSnapshotsResponse, string> ListTopicSnapshots(ListTopicSnapshotsRequest request, CallSettings callSettings = null)

Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters
Name Description
request ListTopicSnapshotsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicSnapshotsResponsestring

A pageable sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
ListTopicSnapshotsRequest request = new ListTopicSnapshotsRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
PagedEnumerable<ListTopicSnapshotsResponse, string> response = publisherServiceApiClient.ListTopicSnapshots(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (string item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicSnapshotsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSnapshots(TopicName, string, int?, CallSettings)

public virtual PagedEnumerable<ListTopicSnapshotsResponse, string> ListTopicSnapshots(TopicName topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters
Name Description
topic TopicName

Required. The name of the topic that snapshots are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicSnapshotsResponsestring

A pageable sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
PagedEnumerable<ListTopicSnapshotsResponse, string> response = publisherServiceApiClient.ListTopicSnapshots(topic);

// Iterate over all response items, lazily performing RPCs as required
foreach (string item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicSnapshotsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSnapshots(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListTopicSnapshotsResponse, string> ListTopicSnapshots(string topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters
Name Description
topic string

Required. The name of the topic that snapshots are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicSnapshotsResponsestring

A pageable sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
PagedEnumerable<ListTopicSnapshotsResponse, string> response = publisherServiceApiClient.ListTopicSnapshots(topic);

// Iterate over all response items, lazily performing RPCs as required
foreach (string item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicSnapshotsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSnapshotsAsync(ListTopicSnapshotsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicSnapshotsResponse, string> ListTopicSnapshotsAsync(ListTopicSnapshotsRequest request, CallSettings callSettings = null)

Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters
Name Description
request ListTopicSnapshotsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicSnapshotsResponsestring

A pageable asynchronous sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
ListTopicSnapshotsRequest request = new ListTopicSnapshotsRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
PagedAsyncEnumerable<ListTopicSnapshotsResponse, string> response = publisherServiceApiClient.ListTopicSnapshotsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((string item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicSnapshotsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSnapshotsAsync(TopicName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicSnapshotsResponse, string> ListTopicSnapshotsAsync(TopicName topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters
Name Description
topic TopicName

Required. The name of the topic that snapshots are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicSnapshotsResponsestring

A pageable asynchronous sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
PagedAsyncEnumerable<ListTopicSnapshotsResponse, string> response = publisherServiceApiClient.ListTopicSnapshotsAsync(topic);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((string item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicSnapshotsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSnapshotsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicSnapshotsResponse, string> ListTopicSnapshotsAsync(string topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

Parameters
Name Description
topic string

Required. The name of the topic that snapshots are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicSnapshotsResponsestring

A pageable asynchronous sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
PagedAsyncEnumerable<ListTopicSnapshotsResponse, string> response = publisherServiceApiClient.ListTopicSnapshotsAsync(topic);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((string item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicSnapshotsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSubscriptions(ListTopicSubscriptionsRequest, CallSettings)

public virtual PagedEnumerable<ListTopicSubscriptionsResponse, string> ListTopicSubscriptions(ListTopicSubscriptionsRequest request, CallSettings callSettings = null)

Lists the names of the attached subscriptions on this topic.

Parameters
Name Description
request ListTopicSubscriptionsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicSubscriptionsResponsestring

A pageable sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
ListTopicSubscriptionsRequest request = new ListTopicSubscriptionsRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
PagedEnumerable<ListTopicSubscriptionsResponse, string> response = publisherServiceApiClient.ListTopicSubscriptions(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (string item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicSubscriptionsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSubscriptions(TopicName, string, int?, CallSettings)

public virtual PagedEnumerable<ListTopicSubscriptionsResponse, string> ListTopicSubscriptions(TopicName topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the attached subscriptions on this topic.

Parameters
Name Description
topic TopicName

Required. The name of the topic that subscriptions are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicSubscriptionsResponsestring

A pageable sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
PagedEnumerable<ListTopicSubscriptionsResponse, string> response = publisherServiceApiClient.ListTopicSubscriptions(topic);

// Iterate over all response items, lazily performing RPCs as required
foreach (string item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicSubscriptionsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSubscriptions(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListTopicSubscriptionsResponse, string> ListTopicSubscriptions(string topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the attached subscriptions on this topic.

Parameters
Name Description
topic string

Required. The name of the topic that subscriptions are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicSubscriptionsResponsestring

A pageable sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
PagedEnumerable<ListTopicSubscriptionsResponse, string> response = publisherServiceApiClient.ListTopicSubscriptions(topic);

// Iterate over all response items, lazily performing RPCs as required
foreach (string item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicSubscriptionsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSubscriptionsAsync(ListTopicSubscriptionsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicSubscriptionsResponse, string> ListTopicSubscriptionsAsync(ListTopicSubscriptionsRequest request, CallSettings callSettings = null)

Lists the names of the attached subscriptions on this topic.

Parameters
Name Description
request ListTopicSubscriptionsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicSubscriptionsResponsestring

A pageable asynchronous sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
ListTopicSubscriptionsRequest request = new ListTopicSubscriptionsRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
};
// Make the request
PagedAsyncEnumerable<ListTopicSubscriptionsResponse, string> response = publisherServiceApiClient.ListTopicSubscriptionsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((string item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicSubscriptionsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSubscriptionsAsync(TopicName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicSubscriptionsResponse, string> ListTopicSubscriptionsAsync(TopicName topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the attached subscriptions on this topic.

Parameters
Name Description
topic TopicName

Required. The name of the topic that subscriptions are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicSubscriptionsResponsestring

A pageable asynchronous sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
TopicName topic = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]");
// Make the request
PagedAsyncEnumerable<ListTopicSubscriptionsResponse, string> response = publisherServiceApiClient.ListTopicSubscriptionsAsync(topic);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((string item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicSubscriptionsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicSubscriptionsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicSubscriptionsResponse, string> ListTopicSubscriptionsAsync(string topic, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists the names of the attached subscriptions on this topic.

Parameters
Name Description
topic string

Required. The name of the topic that subscriptions are attached to. Format is projects/{project}/topics/{topic}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicSubscriptionsResponsestring

A pageable asynchronous sequence of string resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
// Make the request
PagedAsyncEnumerable<ListTopicSubscriptionsResponse, string> response = publisherServiceApiClient.ListTopicSubscriptionsAsync(topic);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((string item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicSubscriptionsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (string item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<string> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (string item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopics(ProjectName, string, int?, CallSettings)

public virtual PagedEnumerable<ListTopicsResponse, Topic> ListTopics(ProjectName project, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists matching topics.

Parameters
Name Description
project ProjectName

Required. The name of the project in which to list topics. Format is projects/{project-id}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicsResponseTopic

A pageable sequence of Topic resources.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

ProjectName projectName = new ProjectName(projectId);
foreach (Topic topic in client.ListTopics(projectName))
{
    Console.WriteLine(topic.Name);
}

ListTopics(ListTopicsRequest, CallSettings)

public virtual PagedEnumerable<ListTopicsResponse, Topic> ListTopics(ListTopicsRequest request, CallSettings callSettings = null)

Lists matching topics.

Parameters
Name Description
request ListTopicsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicsResponseTopic

A pageable sequence of Topic resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
ListTopicsRequest request = new ListTopicsRequest
{
    ProjectAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedEnumerable<ListTopicsResponse, Topic> response = publisherServiceApiClient.ListTopics(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Topic item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Topic item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Topic> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Topic item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopics(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListTopicsResponse, Topic> ListTopics(string project, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists matching topics.

Parameters
Name Description
project string

Required. The name of the project in which to list topics. Format is projects/{project-id}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListTopicsResponseTopic

A pageable sequence of Topic resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string project = "projects/[PROJECT]";
// Make the request
PagedEnumerable<ListTopicsResponse, Topic> response = publisherServiceApiClient.ListTopics(project);

// Iterate over all response items, lazily performing RPCs as required
foreach (Topic item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTopicsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Topic item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Topic> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Topic item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicsAsync(ProjectName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicsResponse, Topic> ListTopicsAsync(ProjectName project, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists matching topics.

Parameters
Name Description
project ProjectName

Required. The name of the project in which to list topics. Format is projects/{project-id}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicsResponseTopic

A pageable asynchronous sequence of Topic resources.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();

ProjectName projectName = new ProjectName(projectId);
IAsyncEnumerable<Topic> topics = client.ListTopicsAsync(projectName);
await topics.ForEachAsync(topic =>
{
    Console.WriteLine(topic.Name);
});

ListTopicsAsync(ListTopicsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicsResponse, Topic> ListTopicsAsync(ListTopicsRequest request, CallSettings callSettings = null)

Lists matching topics.

Parameters
Name Description
request ListTopicsRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicsResponseTopic

A pageable asynchronous sequence of Topic resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
ListTopicsRequest request = new ListTopicsRequest
{
    ProjectAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedAsyncEnumerable<ListTopicsResponse, Topic> response = publisherServiceApiClient.ListTopicsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Topic item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Topic item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Topic> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Topic item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTopicsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTopicsResponse, Topic> ListTopicsAsync(string project, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists matching topics.

Parameters
Name Description
project string

Required. The name of the project in which to list topics. Format is projects/{project-id}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListTopicsResponseTopic

A pageable asynchronous sequence of Topic resources.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string project = "projects/[PROJECT]";
// Make the request
PagedAsyncEnumerable<ListTopicsResponse, Topic> response = publisherServiceApiClient.ListTopicsAsync(project);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Topic item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTopicsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Topic item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Topic> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Topic item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

Publish(PublishRequest, CallSettings)

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

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
request PublishRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PublishResponse

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
PublishRequest request = new PublishRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
    Messages =
    {
        new PubsubMessage(),
    },
};
// Make the request
PublishResponse response = publisherServiceApiClient.Publish(request);

Publish(TopicName, IEnumerable<PubsubMessage>, CallSettings)

public virtual PublishResponse Publish(TopicName topic, IEnumerable<PubsubMessage> messages, CallSettings callSettings = null)

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
topic TopicName

Required. The messages in the request will be published on this topic. Format is projects/{project}/topics/{topic}.

messages IEnumerablePubsubMessage

Required. The messages to publish.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PublishResponse

The RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();
// Make sure we have a topic to publish to
TopicName topicName = new TopicName(projectId, topicId);
client.CreateTopic(topicName);

PubsubMessage message = new PubsubMessage
{
    // The data is any arbitrary ByteString. Here, we're using text.
    Data = ByteString.CopyFromUtf8("Hello, Pubsub"),
    // The attributes provide metadata in a string-to-string dictionary.
    Attributes =
    {
        { "description", "Simple text message" }
    }
};
client.Publish(topicName, new[] { message });

Publish(string, IEnumerable<PubsubMessage>, CallSettings)

public virtual PublishResponse Publish(string topic, IEnumerable<PubsubMessage> messages, CallSettings callSettings = null)

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
topic string

Required. The messages in the request will be published on this topic. Format is projects/{project}/topics/{topic}.

messages IEnumerablePubsubMessage

Required. The messages to publish.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PublishResponse

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
IEnumerable<PubsubMessage> messages = new PubsubMessage[]
{
    new PubsubMessage(),
};
// Make the request
PublishResponse response = publisherServiceApiClient.Publish(topic, messages);

PublishAsync(PublishRequest, CallSettings)

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

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
request PublishRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPublishResponse

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
PublishRequest request = new PublishRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
    Messages =
    {
        new PubsubMessage(),
    },
};
// Make the request
PublishResponse response = await publisherServiceApiClient.PublishAsync(request);

PublishAsync(PublishRequest, CancellationToken)

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

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
request PublishRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPublishResponse

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
PublishRequest request = new PublishRequest
{
    TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
    Messages =
    {
        new PubsubMessage(),
    },
};
// Make the request
PublishResponse response = await publisherServiceApiClient.PublishAsync(request);

PublishAsync(TopicName, IEnumerable<PubsubMessage>, CallSettings)

public virtual Task<PublishResponse> PublishAsync(TopicName topic, IEnumerable<PubsubMessage> messages, CallSettings callSettings = null)

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
topic TopicName

Required. The messages in the request will be published on this topic. Format is projects/{project}/topics/{topic}.

messages IEnumerablePubsubMessage

Required. The messages to publish.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPublishResponse

A Task containing the RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();
// Make sure we have a topic to publish to
TopicName topicName = new TopicName(projectId, topicId);
await client.CreateTopicAsync(topicName);

PubsubMessage message = new PubsubMessage
{
    // The data is any arbitrary ByteString. Here, we're using text.
    Data = ByteString.CopyFromUtf8("Hello, Pubsub"),
    // The attributes provide metadata in a string-to-string dictionary.
    Attributes =
    {
        { "description", "Simple text message" }
    }
};
await client.PublishAsync(topicName, new[] { message });

PublishAsync(TopicName, IEnumerable<PubsubMessage>, CancellationToken)

public virtual Task<PublishResponse> PublishAsync(TopicName topic, IEnumerable<PubsubMessage> messages, CancellationToken cancellationToken)

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
topic TopicName

Required. The messages in the request will be published on this topic. Format is projects/{project}/topics/{topic}.

messages IEnumerablePubsubMessage

Required. The messages to publish.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPublishResponse

A Task containing the RPC response.

Example
PublisherServiceApiClient client = PublisherServiceApiClient.Create();
// Make sure we have a topic to publish to
TopicName topicName = new TopicName(projectId, topicId);
await client.CreateTopicAsync(topicName);

PubsubMessage message = new PubsubMessage
{
    // The data is any arbitrary ByteString. Here, we're using text.
    Data = ByteString.CopyFromUtf8("Hello, Pubsub"),
    // The attributes provide metadata in a string-to-string dictionary.
    Attributes =
    {
        { "description", "Simple text message" }
    }
};
await client.PublishAsync(topicName, new[] { message });

PublishAsync(string, IEnumerable<PubsubMessage>, CallSettings)

public virtual Task<PublishResponse> PublishAsync(string topic, IEnumerable<PubsubMessage> messages, CallSettings callSettings = null)

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
topic string

Required. The messages in the request will be published on this topic. Format is projects/{project}/topics/{topic}.

messages IEnumerablePubsubMessage

Required. The messages to publish.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPublishResponse

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
IEnumerable<PubsubMessage> messages = new PubsubMessage[]
{
    new PubsubMessage(),
};
// Make the request
PublishResponse response = await publisherServiceApiClient.PublishAsync(topic, messages);

PublishAsync(string, IEnumerable<PubsubMessage>, CancellationToken)

public virtual Task<PublishResponse> PublishAsync(string topic, IEnumerable<PubsubMessage> messages, CancellationToken cancellationToken)

Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.

Parameters
Name Description
topic string

Required. The messages in the request will be published on this topic. Format is projects/{project}/topics/{topic}.

messages IEnumerablePubsubMessage

Required. The messages to publish.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPublishResponse

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
string topic = "projects/[PROJECT]/topics/[TOPIC]";
IEnumerable<PubsubMessage> messages = new PubsubMessage[]
{
    new PubsubMessage(),
};
// Make the request
PublishResponse response = await publisherServiceApiClient.PublishAsync(topic, messages);

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

UpdateTopic(Topic, FieldMask, CallSettings)

public virtual Topic UpdateTopic(Topic topic, FieldMask updateMask, CallSettings callSettings = null)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

Parameters
Name Description
topic Topic

Required. The updated topic object.

updateMask FieldMask

Required. Indicates which fields in the provided topic to update. Must be specified and non-empty. Note that if update_mask contains "message_storage_policy" but the message_storage_policy is not set in the topic provided above, then the updated value is determined by the policy configured at the project or organization level.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
Topic topic = new Topic();
FieldMask updateMask = new FieldMask();
// Make the request
Topic response = publisherServiceApiClient.UpdateTopic(topic, updateMask);

UpdateTopic(UpdateTopicRequest, CallSettings)

public virtual Topic UpdateTopic(UpdateTopicRequest request, CallSettings callSettings = null)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

Parameters
Name Description
request UpdateTopicRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Topic

The RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
// Initialize request argument(s)
UpdateTopicRequest request = new UpdateTopicRequest
{
    Topic = new Topic(),
    UpdateMask = new FieldMask(),
};
// Make the request
Topic response = publisherServiceApiClient.UpdateTopic(request);

UpdateTopicAsync(Topic, FieldMask, CallSettings)

public virtual Task<Topic> UpdateTopicAsync(Topic topic, FieldMask updateMask, CallSettings callSettings = null)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

Parameters
Name Description
topic Topic

Required. The updated topic object.

updateMask FieldMask

Required. Indicates which fields in the provided topic to update. Must be specified and non-empty. Note that if update_mask contains "message_storage_policy" but the message_storage_policy is not set in the topic provided above, then the updated value is determined by the policy configured at the project or organization level.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
Topic topic = new Topic();
FieldMask updateMask = new FieldMask();
// Make the request
Topic response = await publisherServiceApiClient.UpdateTopicAsync(topic, updateMask);

UpdateTopicAsync(Topic, FieldMask, CancellationToken)

public virtual Task<Topic> UpdateTopicAsync(Topic topic, FieldMask updateMask, CancellationToken cancellationToken)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

Parameters
Name Description
topic Topic

Required. The updated topic object.

updateMask FieldMask

Required. Indicates which fields in the provided topic to update. Must be specified and non-empty. Note that if update_mask contains "message_storage_policy" but the message_storage_policy is not set in the topic provided above, then the updated value is determined by the policy configured at the project or organization level.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
Topic topic = new Topic();
FieldMask updateMask = new FieldMask();
// Make the request
Topic response = await publisherServiceApiClient.UpdateTopicAsync(topic, updateMask);

UpdateTopicAsync(UpdateTopicRequest, CallSettings)

public virtual Task<Topic> UpdateTopicAsync(UpdateTopicRequest request, CallSettings callSettings = null)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

Parameters
Name Description
request UpdateTopicRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
UpdateTopicRequest request = new UpdateTopicRequest
{
    Topic = new Topic(),
    UpdateMask = new FieldMask(),
};
// Make the request
Topic response = await publisherServiceApiClient.UpdateTopicAsync(request);

UpdateTopicAsync(UpdateTopicRequest, CancellationToken)

public virtual Task<Topic> UpdateTopicAsync(UpdateTopicRequest request, CancellationToken cancellationToken)

Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.

Parameters
Name Description
request UpdateTopicRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskTopic

A Task containing the RPC response.

Example
// Create client
PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();
// Initialize request argument(s)
UpdateTopicRequest request = new UpdateTopicRequest
{
    Topic = new Topic(),
    UpdateMask = new FieldMask(),
};
// Make the request
Topic response = await publisherServiceApiClient.UpdateTopicAsync(request);