1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import { CallOptions } from 'google-gax';
|
18 | import { google } from '../protos/protos';
|
19 | import { IAM } from './iam';
|
20 | import { Attributes, PublishCallback, Publisher, PublishOptions, PubsubMessage } from './publisher';
|
21 | import { EmptyCallback, EmptyResponse, ExistsCallback, ExistsResponse, ObjectStream, PagedResponse, PageOptions, PubSub, RequestCallback, ResourceCallback } from './pubsub';
|
22 | import { CreateSubscriptionCallback, CreateSubscriptionOptions, CreateSubscriptionResponse, Subscription, SubscriptionOptions } from './subscription';
|
23 | export declare type TopicMetadata = google.pubsub.v1.ITopic;
|
24 | declare type TopicCallback = ResourceCallback<Topic, TopicMetadata>;
|
25 | declare type TopicResponse = [Topic, TopicMetadata];
|
26 | export declare type CreateTopicCallback = TopicCallback;
|
27 | export declare type CreateTopicResponse = TopicResponse;
|
28 | export declare type GetTopicCallback = TopicCallback;
|
29 | export declare type GetTopicResponse = TopicResponse;
|
30 | export declare type GetTopicOptions = CallOptions & {
|
31 | autoCreate?: boolean;
|
32 | };
|
33 | declare type MetadataCallback = RequestCallback<TopicMetadata>;
|
34 | declare type MetadataResponse = [TopicMetadata];
|
35 | export declare type GetTopicMetadataCallback = MetadataCallback;
|
36 | export declare type GetTopicMetadataResponse = MetadataResponse;
|
37 | export declare type SetTopicMetadataCallback = MetadataCallback;
|
38 | export declare type SetTopicMetadataResponse = MetadataResponse;
|
39 | export declare type GetTopicSubscriptionsCallback = RequestCallback<Subscription, google.pubsub.v1.IListTopicSubscriptionsResponse>;
|
40 | export declare type GetTopicSubscriptionsResponse = PagedResponse<Subscription, google.pubsub.v1.IListTopicSubscriptionsResponse>;
|
41 | export declare type MessageOptions = PubsubMessage & {
|
42 | json?: any;
|
43 | };
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | export declare class Topic {
|
62 | name: string;
|
63 | parent: PubSub;
|
64 | pubsub: PubSub;
|
65 | request: typeof PubSub.prototype.request;
|
66 | iam: IAM;
|
67 | metadata?: TopicMetadata;
|
68 | publisher: Publisher;
|
69 | getSubscriptionsStream: () => ObjectStream<Subscription>;
|
70 | constructor(pubsub: PubSub, name: string, options?: PublishOptions);
|
71 | flush(): Promise<void>;
|
72 | flush(callback: EmptyCallback): void;
|
73 | create(gaxOpts?: CallOptions): Promise<CreateTopicResponse>;
|
74 | create(callback: CreateTopicCallback): void;
|
75 | create(gaxOpts: CallOptions, callback: CreateTopicCallback): void;
|
76 | createSubscription(name: string, callback: CreateSubscriptionCallback): void;
|
77 | createSubscription(name: string, options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse>;
|
78 | createSubscription(name: string, options: CreateSubscriptionOptions, callback: CreateSubscriptionCallback): void;
|
79 | delete(callback: EmptyCallback): void;
|
80 | delete(gaxOpts?: CallOptions): Promise<EmptyResponse>;
|
81 | delete(gaxOpts: CallOptions, callback: EmptyCallback): void;
|
82 | exists(): Promise<ExistsResponse>;
|
83 | exists(callback: ExistsCallback): void;
|
84 | get(callback: GetTopicCallback): void;
|
85 | get(gaxOpts?: GetTopicOptions): Promise<GetTopicResponse>;
|
86 | get(gaxOpts: GetTopicOptions, callback: GetTopicCallback): void;
|
87 | getMetadata(callback: GetTopicMetadataCallback): void;
|
88 | getMetadata(gaxOpts: CallOptions, callback: GetTopicMetadataCallback): void;
|
89 | getMetadata(gaxOpts?: CallOptions): Promise<GetTopicMetadataResponse>;
|
90 | getSubscriptions(callback: GetTopicSubscriptionsCallback): void;
|
91 | getSubscriptions(options: PageOptions, callback: GetTopicSubscriptionsCallback): void;
|
92 | getSubscriptions(options?: PageOptions): Promise<GetTopicSubscriptionsResponse>;
|
93 | publish(data: Buffer, attributes?: Attributes): Promise<string>;
|
94 | publish(data: Buffer, callback: PublishCallback): void;
|
95 | publish(data: Buffer, attributes: Attributes, callback: PublishCallback): void;
|
96 | publishJSON(json: object, attributes?: Attributes): Promise<string>;
|
97 | publishJSON(json: object, callback: PublishCallback): void;
|
98 | publishJSON(json: object, attributes: Attributes, callback: PublishCallback): void;
|
99 | publishMessage(message: MessageOptions): Promise<[string]>;
|
100 | publishMessage(message: MessageOptions, callback: PublishCallback): void;
|
101 | /**
|
102 | * In the event that the client fails to publish an ordered message, all
|
103 | * subsequent publish calls using the same ordering key will fail. Calling
|
104 | * this method will disregard the publish failure, allowing the supplied
|
105 | * ordering key to be used again in the future.
|
106 | *
|
107 | * @param {string} orderingKey The ordering key in question.
|
108 | *
|
109 | * @example
|
110 | * const {PubSub} = require('@google-cloud/pubsub');
|
111 | * const pubsub = new PubSub();
|
112 | * const topic = pubsub.topic('my-topic', {messageOrdering: true});
|
113 | *
|
114 | * const orderingKey = 'foo';
|
115 | * const data = Buffer.from('Hello, order!');
|
116 | *
|
117 | * topic.publishMessage({data, orderingKey}, err => {
|
118 | * if (err) {
|
119 | * topic.resumePublishing(orderingKey);
|
120 | * }
|
121 | * });
|
122 | */
|
123 | resumePublishing(orderingKey: string): void;
|
124 | setMetadata(options: TopicMetadata, gaxOpts?: CallOptions): Promise<SetTopicMetadataResponse>;
|
125 | setMetadata(options: TopicMetadata, callback: SetTopicMetadataCallback): void;
|
126 | setMetadata(options: TopicMetadata, gaxOpts: CallOptions, callback: SetTopicMetadataCallback): void;
|
127 | |
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | setPublishOptions(options: PublishOptions): void;
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 | getPublishOptionDefaults(): PublishOptions;
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | subscription(name: string, options?: SubscriptionOptions): Subscription;
|
189 | |
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | static formatName_(projectId: string, name: string): string;
|
198 | }
|
199 | export { PublishOptions };
|