1 | /*!
|
2 | * Copyright 2017 Google Inc. All Rights Reserved.
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import { CallOptions } from 'google-gax';
|
17 | import { google } from '../protos/protos';
|
18 | import { PubSub } from './pubsub';
|
19 | import { EmptyCallback, EmptyResponse, RequestCallback, ResourceCallback } from './pubsub';
|
20 | import { Subscription } from './subscription';
|
21 | export declare type CreateSnapshotCallback = ResourceCallback<Snapshot, google.pubsub.v1.ISnapshot>;
|
22 | export declare type CreateSnapshotResponse = [Snapshot, google.pubsub.v1.ISnapshot];
|
23 | export declare type SeekCallback = RequestCallback<google.pubsub.v1.ISeekResponse>;
|
24 | export declare type SeekResponse = [google.pubsub.v1.ISeekResponse];
|
25 | /**
|
26 | * A Snapshot object will give you access to your Cloud Pub/Sub snapshot.
|
27 | *
|
28 | * Snapshots are sometimes retrieved when using various methods:
|
29 | *
|
30 | * - {@link PubSub#getSnapshots}
|
31 | * - {@link PubSub#getSnapshotsStream}
|
32 | * - {@link PubSub#snapshot}
|
33 | *
|
34 | * Snapshots may be created with:
|
35 | *
|
36 | * - {@link Subscription#createSnapshot}
|
37 | *
|
38 | * You can use snapshots to seek a subscription to a specific point in time.
|
39 | *
|
40 | * - {@link Subscription#seek}
|
41 | *
|
42 | * @class
|
43 | *
|
44 | * @example
|
45 | * //-
|
46 | * // From {@link PubSub#getSnapshots}:
|
47 | * //-
|
48 | * pubsub.getSnapshots((err, snapshots) => {
|
49 | * // `snapshots` is an array of Snapshot objects.
|
50 | * });
|
51 | *
|
52 | * //-
|
53 | * // From {@link PubSub#getSnapshotsStream}:
|
54 | * //-
|
55 | * pubsub.getSnapshotsStream()
|
56 | * .on('error', console.error)
|
57 | * .on('data', (snapshot) => {
|
58 | * // `snapshot` is a Snapshot object.
|
59 | * });
|
60 | *
|
61 | * //-
|
62 | * // From {@link PubSub#snapshot}:
|
63 | * //-
|
64 | * const snapshot = pubsub.snapshot('my-snapshot');
|
65 | * // snapshot is a Snapshot object.
|
66 | *
|
67 | * //-
|
68 | * // Create a snapshot with {module:pubsub/subscription#createSnapshot}:
|
69 | * //-
|
70 | * const subscription = pubsub.subscription('my-subscription');
|
71 | *
|
72 | * subscription.createSnapshot('my-snapshot', (err, snapshot) => {
|
73 | * if (!err) {
|
74 | * // `snapshot` is a Snapshot object.
|
75 | * }
|
76 | * });
|
77 | *
|
78 | * //-
|
79 | * // Seek to your snapshot:
|
80 | * //-
|
81 | * const subscription = pubsub.subscription('my-subscription');
|
82 | *
|
83 | * subscription.seek('my-snapshot', (err) => {
|
84 | * if (err) {
|
85 | * // Error handling omitted.
|
86 | * }
|
87 | * });
|
88 | */
|
89 | export declare class Snapshot {
|
90 | parent: Subscription | PubSub;
|
91 | name: string;
|
92 | metadata?: google.pubsub.v1.ISnapshot;
|
93 | constructor(parent: Subscription | PubSub, name: string);
|
94 | delete(): Promise<EmptyResponse>;
|
95 | delete(callback: EmptyCallback): void;
|
96 | static formatName_(projectId: string, name: string): string;
|
97 | create(gaxOpts?: CallOptions): Promise<CreateSnapshotResponse>;
|
98 | create(callback: CreateSnapshotCallback): void;
|
99 | create(gaxOpts: CallOptions, callback: CreateSnapshotCallback): void;
|
100 | seek(gaxOpts?: CallOptions): Promise<SeekResponse>;
|
101 | seek(callback: SeekCallback): void;
|
102 | seek(gaxOpts: CallOptions, callback: SeekCallback): void;
|
103 | }
|