@@ -201,6 +201,110 @@ class BigQueryConfigBuilder {
201201 std::set<std::string> paths_;
202202};
203203
204+ /* *
205+ * A helper class to build `google::pubsub::v1::CloudStorageConfig` protos.
206+ *
207+ * Makes it easier to create the protobuf messages consumed by
208+ * `SubscriptionAdminClient`. The main advantages are:
209+ *
210+ * - Use a fluent API to set multiple values when constructing complex objects.
211+ * - Automatically compute the set of paths for update requests.
212+ */
213+ class CloudStorageConfigBuilder {
214+ public:
215+ CloudStorageConfigBuilder () = default ;
216+
217+ // / @name Setters for each protocol buffer field.
218+ // /@{
219+ CloudStorageConfigBuilder& set_bucket (std::string bucket) & {
220+ *proto_.mutable_bucket () = std::move (bucket);
221+ paths_.insert (" bucket" );
222+ return *this ;
223+ }
224+ CloudStorageConfigBuilder&& set_bucket(std::string bucket) && {
225+ return std::move (set_bucket (std::move (bucket)));
226+ }
227+
228+ CloudStorageConfigBuilder& set_filename_prefix (
229+ std::string filename_prefix) & {
230+ *proto_.mutable_filename_prefix () = std::move (filename_prefix);
231+ paths_.insert (" filename_prefix" );
232+ return *this ;
233+ }
234+ CloudStorageConfigBuilder&& set_filename_prefix(
235+ std::string filename_prefix) && {
236+ return std::move (set_filename_prefix (std::move (filename_prefix)));
237+ }
238+
239+ CloudStorageConfigBuilder& set_filename_suffix (
240+ std::string filename_suffix) & {
241+ *proto_.mutable_filename_suffix () = std::move (filename_suffix);
242+ paths_.insert (" filename_suffix" );
243+ return *this ;
244+ }
245+ CloudStorageConfigBuilder&& set_filename_suffix(
246+ std::string filename_suffix) && {
247+ return std::move (set_filename_suffix (std::move (filename_suffix)));
248+ }
249+
250+ static google::pubsub::v1::CloudStorageConfig::AvroConfig MakeAvroConfig (
251+ bool write_metadata) {
252+ google::pubsub::v1::CloudStorageConfig::AvroConfig proto;
253+ proto.set_write_metadata (write_metadata);
254+ return proto;
255+ }
256+
257+ CloudStorageConfigBuilder& set_avro_config (
258+ google::pubsub::v1::CloudStorageConfig::AvroConfig avro_config) & {
259+ *proto_.mutable_avro_config () = std::move (avro_config);
260+ paths_.insert (" avro_config" );
261+ return *this ;
262+ }
263+ CloudStorageConfigBuilder&& set_avro_config(
264+ google::pubsub::v1::CloudStorageConfig::AvroConfig avro_config) && {
265+ return std::move (set_avro_config (std::move (avro_config)));
266+ }
267+
268+ template <typename Rep, typename Period>
269+ CloudStorageConfigBuilder& set_max_duration (
270+ std::chrono::duration<Rep, Period> d) & {
271+ *proto_.mutable_max_duration () =
272+ google::cloud::internal::ToDurationProto (d);
273+ paths_.insert (" max_duration" );
274+ return *this ;
275+ }
276+ template <typename Rep, typename Period>
277+ CloudStorageConfigBuilder&& set_max_duration(
278+ std::chrono::duration<Rep, Period> d) && {
279+ return std::move (set_max_duration (d));
280+ }
281+ CloudStorageConfigBuilder& set_max_duration (
282+ google::protobuf::Duration const & d) & {
283+ *proto_.mutable_max_duration () = d;
284+ paths_.insert (" max_duration" );
285+ return *this ;
286+ }
287+ CloudStorageConfigBuilder&& set_max_duration(
288+ google::protobuf::Duration const & d) && {
289+ return std::move (set_max_duration (d));
290+ }
291+
292+ CloudStorageConfigBuilder& set_max_bytes (int v) & {
293+ proto_.set_max_bytes (v);
294+ paths_.insert (" max_bytes" );
295+ return *this ;
296+ }
297+ CloudStorageConfigBuilder&& set_max_bytes(int v) && {
298+ return std::move (set_max_bytes (v));
299+ }
300+ // /@}
301+
302+ private:
303+ friend class SubscriptionBuilder ;
304+ google::pubsub::v1::CloudStorageConfig proto_;
305+ std::set<std::string> paths_;
306+ };
307+
204308/* *
205309 * Create a Cloud Pub/Sub subscription configuration.
206310 *
@@ -234,6 +338,12 @@ class SubscriptionBuilder {
234338 return std::move (set_bigquery_config (std::move (v)));
235339 }
236340
341+ SubscriptionBuilder& set_cloud_storage_config (CloudStorageConfigBuilder v) &;
342+ SubscriptionBuilder&& set_cloud_storage_config(
343+ CloudStorageConfigBuilder v) && {
344+ return std::move (set_cloud_storage_config (std::move (v)));
345+ }
346+
237347 SubscriptionBuilder& set_ack_deadline (std::chrono::seconds v) & {
238348 proto_.set_ack_deadline_seconds (static_cast <std::int32_t >(v.count ()));
239349 paths_.insert (" ack_deadline_seconds" );
0 commit comments