# Cloud PubSub Client - Class Snapshot (2.19.3)

2.19.3 (latest) 2.19.2 2.18.0 2.17.0 2.16.2 2.15.1 2.14.0 2.13.2 2.12.0 2.11.3 2.10.1 2.9.1 2.8.2 2.7.0 2.6.0 2.5.2 2.4.0 2.3.0 2.2.1 2.1.2 1.50.0 1.49.0 1.48.0 1.47.0 1.46.5 1.45.2 1.44.0 1.43.2 1.42.1 1.41.3 1.40.1 1.39.3 Reference documentation and code samples for the Cloud PubSub Client class Snapshot.

Represents a Pub/Sub Snapshot

Example:

    use Google\Cloud\PubSub\PubSubClient;

    $pubsub = new PubSubClient(['projectId' => 'my-project']);

    $snapshot = $pubsub->snapshot($snapshotName);

## Namespace

Google \\ Cloud \\ PubSub

## Methods

### __construct

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `requestHandler` | `Google\Cloud\Core\RequestHandler` |
| `serializer` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/Serializer.html` The serializer instance to encode/decode messages. |
| `projectId` | `string` The current Project ID. |
| `name` | `string` The snapshot name. |
| `encode` | `bool` Whether certain request arguments should be base64-encoded. |
| `info` | `array` \[optional\] The snapshot data. When creating a Snapshot, this array **must** contain a `$info.subscription` argument with a fully-qualified subscription name. |
| `clientConfig` | `array` \[optional\] Configuration options for the PubSub client used to handle processing of batch items through the daemon. For valid options please see [PubSubClient::__construct()](https://docs.cloud.google.com/php/docs/reference/cloud-pubsub/latest/PubSubClient#_Google_Cloud_PubSub_PubSubClient____construct__). *Defaults to*\* the options provided to the PubSub client associated with this instance. |

### name

Get the Snapshot name.

Example:

    echo $snapshot->name();

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

### info

Get the snapshot info.

Example:

    $info = $snapshot->info();

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### create

Create a new Snapshot.

When creating a snapshot, a subscription name must be supplied at
instantiation.

Please note that this method may not yet be available in your project.

Example:

    $info = $snapshot->create();

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` \[optional\] Configuration options. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### delete

Delete the snapshot.

Please note that this method may not yet be available in your project.

Example:

    $snapshot->delete();

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` \[optional\] Configuration options. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `void` |   |

### topic

Get the Topic attached to the snapshot, if one exists.

Example:

    $topic = $snapshot->topic();

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-pubsub/latest/Topic|null` |   |

### subscription

Get the Subscription attached to the snapshot, if one exists.

Example:

    $subscription = $snapshot->subscription();

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-pubsub/latest/Subscription|null` |   |

### __debugInfo