# Cloud Scheduler V1 Client - Class PubsubTarget (2.2.0)

2.2.0 (latest) 2.1.2 2.0.5 1.10.5 1.9.4 1.8.3 1.7.1 1.6.8 Reference documentation and code samples for the Cloud Scheduler V1 Client class PubsubTarget.

Pub/Sub target. The job will be delivered by publishing a message to
the given Pub/Sub topic.

Generated from protobuf message `google.cloud.scheduler.v1.PubsubTarget`

## Namespace

Google \\ Cloud \\ Scheduler \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ topic_name` | `string` Required. The name of the Cloud Pub/Sub topic to which messages will be published when a job is delivered. The topic name must be in the same format as required by Pub/Sub's [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest), for example `projects/PROJECT_ID/topics/TOPIC_ID`. The topic must be in the same project as the Cloud Scheduler job. |
| `↳ data` | `string` The message payload for PubsubMessage. Pubsub message must contain either non-empty data, or at least one attribute. |
| `↳ attributes` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` Attributes for PubsubMessage. Pubsub message must contain either non-empty data, or at least one attribute. |

### getTopicName

Required. The name of the Cloud Pub/Sub topic to which messages will
be published when a job is delivered. The topic name must be in the
same format as required by Pub/Sub's
[PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest),
for example `projects/PROJECT_ID/topics/TOPIC_ID`.

The topic must be in the same project as the Cloud Scheduler job.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setTopicName

Required. The name of the Cloud Pub/Sub topic to which messages will
be published when a job is delivered. The topic name must be in the
same format as required by Pub/Sub's
[PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest),
for example `projects/PROJECT_ID/topics/TOPIC_ID`.

The topic must be in the same project as the Cloud Scheduler job.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getData

The message payload for PubsubMessage.

Pubsub message must contain either non-empty data, or at least one
attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setData

The message payload for PubsubMessage.

Pubsub message must contain either non-empty data, or at least one
attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getAttributes

Attributes for PubsubMessage.

Pubsub message must contain either non-empty data, or at least one
attribute.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |   |

### setAttributes

Attributes for PubsubMessage.

Pubsub message must contain either non-empty data, or at least one
attribute.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |