google_pubsublite1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all PubsubLite related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_pubsublite1 as pubsublite1;
49/// use pubsublite1::api::CancelOperationRequest;
50/// use pubsublite1::{Result, Error};
51/// # async fn dox() {
52/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = PubsubLite::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = CancelOperationRequest::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.admin().projects_locations_operations_cancel(req, "name")
88/// .doit().await;
89///
90/// match result {
91/// Err(e) => match e {
92/// // The Error enum provides details about what exactly happened.
93/// // You can also just use its `Debug`, `Display` or `Error` traits
94/// Error::HttpError(_)
95/// |Error::Io(_)
96/// |Error::MissingAPIKey
97/// |Error::MissingToken(_)
98/// |Error::Cancelled
99/// |Error::UploadSizeLimitExceeded(_, _)
100/// |Error::Failure(_)
101/// |Error::BadRequest(_)
102/// |Error::FieldClash(_)
103/// |Error::JsonDecodeError(_, _) => println!("{}", e),
104/// },
105/// Ok(res) => println!("Success: {:?}", res),
106/// }
107/// # }
108/// ```
109#[derive(Clone)]
110pub struct PubsubLite<C> {
111 pub client: common::Client<C>,
112 pub auth: Box<dyn common::GetToken>,
113 _user_agent: String,
114 _base_url: String,
115 _root_url: String,
116}
117
118impl<C> common::Hub for PubsubLite<C> {}
119
120impl<'a, C> PubsubLite<C> {
121 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> PubsubLite<C> {
122 PubsubLite {
123 client,
124 auth: Box::new(auth),
125 _user_agent: "google-api-rust-client/6.0.0".to_string(),
126 _base_url: "https://pubsublite.googleapis.com/".to_string(),
127 _root_url: "https://pubsublite.googleapis.com/".to_string(),
128 }
129 }
130
131 pub fn admin(&'a self) -> AdminMethods<'a, C> {
132 AdminMethods { hub: self }
133 }
134 pub fn cursor(&'a self) -> CursorMethods<'a, C> {
135 CursorMethods { hub: self }
136 }
137 pub fn topic_stats(&'a self) -> TopicStatMethods<'a, C> {
138 TopicStatMethods { hub: self }
139 }
140
141 /// Set the user-agent header field to use in all requests to the server.
142 /// It defaults to `google-api-rust-client/6.0.0`.
143 ///
144 /// Returns the previously set user-agent.
145 pub fn user_agent(&mut self, agent_name: String) -> String {
146 std::mem::replace(&mut self._user_agent, agent_name)
147 }
148
149 /// Set the base url to use in all requests to the server.
150 /// It defaults to `https://pubsublite.googleapis.com/`.
151 ///
152 /// Returns the previously set base url.
153 pub fn base_url(&mut self, new_base_url: String) -> String {
154 std::mem::replace(&mut self._base_url, new_base_url)
155 }
156
157 /// Set the root url to use in all requests to the server.
158 /// It defaults to `https://pubsublite.googleapis.com/`.
159 ///
160 /// Returns the previously set root url.
161 pub fn root_url(&mut self, new_root_url: String) -> String {
162 std::mem::replace(&mut self._root_url, new_root_url)
163 }
164}
165
166// ############
167// SCHEMAS ###
168// ##########
169/// The request message for Operations.CancelOperation.
170///
171/// # Activities
172///
173/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
174/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
175///
176/// * [projects locations operations cancel admin](AdminProjectLocationOperationCancelCall) (request)
177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
178#[serde_with::serde_as]
179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
180pub struct CancelOperationRequest {
181 _never_set: Option<bool>,
182}
183
184impl common::RequestValue for CancelOperationRequest {}
185
186/// The throughput capacity configuration for each partition.
187///
188/// This type is not used in any activity, and only used as *part* of another schema.
189///
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct Capacity {
194 /// Publish throughput capacity per partition in MiB/s. Must be >= 4 and <= 16.
195 #[serde(rename = "publishMibPerSec")]
196 pub publish_mib_per_sec: Option<i32>,
197 /// Subscribe throughput capacity per partition in MiB/s. Must be >= 4 and <= 32.
198 #[serde(rename = "subscribeMibPerSec")]
199 pub subscribe_mib_per_sec: Option<i32>,
200}
201
202impl common::Part for Capacity {}
203
204/// Request for CommitCursor.
205///
206/// # Activities
207///
208/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
209/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
210///
211/// * [projects locations subscriptions commit cursor cursor](CursorProjectLocationSubscriptionCommitCursorCall) (request)
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct CommitCursorRequest {
216 /// The new value for the committed cursor.
217 pub cursor: Option<Cursor>,
218 /// The partition for which to update the cursor. Partitions are zero indexed, so `partition` must be in the range [0, topic.num_partitions).
219 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
220 pub partition: Option<i64>,
221}
222
223impl common::RequestValue for CommitCursorRequest {}
224
225/// Response for CommitCursor.
226///
227/// # Activities
228///
229/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
230/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
231///
232/// * [projects locations subscriptions commit cursor cursor](CursorProjectLocationSubscriptionCommitCursorCall) (response)
233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
234#[serde_with::serde_as]
235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
236pub struct CommitCursorResponse {
237 _never_set: Option<bool>,
238}
239
240impl common::ResponseResult for CommitCursorResponse {}
241
242/// Compute the current head cursor for a partition.
243///
244/// # Activities
245///
246/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
247/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
248///
249/// * [projects locations topics compute head cursor topic stats](TopicStatProjectLocationTopicComputeHeadCursorCall) (request)
250#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
251#[serde_with::serde_as]
252#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
253pub struct ComputeHeadCursorRequest {
254 /// Required. The partition for which we should compute the head cursor.
255 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
256 pub partition: Option<i64>,
257}
258
259impl common::RequestValue for ComputeHeadCursorRequest {}
260
261/// Response containing the head cursor for the requested topic and partition.
262///
263/// # Activities
264///
265/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
266/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
267///
268/// * [projects locations topics compute head cursor topic stats](TopicStatProjectLocationTopicComputeHeadCursorCall) (response)
269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
270#[serde_with::serde_as]
271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
272pub struct ComputeHeadCursorResponse {
273 /// The head cursor.
274 #[serde(rename = "headCursor")]
275 pub head_cursor: Option<Cursor>,
276}
277
278impl common::ResponseResult for ComputeHeadCursorResponse {}
279
280/// Compute statistics about a range of messages in a given topic and partition.
281///
282/// # Activities
283///
284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
286///
287/// * [projects locations topics compute message stats topic stats](TopicStatProjectLocationTopicComputeMessageStatCall) (request)
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct ComputeMessageStatsRequest {
292 /// The exclusive end of the range. The range is empty if end_cursor <= start_cursor. Specifying a start_cursor before the first message and an end_cursor after the last message will retrieve all messages.
293 #[serde(rename = "endCursor")]
294 pub end_cursor: Option<Cursor>,
295 /// Required. The partition for which we should compute message stats.
296 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
297 pub partition: Option<i64>,
298 /// The inclusive start of the range.
299 #[serde(rename = "startCursor")]
300 pub start_cursor: Option<Cursor>,
301}
302
303impl common::RequestValue for ComputeMessageStatsRequest {}
304
305/// Response containing stats for messages in the requested topic and partition.
306///
307/// # Activities
308///
309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
311///
312/// * [projects locations topics compute message stats topic stats](TopicStatProjectLocationTopicComputeMessageStatCall) (response)
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct ComputeMessageStatsResponse {
317 /// The number of quota bytes accounted to these messages.
318 #[serde(rename = "messageBytes")]
319 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
320 pub message_bytes: Option<i64>,
321 /// The count of messages.
322 #[serde(rename = "messageCount")]
323 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
324 pub message_count: Option<i64>,
325 /// The minimum event timestamp across these messages. For the purposes of this computation, if a message does not have an event time, we use the publish time. The timestamp will be unset if there are no messages.
326 #[serde(rename = "minimumEventTime")]
327 pub minimum_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
328 /// The minimum publish timestamp across these messages. Note that publish timestamps within a partition are not guaranteed to be non-decreasing. The timestamp will be unset if there are no messages.
329 #[serde(rename = "minimumPublishTime")]
330 pub minimum_publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
331}
332
333impl common::ResponseResult for ComputeMessageStatsResponse {}
334
335/// Compute the corresponding cursor for a publish or event time in a topic partition.
336///
337/// # Activities
338///
339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
341///
342/// * [projects locations topics compute time cursor topic stats](TopicStatProjectLocationTopicComputeTimeCursorCall) (request)
343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
344#[serde_with::serde_as]
345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
346pub struct ComputeTimeCursorRequest {
347 /// Required. The partition for which we should compute the cursor.
348 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
349 pub partition: Option<i64>,
350 /// Required. The target publish or event time. Specifying a future time will return an unset cursor.
351 pub target: Option<TimeTarget>,
352}
353
354impl common::RequestValue for ComputeTimeCursorRequest {}
355
356/// Response containing the cursor corresponding to a publish or event time in a topic partition.
357///
358/// # Activities
359///
360/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
361/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
362///
363/// * [projects locations topics compute time cursor topic stats](TopicStatProjectLocationTopicComputeTimeCursorCall) (response)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct ComputeTimeCursorResponse {
368 /// If present, the cursor references the first message with time greater than or equal to the specified target time. If such a message cannot be found, the cursor will be unset (i.e. `cursor` is not present).
369 pub cursor: Option<Cursor>,
370}
371
372impl common::ResponseResult for ComputeTimeCursorResponse {}
373
374/// A cursor that describes the position of a message within a topic partition.
375///
376/// This type is not used in any activity, and only used as *part* of another schema.
377///
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct Cursor {
382 /// The offset of a message within a topic partition. Must be greater than or equal 0.
383 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
384 pub offset: Option<i64>,
385}
386
387impl common::Part for Cursor {}
388
389/// The settings for a subscription's message delivery.
390///
391/// This type is not used in any activity, and only used as *part* of another schema.
392///
393#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
394#[serde_with::serde_as]
395#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
396pub struct DeliveryConfig {
397 /// The DeliveryRequirement for this subscription.
398 #[serde(rename = "deliveryRequirement")]
399 pub delivery_requirement: Option<String>,
400}
401
402impl common::Part for DeliveryConfig {}
403
404/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
405///
406/// # Activities
407///
408/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
409/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
410///
411/// * [projects locations operations cancel admin](AdminProjectLocationOperationCancelCall) (response)
412/// * [projects locations operations delete admin](AdminProjectLocationOperationDeleteCall) (response)
413/// * [projects locations reservations delete admin](AdminProjectLocationReservationDeleteCall) (response)
414/// * [projects locations subscriptions delete admin](AdminProjectLocationSubscriptionDeleteCall) (response)
415/// * [projects locations topics delete admin](AdminProjectLocationTopicDeleteCall) (response)
416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
417#[serde_with::serde_as]
418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
419pub struct Empty {
420 _never_set: Option<bool>,
421}
422
423impl common::ResponseResult for Empty {}
424
425/// Configuration for a Pub/Sub Lite subscription that writes messages to a destination. User subscriber clients must not connect to this subscription.
426///
427/// This type is not used in any activity, and only used as *part* of another schema.
428///
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as]
431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
432pub struct ExportConfig {
433 /// Output only. The current state of the export, which may be different to the desired state due to errors. This field is output only.
434 #[serde(rename = "currentState")]
435 pub current_state: Option<String>,
436 /// Optional. The name of an optional Pub/Sub Lite topic to publish messages that can not be exported to the destination. For example, the message can not be published to the Pub/Sub service because it does not satisfy the constraints documented at https://cloud.google.com/pubsub/docs/publisher. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}. Must be within the same project and location as the subscription. The topic may be changed or removed.
437 #[serde(rename = "deadLetterTopic")]
438 pub dead_letter_topic: Option<String>,
439 /// The desired state of this export. Setting this to values other than `ACTIVE` and `PAUSED` will result in an error.
440 #[serde(rename = "desiredState")]
441 pub desired_state: Option<String>,
442 /// Messages are automatically written from the Pub/Sub Lite topic associated with this subscription to a Pub/Sub topic.
443 #[serde(rename = "pubsubConfig")]
444 pub pubsub_config: Option<PubSubConfig>,
445}
446
447impl common::Part for ExportConfig {}
448
449/// The response message for Operations.ListOperations.
450///
451/// # Activities
452///
453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
455///
456/// * [projects locations operations list admin](AdminProjectLocationOperationListCall) (response)
457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
458#[serde_with::serde_as]
459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
460pub struct ListOperationsResponse {
461 /// The standard List next-page token.
462 #[serde(rename = "nextPageToken")]
463 pub next_page_token: Option<String>,
464 /// A list of operations that matches the specified filter in the request.
465 pub operations: Option<Vec<Operation>>,
466}
467
468impl common::ResponseResult for ListOperationsResponse {}
469
470/// Response for ListPartitionCursors
471///
472/// # Activities
473///
474/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
475/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
476///
477/// * [projects locations subscriptions cursors list cursor](CursorProjectLocationSubscriptionCursorListCall) (response)
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct ListPartitionCursorsResponse {
482 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
483 #[serde(rename = "nextPageToken")]
484 pub next_page_token: Option<String>,
485 /// The partition cursors from this request.
486 #[serde(rename = "partitionCursors")]
487 pub partition_cursors: Option<Vec<PartitionCursor>>,
488}
489
490impl common::ResponseResult for ListPartitionCursorsResponse {}
491
492/// Response for ListReservationTopics.
493///
494/// # Activities
495///
496/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
497/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
498///
499/// * [projects locations reservations topics list admin](AdminProjectLocationReservationTopicListCall) (response)
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct ListReservationTopicsResponse {
504 /// A token that can be sent as `page_token` to retrieve the next page of results. If this field is omitted, there are no more results.
505 #[serde(rename = "nextPageToken")]
506 pub next_page_token: Option<String>,
507 /// The names of topics attached to the reservation. The order of the topics is unspecified.
508 pub topics: Option<Vec<String>>,
509}
510
511impl common::ResponseResult for ListReservationTopicsResponse {}
512
513/// Response for ListReservations.
514///
515/// # Activities
516///
517/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
518/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
519///
520/// * [projects locations reservations list admin](AdminProjectLocationReservationListCall) (response)
521#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
522#[serde_with::serde_as]
523#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
524pub struct ListReservationsResponse {
525 /// A token that can be sent as `page_token` to retrieve the next page of results. If this field is omitted, there are no more results.
526 #[serde(rename = "nextPageToken")]
527 pub next_page_token: Option<String>,
528 /// The list of reservation in the requested parent. The order of the reservations is unspecified.
529 pub reservations: Option<Vec<Reservation>>,
530}
531
532impl common::ResponseResult for ListReservationsResponse {}
533
534/// Response for ListSubscriptions.
535///
536/// # Activities
537///
538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
540///
541/// * [projects locations subscriptions list admin](AdminProjectLocationSubscriptionListCall) (response)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as]
544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
545pub struct ListSubscriptionsResponse {
546 /// A token that can be sent as `page_token` to retrieve the next page of results. If this field is omitted, there are no more results.
547 #[serde(rename = "nextPageToken")]
548 pub next_page_token: Option<String>,
549 /// The list of subscriptions in the requested parent. The order of the subscriptions is unspecified.
550 pub subscriptions: Option<Vec<Subscription>>,
551}
552
553impl common::ResponseResult for ListSubscriptionsResponse {}
554
555/// Response for ListTopicSubscriptions.
556///
557/// # Activities
558///
559/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
560/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
561///
562/// * [projects locations topics subscriptions list admin](AdminProjectLocationTopicSubscriptionListCall) (response)
563#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
564#[serde_with::serde_as]
565#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
566pub struct ListTopicSubscriptionsResponse {
567 /// A token that can be sent as `page_token` to retrieve the next page of results. If this field is omitted, there are no more results.
568 #[serde(rename = "nextPageToken")]
569 pub next_page_token: Option<String>,
570 /// The names of subscriptions attached to the topic. The order of the subscriptions is unspecified.
571 pub subscriptions: Option<Vec<String>>,
572}
573
574impl common::ResponseResult for ListTopicSubscriptionsResponse {}
575
576/// Response for ListTopics.
577///
578/// # Activities
579///
580/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
581/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
582///
583/// * [projects locations topics list admin](AdminProjectLocationTopicListCall) (response)
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct ListTopicsResponse {
588 /// A token that can be sent as `page_token` to retrieve the next page of results. If this field is omitted, there are no more results.
589 #[serde(rename = "nextPageToken")]
590 pub next_page_token: Option<String>,
591 /// The list of topic in the requested parent. The order of the topics is unspecified.
592 pub topics: Option<Vec<Topic>>,
593}
594
595impl common::ResponseResult for ListTopicsResponse {}
596
597/// This resource represents a long-running operation that is the result of a network API call.
598///
599/// # Activities
600///
601/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
602/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
603///
604/// * [projects locations operations get admin](AdminProjectLocationOperationGetCall) (response)
605/// * [projects locations subscriptions seek admin](AdminProjectLocationSubscriptionSeekCall) (response)
606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
607#[serde_with::serde_as]
608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
609pub struct Operation {
610 /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
611 pub done: Option<bool>,
612 /// The error result of the operation in case of failure or cancellation.
613 pub error: Option<Status>,
614 /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
615 pub metadata: Option<HashMap<String, serde_json::Value>>,
616 /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
617 pub name: Option<String>,
618 /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
619 pub response: Option<HashMap<String, serde_json::Value>>,
620}
621
622impl common::ResponseResult for Operation {}
623
624/// The settings for a topic's partitions.
625///
626/// This type is not used in any activity, and only used as *part* of another schema.
627///
628#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
629#[serde_with::serde_as]
630#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
631pub struct PartitionConfig {
632 /// The capacity configuration.
633 pub capacity: Option<Capacity>,
634 /// The number of partitions in the topic. Must be at least 1. Once a topic has been created the number of partitions can be increased but not decreased. Message ordering is not guaranteed across a topic resize. For more information see https://cloud.google.com/pubsub/lite/docs/topics#scaling_capacity
635 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
636 pub count: Option<i64>,
637 /// DEPRECATED: Use capacity instead which can express a superset of configurations. Every partition in the topic is allocated throughput equivalent to `scale` times the standard partition throughput (4 MiB/s). This is also reflected in the cost of this topic; a topic with `scale` of 2 and count of 10 is charged for 20 partitions. This value must be in the range [1,4].
638 pub scale: Option<i32>,
639}
640
641impl common::Part for PartitionConfig {}
642
643/// A pair of a Cursor and the partition it is for.
644///
645/// This type is not used in any activity, and only used as *part* of another schema.
646///
647#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
648#[serde_with::serde_as]
649#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
650pub struct PartitionCursor {
651 /// The value of the cursor.
652 pub cursor: Option<Cursor>,
653 /// The partition this is for.
654 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
655 pub partition: Option<i64>,
656}
657
658impl common::Part for PartitionCursor {}
659
660/// Configuration for exporting to a Pub/Sub topic.
661///
662/// This type is not used in any activity, and only used as *part* of another schema.
663///
664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
665#[serde_with::serde_as]
666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
667pub struct PubSubConfig {
668 /// The name of the Pub/Sub topic. Structured like: projects/{project_number}/topics/{topic_id}. The topic may be changed.
669 pub topic: Option<String>,
670}
671
672impl common::Part for PubSubConfig {}
673
674/// Metadata about a reservation resource.
675///
676/// # Activities
677///
678/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
679/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
680///
681/// * [projects locations reservations create admin](AdminProjectLocationReservationCreateCall) (request|response)
682/// * [projects locations reservations get admin](AdminProjectLocationReservationGetCall) (response)
683/// * [projects locations reservations patch admin](AdminProjectLocationReservationPatchCall) (request|response)
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct Reservation {
688 /// The name of the reservation. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
689 pub name: Option<String>,
690 /// The reserved throughput capacity. Every unit of throughput capacity is equivalent to 1 MiB/s of published messages or 2 MiB/s of subscribed messages. Any topics which are declared as using capacity from a Reservation will consume resources from this reservation instead of being charged individually.
691 #[serde(rename = "throughputCapacity")]
692 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
693 pub throughput_capacity: Option<i64>,
694}
695
696impl common::RequestValue for Reservation {}
697impl common::ResponseResult for Reservation {}
698
699/// The settings for this topic's Reservation usage.
700///
701/// This type is not used in any activity, and only used as *part* of another schema.
702///
703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
704#[serde_with::serde_as]
705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
706pub struct ReservationConfig {
707 /// The Reservation to use for this topic's throughput capacity. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
708 #[serde(rename = "throughputReservation")]
709 pub throughput_reservation: Option<String>,
710}
711
712impl common::Part for ReservationConfig {}
713
714/// The settings for a topic's message retention.
715///
716/// This type is not used in any activity, and only used as *part* of another schema.
717///
718#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
719#[serde_with::serde_as]
720#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
721pub struct RetentionConfig {
722 /// The provisioned storage, in bytes, per partition. If the number of bytes stored in any of the topic's partitions grows beyond this value, older messages will be dropped to make room for newer ones, regardless of the value of `period`.
723 #[serde(rename = "perPartitionBytes")]
724 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
725 pub per_partition_bytes: Option<i64>,
726 /// How long a published message is retained. If unset, messages will be retained as long as the bytes retained for each partition is below `per_partition_bytes`.
727 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
728 pub period: Option<chrono::Duration>,
729}
730
731impl common::Part for RetentionConfig {}
732
733/// Request for SeekSubscription.
734///
735/// # Activities
736///
737/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
738/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
739///
740/// * [projects locations subscriptions seek admin](AdminProjectLocationSubscriptionSeekCall) (request)
741#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
742#[serde_with::serde_as]
743#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
744pub struct SeekSubscriptionRequest {
745 /// Seek to a named position with respect to the message backlog.
746 #[serde(rename = "namedTarget")]
747 pub named_target: Option<String>,
748 /// Seek to the first message whose publish or event time is greater than or equal to the specified query time. If no such message can be located, will seek to the end of the message backlog.
749 #[serde(rename = "timeTarget")]
750 pub time_target: Option<TimeTarget>,
751}
752
753impl common::RequestValue for SeekSubscriptionRequest {}
754
755/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
756///
757/// This type is not used in any activity, and only used as *part* of another schema.
758///
759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
760#[serde_with::serde_as]
761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
762pub struct Status {
763 /// The status code, which should be an enum value of google.rpc.Code.
764 pub code: Option<i32>,
765 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
766 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
767 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
768 pub message: Option<String>,
769}
770
771impl common::Part for Status {}
772
773/// Metadata about a subscription resource.
774///
775/// # Activities
776///
777/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
778/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
779///
780/// * [projects locations subscriptions create admin](AdminProjectLocationSubscriptionCreateCall) (request|response)
781/// * [projects locations subscriptions get admin](AdminProjectLocationSubscriptionGetCall) (response)
782/// * [projects locations subscriptions patch admin](AdminProjectLocationSubscriptionPatchCall) (request|response)
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct Subscription {
787 /// The settings for this subscription's message delivery.
788 #[serde(rename = "deliveryConfig")]
789 pub delivery_config: Option<DeliveryConfig>,
790 /// If present, messages are automatically written from the Pub/Sub Lite topic associated with this subscription to a destination.
791 #[serde(rename = "exportConfig")]
792 pub export_config: Option<ExportConfig>,
793 /// The name of the subscription. Structured like: projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
794 pub name: Option<String>,
795 /// The name of the topic this subscription is attached to. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
796 pub topic: Option<String>,
797}
798
799impl common::RequestValue for Subscription {}
800impl common::ResponseResult for Subscription {}
801
802/// A target publish or event time. Can be used for seeking to or retrieving the corresponding cursor.
803///
804/// This type is not used in any activity, and only used as *part* of another schema.
805///
806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
807#[serde_with::serde_as]
808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
809pub struct TimeTarget {
810 /// Request the cursor of the first message with event time greater than or equal to `event_time`. If messages are missing an event time, the publish time is used as a fallback. As event times are user supplied, subsequent messages may have event times less than `event_time` and should be filtered by the client, if necessary.
811 #[serde(rename = "eventTime")]
812 pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
813 /// Request the cursor of the first message with publish time greater than or equal to `publish_time`. All messages thereafter are guaranteed to have publish times >= `publish_time`.
814 #[serde(rename = "publishTime")]
815 pub publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
816}
817
818impl common::Part for TimeTarget {}
819
820/// Metadata about a topic resource.
821///
822/// # Activities
823///
824/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
825/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
826///
827/// * [projects locations topics create admin](AdminProjectLocationTopicCreateCall) (request|response)
828/// * [projects locations topics get admin](AdminProjectLocationTopicGetCall) (response)
829/// * [projects locations topics patch admin](AdminProjectLocationTopicPatchCall) (request|response)
830#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
831#[serde_with::serde_as]
832#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
833pub struct Topic {
834 /// The name of the topic. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
835 pub name: Option<String>,
836 /// The settings for this topic's partitions.
837 #[serde(rename = "partitionConfig")]
838 pub partition_config: Option<PartitionConfig>,
839 /// The settings for this topic's Reservation usage.
840 #[serde(rename = "reservationConfig")]
841 pub reservation_config: Option<ReservationConfig>,
842 /// The settings for this topic's message retention.
843 #[serde(rename = "retentionConfig")]
844 pub retention_config: Option<RetentionConfig>,
845}
846
847impl common::RequestValue for Topic {}
848impl common::ResponseResult for Topic {}
849
850/// Response for GetTopicPartitions.
851///
852/// # Activities
853///
854/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
855/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
856///
857/// * [projects locations topics get partitions admin](AdminProjectLocationTopicGetPartitionCall) (response)
858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
859#[serde_with::serde_as]
860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
861pub struct TopicPartitions {
862 /// The number of partitions in the topic.
863 #[serde(rename = "partitionCount")]
864 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
865 pub partition_count: Option<i64>,
866}
867
868impl common::ResponseResult for TopicPartitions {}
869
870// ###################
871// MethodBuilders ###
872// #################
873
874/// A builder providing access to all methods supported on *admin* resources.
875/// It is not used directly, but through the [`PubsubLite`] hub.
876///
877/// # Example
878///
879/// Instantiate a resource builder
880///
881/// ```test_harness,no_run
882/// extern crate hyper;
883/// extern crate hyper_rustls;
884/// extern crate google_pubsublite1 as pubsublite1;
885///
886/// # async fn dox() {
887/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
888///
889/// let secret: yup_oauth2::ApplicationSecret = Default::default();
890/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
891/// secret,
892/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
893/// ).build().await.unwrap();
894///
895/// let client = hyper_util::client::legacy::Client::builder(
896/// hyper_util::rt::TokioExecutor::new()
897/// )
898/// .build(
899/// hyper_rustls::HttpsConnectorBuilder::new()
900/// .with_native_roots()
901/// .unwrap()
902/// .https_or_http()
903/// .enable_http1()
904/// .build()
905/// );
906/// let mut hub = PubsubLite::new(client, auth);
907/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
908/// // like `projects_locations_operations_cancel(...)`, `projects_locations_operations_delete(...)`, `projects_locations_operations_get(...)`, `projects_locations_operations_list(...)`, `projects_locations_reservations_create(...)`, `projects_locations_reservations_delete(...)`, `projects_locations_reservations_get(...)`, `projects_locations_reservations_list(...)`, `projects_locations_reservations_patch(...)`, `projects_locations_reservations_topics_list(...)`, `projects_locations_subscriptions_create(...)`, `projects_locations_subscriptions_delete(...)`, `projects_locations_subscriptions_get(...)`, `projects_locations_subscriptions_list(...)`, `projects_locations_subscriptions_patch(...)`, `projects_locations_subscriptions_seek(...)`, `projects_locations_topics_create(...)`, `projects_locations_topics_delete(...)`, `projects_locations_topics_get(...)`, `projects_locations_topics_get_partitions(...)`, `projects_locations_topics_list(...)`, `projects_locations_topics_patch(...)` and `projects_locations_topics_subscriptions_list(...)`
909/// // to build up your call.
910/// let rb = hub.admin();
911/// # }
912/// ```
913pub struct AdminMethods<'a, C>
914where
915 C: 'a,
916{
917 hub: &'a PubsubLite<C>,
918}
919
920impl<'a, C> common::MethodsBuilder for AdminMethods<'a, C> {}
921
922impl<'a, C> AdminMethods<'a, C> {
923 /// Create a builder to help you perform the following task:
924 ///
925 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
926 ///
927 /// # Arguments
928 ///
929 /// * `request` - No description provided.
930 /// * `name` - The name of the operation resource to be cancelled.
931 pub fn projects_locations_operations_cancel(
932 &self,
933 request: CancelOperationRequest,
934 name: &str,
935 ) -> AdminProjectLocationOperationCancelCall<'a, C> {
936 AdminProjectLocationOperationCancelCall {
937 hub: self.hub,
938 _request: request,
939 _name: name.to_string(),
940 _delegate: Default::default(),
941 _additional_params: Default::default(),
942 _scopes: Default::default(),
943 }
944 }
945
946 /// Create a builder to help you perform the following task:
947 ///
948 /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
949 ///
950 /// # Arguments
951 ///
952 /// * `name` - The name of the operation resource to be deleted.
953 pub fn projects_locations_operations_delete(
954 &self,
955 name: &str,
956 ) -> AdminProjectLocationOperationDeleteCall<'a, C> {
957 AdminProjectLocationOperationDeleteCall {
958 hub: self.hub,
959 _name: name.to_string(),
960 _delegate: Default::default(),
961 _additional_params: Default::default(),
962 _scopes: Default::default(),
963 }
964 }
965
966 /// Create a builder to help you perform the following task:
967 ///
968 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
969 ///
970 /// # Arguments
971 ///
972 /// * `name` - The name of the operation resource.
973 pub fn projects_locations_operations_get(
974 &self,
975 name: &str,
976 ) -> AdminProjectLocationOperationGetCall<'a, C> {
977 AdminProjectLocationOperationGetCall {
978 hub: self.hub,
979 _name: name.to_string(),
980 _delegate: Default::default(),
981 _additional_params: Default::default(),
982 _scopes: Default::default(),
983 }
984 }
985
986 /// Create a builder to help you perform the following task:
987 ///
988 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
989 ///
990 /// # Arguments
991 ///
992 /// * `name` - The name of the operation's parent resource.
993 pub fn projects_locations_operations_list(
994 &self,
995 name: &str,
996 ) -> AdminProjectLocationOperationListCall<'a, C> {
997 AdminProjectLocationOperationListCall {
998 hub: self.hub,
999 _name: name.to_string(),
1000 _page_token: Default::default(),
1001 _page_size: Default::default(),
1002 _filter: Default::default(),
1003 _delegate: Default::default(),
1004 _additional_params: Default::default(),
1005 _scopes: Default::default(),
1006 }
1007 }
1008
1009 /// Create a builder to help you perform the following task:
1010 ///
1011 /// Lists the topics attached to the specified reservation.
1012 ///
1013 /// # Arguments
1014 ///
1015 /// * `name` - Required. The name of the reservation whose topics to list. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1016 pub fn projects_locations_reservations_topics_list(
1017 &self,
1018 name: &str,
1019 ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
1020 AdminProjectLocationReservationTopicListCall {
1021 hub: self.hub,
1022 _name: name.to_string(),
1023 _page_token: Default::default(),
1024 _page_size: Default::default(),
1025 _delegate: Default::default(),
1026 _additional_params: Default::default(),
1027 _scopes: Default::default(),
1028 }
1029 }
1030
1031 /// Create a builder to help you perform the following task:
1032 ///
1033 /// Creates a new reservation.
1034 ///
1035 /// # Arguments
1036 ///
1037 /// * `request` - No description provided.
1038 /// * `parent` - Required. The parent location in which to create the reservation. Structured like `projects/{project_number}/locations/{location}`.
1039 pub fn projects_locations_reservations_create(
1040 &self,
1041 request: Reservation,
1042 parent: &str,
1043 ) -> AdminProjectLocationReservationCreateCall<'a, C> {
1044 AdminProjectLocationReservationCreateCall {
1045 hub: self.hub,
1046 _request: request,
1047 _parent: parent.to_string(),
1048 _reservation_id: Default::default(),
1049 _delegate: Default::default(),
1050 _additional_params: Default::default(),
1051 _scopes: Default::default(),
1052 }
1053 }
1054
1055 /// Create a builder to help you perform the following task:
1056 ///
1057 /// Deletes the specified reservation.
1058 ///
1059 /// # Arguments
1060 ///
1061 /// * `name` - Required. The name of the reservation to delete. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1062 pub fn projects_locations_reservations_delete(
1063 &self,
1064 name: &str,
1065 ) -> AdminProjectLocationReservationDeleteCall<'a, C> {
1066 AdminProjectLocationReservationDeleteCall {
1067 hub: self.hub,
1068 _name: name.to_string(),
1069 _delegate: Default::default(),
1070 _additional_params: Default::default(),
1071 _scopes: Default::default(),
1072 }
1073 }
1074
1075 /// Create a builder to help you perform the following task:
1076 ///
1077 /// Returns the reservation configuration.
1078 ///
1079 /// # Arguments
1080 ///
1081 /// * `name` - Required. The name of the reservation whose configuration to return. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1082 pub fn projects_locations_reservations_get(
1083 &self,
1084 name: &str,
1085 ) -> AdminProjectLocationReservationGetCall<'a, C> {
1086 AdminProjectLocationReservationGetCall {
1087 hub: self.hub,
1088 _name: name.to_string(),
1089 _delegate: Default::default(),
1090 _additional_params: Default::default(),
1091 _scopes: Default::default(),
1092 }
1093 }
1094
1095 /// Create a builder to help you perform the following task:
1096 ///
1097 /// Returns the list of reservations for the given project.
1098 ///
1099 /// # Arguments
1100 ///
1101 /// * `parent` - Required. The parent whose reservations are to be listed. Structured like `projects/{project_number}/locations/{location}`.
1102 pub fn projects_locations_reservations_list(
1103 &self,
1104 parent: &str,
1105 ) -> AdminProjectLocationReservationListCall<'a, C> {
1106 AdminProjectLocationReservationListCall {
1107 hub: self.hub,
1108 _parent: parent.to_string(),
1109 _page_token: Default::default(),
1110 _page_size: Default::default(),
1111 _delegate: Default::default(),
1112 _additional_params: Default::default(),
1113 _scopes: Default::default(),
1114 }
1115 }
1116
1117 /// Create a builder to help you perform the following task:
1118 ///
1119 /// Updates properties of the specified reservation.
1120 ///
1121 /// # Arguments
1122 ///
1123 /// * `request` - No description provided.
1124 /// * `name` - The name of the reservation. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1125 pub fn projects_locations_reservations_patch(
1126 &self,
1127 request: Reservation,
1128 name: &str,
1129 ) -> AdminProjectLocationReservationPatchCall<'a, C> {
1130 AdminProjectLocationReservationPatchCall {
1131 hub: self.hub,
1132 _request: request,
1133 _name: name.to_string(),
1134 _update_mask: Default::default(),
1135 _delegate: Default::default(),
1136 _additional_params: Default::default(),
1137 _scopes: Default::default(),
1138 }
1139 }
1140
1141 /// Create a builder to help you perform the following task:
1142 ///
1143 /// Creates a new subscription.
1144 ///
1145 /// # Arguments
1146 ///
1147 /// * `request` - No description provided.
1148 /// * `parent` - Required. The parent location in which to create the subscription. Structured like `projects/{project_number}/locations/{location}`.
1149 pub fn projects_locations_subscriptions_create(
1150 &self,
1151 request: Subscription,
1152 parent: &str,
1153 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
1154 AdminProjectLocationSubscriptionCreateCall {
1155 hub: self.hub,
1156 _request: request,
1157 _parent: parent.to_string(),
1158 _subscription_id: Default::default(),
1159 _skip_backlog: Default::default(),
1160 _delegate: Default::default(),
1161 _additional_params: Default::default(),
1162 _scopes: Default::default(),
1163 }
1164 }
1165
1166 /// Create a builder to help you perform the following task:
1167 ///
1168 /// Deletes the specified subscription.
1169 ///
1170 /// # Arguments
1171 ///
1172 /// * `name` - Required. The name of the subscription to delete.
1173 pub fn projects_locations_subscriptions_delete(
1174 &self,
1175 name: &str,
1176 ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
1177 AdminProjectLocationSubscriptionDeleteCall {
1178 hub: self.hub,
1179 _name: name.to_string(),
1180 _delegate: Default::default(),
1181 _additional_params: Default::default(),
1182 _scopes: Default::default(),
1183 }
1184 }
1185
1186 /// Create a builder to help you perform the following task:
1187 ///
1188 /// Returns the subscription configuration.
1189 ///
1190 /// # Arguments
1191 ///
1192 /// * `name` - Required. The name of the subscription whose configuration to return.
1193 pub fn projects_locations_subscriptions_get(
1194 &self,
1195 name: &str,
1196 ) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
1197 AdminProjectLocationSubscriptionGetCall {
1198 hub: self.hub,
1199 _name: name.to_string(),
1200 _delegate: Default::default(),
1201 _additional_params: Default::default(),
1202 _scopes: Default::default(),
1203 }
1204 }
1205
1206 /// Create a builder to help you perform the following task:
1207 ///
1208 /// Returns the list of subscriptions for the given project.
1209 ///
1210 /// # Arguments
1211 ///
1212 /// * `parent` - Required. The parent whose subscriptions are to be listed. Structured like `projects/{project_number}/locations/{location}`.
1213 pub fn projects_locations_subscriptions_list(
1214 &self,
1215 parent: &str,
1216 ) -> AdminProjectLocationSubscriptionListCall<'a, C> {
1217 AdminProjectLocationSubscriptionListCall {
1218 hub: self.hub,
1219 _parent: parent.to_string(),
1220 _page_token: Default::default(),
1221 _page_size: Default::default(),
1222 _delegate: Default::default(),
1223 _additional_params: Default::default(),
1224 _scopes: Default::default(),
1225 }
1226 }
1227
1228 /// Create a builder to help you perform the following task:
1229 ///
1230 /// Updates properties of the specified subscription.
1231 ///
1232 /// # Arguments
1233 ///
1234 /// * `request` - No description provided.
1235 /// * `name` - The name of the subscription. Structured like: projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
1236 pub fn projects_locations_subscriptions_patch(
1237 &self,
1238 request: Subscription,
1239 name: &str,
1240 ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
1241 AdminProjectLocationSubscriptionPatchCall {
1242 hub: self.hub,
1243 _request: request,
1244 _name: name.to_string(),
1245 _update_mask: Default::default(),
1246 _delegate: Default::default(),
1247 _additional_params: Default::default(),
1248 _scopes: Default::default(),
1249 }
1250 }
1251
1252 /// Create a builder to help you perform the following task:
1253 ///
1254 /// Performs an out-of-band seek for a subscription to a specified target, which may be timestamps or named positions within the message backlog. Seek translates these targets to cursors for each partition and orchestrates subscribers to start consuming messages from these seek cursors. If an operation is returned, the seek has been registered and subscribers will eventually receive messages from the seek cursors (i.e. eventual consistency), as long as they are using a minimum supported client library version and not a system that tracks cursors independently of Pub/Sub Lite (e.g. Apache Beam, Dataflow, Spark). The seek operation will fail for unsupported clients. If clients would like to know when subscribers react to the seek (or not), they can poll the operation. The seek operation will succeed and complete once subscribers are ready to receive messages from the seek cursors for all partitions of the topic. This means that the seek operation will not complete until all subscribers come online. If the previous seek operation has not yet completed, it will be aborted and the new invocation of seek will supersede it.
1255 ///
1256 /// # Arguments
1257 ///
1258 /// * `request` - No description provided.
1259 /// * `name` - Required. The name of the subscription to seek.
1260 pub fn projects_locations_subscriptions_seek(
1261 &self,
1262 request: SeekSubscriptionRequest,
1263 name: &str,
1264 ) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
1265 AdminProjectLocationSubscriptionSeekCall {
1266 hub: self.hub,
1267 _request: request,
1268 _name: name.to_string(),
1269 _delegate: Default::default(),
1270 _additional_params: Default::default(),
1271 _scopes: Default::default(),
1272 }
1273 }
1274
1275 /// Create a builder to help you perform the following task:
1276 ///
1277 /// Lists the subscriptions attached to the specified topic.
1278 ///
1279 /// # Arguments
1280 ///
1281 /// * `name` - Required. The name of the topic whose subscriptions to list.
1282 pub fn projects_locations_topics_subscriptions_list(
1283 &self,
1284 name: &str,
1285 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
1286 AdminProjectLocationTopicSubscriptionListCall {
1287 hub: self.hub,
1288 _name: name.to_string(),
1289 _page_token: Default::default(),
1290 _page_size: Default::default(),
1291 _delegate: Default::default(),
1292 _additional_params: Default::default(),
1293 _scopes: Default::default(),
1294 }
1295 }
1296
1297 /// Create a builder to help you perform the following task:
1298 ///
1299 /// Creates a new topic.
1300 ///
1301 /// # Arguments
1302 ///
1303 /// * `request` - No description provided.
1304 /// * `parent` - Required. The parent location in which to create the topic. Structured like `projects/{project_number}/locations/{location}`.
1305 pub fn projects_locations_topics_create(
1306 &self,
1307 request: Topic,
1308 parent: &str,
1309 ) -> AdminProjectLocationTopicCreateCall<'a, C> {
1310 AdminProjectLocationTopicCreateCall {
1311 hub: self.hub,
1312 _request: request,
1313 _parent: parent.to_string(),
1314 _topic_id: Default::default(),
1315 _delegate: Default::default(),
1316 _additional_params: Default::default(),
1317 _scopes: Default::default(),
1318 }
1319 }
1320
1321 /// Create a builder to help you perform the following task:
1322 ///
1323 /// Deletes the specified topic.
1324 ///
1325 /// # Arguments
1326 ///
1327 /// * `name` - Required. The name of the topic to delete.
1328 pub fn projects_locations_topics_delete(
1329 &self,
1330 name: &str,
1331 ) -> AdminProjectLocationTopicDeleteCall<'a, C> {
1332 AdminProjectLocationTopicDeleteCall {
1333 hub: self.hub,
1334 _name: name.to_string(),
1335 _delegate: Default::default(),
1336 _additional_params: Default::default(),
1337 _scopes: Default::default(),
1338 }
1339 }
1340
1341 /// Create a builder to help you perform the following task:
1342 ///
1343 /// Returns the topic configuration.
1344 ///
1345 /// # Arguments
1346 ///
1347 /// * `name` - Required. The name of the topic whose configuration to return.
1348 pub fn projects_locations_topics_get(
1349 &self,
1350 name: &str,
1351 ) -> AdminProjectLocationTopicGetCall<'a, C> {
1352 AdminProjectLocationTopicGetCall {
1353 hub: self.hub,
1354 _name: name.to_string(),
1355 _delegate: Default::default(),
1356 _additional_params: Default::default(),
1357 _scopes: Default::default(),
1358 }
1359 }
1360
1361 /// Create a builder to help you perform the following task:
1362 ///
1363 /// Returns the partition information for the requested topic.
1364 ///
1365 /// # Arguments
1366 ///
1367 /// * `name` - Required. The topic whose partition information to return.
1368 pub fn projects_locations_topics_get_partitions(
1369 &self,
1370 name: &str,
1371 ) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
1372 AdminProjectLocationTopicGetPartitionCall {
1373 hub: self.hub,
1374 _name: name.to_string(),
1375 _delegate: Default::default(),
1376 _additional_params: Default::default(),
1377 _scopes: Default::default(),
1378 }
1379 }
1380
1381 /// Create a builder to help you perform the following task:
1382 ///
1383 /// Returns the list of topics for the given project.
1384 ///
1385 /// # Arguments
1386 ///
1387 /// * `parent` - Required. The parent whose topics are to be listed. Structured like `projects/{project_number}/locations/{location}`.
1388 pub fn projects_locations_topics_list(
1389 &self,
1390 parent: &str,
1391 ) -> AdminProjectLocationTopicListCall<'a, C> {
1392 AdminProjectLocationTopicListCall {
1393 hub: self.hub,
1394 _parent: parent.to_string(),
1395 _page_token: Default::default(),
1396 _page_size: Default::default(),
1397 _delegate: Default::default(),
1398 _additional_params: Default::default(),
1399 _scopes: Default::default(),
1400 }
1401 }
1402
1403 /// Create a builder to help you perform the following task:
1404 ///
1405 /// Updates properties of the specified topic.
1406 ///
1407 /// # Arguments
1408 ///
1409 /// * `request` - No description provided.
1410 /// * `name` - The name of the topic. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
1411 pub fn projects_locations_topics_patch(
1412 &self,
1413 request: Topic,
1414 name: &str,
1415 ) -> AdminProjectLocationTopicPatchCall<'a, C> {
1416 AdminProjectLocationTopicPatchCall {
1417 hub: self.hub,
1418 _request: request,
1419 _name: name.to_string(),
1420 _update_mask: Default::default(),
1421 _delegate: Default::default(),
1422 _additional_params: Default::default(),
1423 _scopes: Default::default(),
1424 }
1425 }
1426}
1427
1428/// A builder providing access to all methods supported on *cursor* resources.
1429/// It is not used directly, but through the [`PubsubLite`] hub.
1430///
1431/// # Example
1432///
1433/// Instantiate a resource builder
1434///
1435/// ```test_harness,no_run
1436/// extern crate hyper;
1437/// extern crate hyper_rustls;
1438/// extern crate google_pubsublite1 as pubsublite1;
1439///
1440/// # async fn dox() {
1441/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1442///
1443/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1444/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1445/// secret,
1446/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1447/// ).build().await.unwrap();
1448///
1449/// let client = hyper_util::client::legacy::Client::builder(
1450/// hyper_util::rt::TokioExecutor::new()
1451/// )
1452/// .build(
1453/// hyper_rustls::HttpsConnectorBuilder::new()
1454/// .with_native_roots()
1455/// .unwrap()
1456/// .https_or_http()
1457/// .enable_http1()
1458/// .build()
1459/// );
1460/// let mut hub = PubsubLite::new(client, auth);
1461/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1462/// // like `projects_locations_subscriptions_commit_cursor(...)` and `projects_locations_subscriptions_cursors_list(...)`
1463/// // to build up your call.
1464/// let rb = hub.cursor();
1465/// # }
1466/// ```
1467pub struct CursorMethods<'a, C>
1468where
1469 C: 'a,
1470{
1471 hub: &'a PubsubLite<C>,
1472}
1473
1474impl<'a, C> common::MethodsBuilder for CursorMethods<'a, C> {}
1475
1476impl<'a, C> CursorMethods<'a, C> {
1477 /// Create a builder to help you perform the following task:
1478 ///
1479 /// Returns all committed cursor information for a subscription.
1480 ///
1481 /// # Arguments
1482 ///
1483 /// * `parent` - Required. The subscription for which to retrieve cursors. Structured like `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
1484 pub fn projects_locations_subscriptions_cursors_list(
1485 &self,
1486 parent: &str,
1487 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
1488 CursorProjectLocationSubscriptionCursorListCall {
1489 hub: self.hub,
1490 _parent: parent.to_string(),
1491 _page_token: Default::default(),
1492 _page_size: Default::default(),
1493 _delegate: Default::default(),
1494 _additional_params: Default::default(),
1495 _scopes: Default::default(),
1496 }
1497 }
1498
1499 /// Create a builder to help you perform the following task:
1500 ///
1501 /// Updates the committed cursor.
1502 ///
1503 /// # Arguments
1504 ///
1505 /// * `request` - No description provided.
1506 /// * `subscription` - The subscription for which to update the cursor.
1507 pub fn projects_locations_subscriptions_commit_cursor(
1508 &self,
1509 request: CommitCursorRequest,
1510 subscription: &str,
1511 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
1512 CursorProjectLocationSubscriptionCommitCursorCall {
1513 hub: self.hub,
1514 _request: request,
1515 _subscription: subscription.to_string(),
1516 _delegate: Default::default(),
1517 _additional_params: Default::default(),
1518 _scopes: Default::default(),
1519 }
1520 }
1521}
1522
1523/// A builder providing access to all methods supported on *topicStat* resources.
1524/// It is not used directly, but through the [`PubsubLite`] hub.
1525///
1526/// # Example
1527///
1528/// Instantiate a resource builder
1529///
1530/// ```test_harness,no_run
1531/// extern crate hyper;
1532/// extern crate hyper_rustls;
1533/// extern crate google_pubsublite1 as pubsublite1;
1534///
1535/// # async fn dox() {
1536/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1537///
1538/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1539/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1540/// secret,
1541/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1542/// ).build().await.unwrap();
1543///
1544/// let client = hyper_util::client::legacy::Client::builder(
1545/// hyper_util::rt::TokioExecutor::new()
1546/// )
1547/// .build(
1548/// hyper_rustls::HttpsConnectorBuilder::new()
1549/// .with_native_roots()
1550/// .unwrap()
1551/// .https_or_http()
1552/// .enable_http1()
1553/// .build()
1554/// );
1555/// let mut hub = PubsubLite::new(client, auth);
1556/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1557/// // like `projects_locations_topics_compute_head_cursor(...)`, `projects_locations_topics_compute_message_stats(...)` and `projects_locations_topics_compute_time_cursor(...)`
1558/// // to build up your call.
1559/// let rb = hub.topic_stats();
1560/// # }
1561/// ```
1562pub struct TopicStatMethods<'a, C>
1563where
1564 C: 'a,
1565{
1566 hub: &'a PubsubLite<C>,
1567}
1568
1569impl<'a, C> common::MethodsBuilder for TopicStatMethods<'a, C> {}
1570
1571impl<'a, C> TopicStatMethods<'a, C> {
1572 /// Create a builder to help you perform the following task:
1573 ///
1574 /// Compute the head cursor for the partition. The head cursor's offset is guaranteed to be less than or equal to all messages which have not yet been acknowledged as published, and greater than the offset of any message whose publish has already been acknowledged. It is zero if there have never been messages in the partition.
1575 ///
1576 /// # Arguments
1577 ///
1578 /// * `request` - No description provided.
1579 /// * `topic` - Required. The topic for which we should compute the head cursor.
1580 pub fn projects_locations_topics_compute_head_cursor(
1581 &self,
1582 request: ComputeHeadCursorRequest,
1583 topic: &str,
1584 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
1585 TopicStatProjectLocationTopicComputeHeadCursorCall {
1586 hub: self.hub,
1587 _request: request,
1588 _topic: topic.to_string(),
1589 _delegate: Default::default(),
1590 _additional_params: Default::default(),
1591 _scopes: Default::default(),
1592 }
1593 }
1594
1595 /// Create a builder to help you perform the following task:
1596 ///
1597 /// Compute statistics about a range of messages in a given topic and partition.
1598 ///
1599 /// # Arguments
1600 ///
1601 /// * `request` - No description provided.
1602 /// * `topic` - Required. The topic for which we should compute message stats.
1603 pub fn projects_locations_topics_compute_message_stats(
1604 &self,
1605 request: ComputeMessageStatsRequest,
1606 topic: &str,
1607 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
1608 TopicStatProjectLocationTopicComputeMessageStatCall {
1609 hub: self.hub,
1610 _request: request,
1611 _topic: topic.to_string(),
1612 _delegate: Default::default(),
1613 _additional_params: Default::default(),
1614 _scopes: Default::default(),
1615 }
1616 }
1617
1618 /// Create a builder to help you perform the following task:
1619 ///
1620 /// Compute the corresponding cursor for a publish or event time in a topic partition.
1621 ///
1622 /// # Arguments
1623 ///
1624 /// * `request` - No description provided.
1625 /// * `topic` - Required. The topic for which we should compute the cursor.
1626 pub fn projects_locations_topics_compute_time_cursor(
1627 &self,
1628 request: ComputeTimeCursorRequest,
1629 topic: &str,
1630 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
1631 TopicStatProjectLocationTopicComputeTimeCursorCall {
1632 hub: self.hub,
1633 _request: request,
1634 _topic: topic.to_string(),
1635 _delegate: Default::default(),
1636 _additional_params: Default::default(),
1637 _scopes: Default::default(),
1638 }
1639 }
1640}
1641
1642// ###################
1643// CallBuilders ###
1644// #################
1645
1646/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
1647///
1648/// A builder for the *projects.locations.operations.cancel* method supported by a *admin* resource.
1649/// It is not used directly, but through a [`AdminMethods`] instance.
1650///
1651/// # Example
1652///
1653/// Instantiate a resource method builder
1654///
1655/// ```test_harness,no_run
1656/// # extern crate hyper;
1657/// # extern crate hyper_rustls;
1658/// # extern crate google_pubsublite1 as pubsublite1;
1659/// use pubsublite1::api::CancelOperationRequest;
1660/// # async fn dox() {
1661/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1662///
1663/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1665/// # secret,
1666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1667/// # ).build().await.unwrap();
1668///
1669/// # let client = hyper_util::client::legacy::Client::builder(
1670/// # hyper_util::rt::TokioExecutor::new()
1671/// # )
1672/// # .build(
1673/// # hyper_rustls::HttpsConnectorBuilder::new()
1674/// # .with_native_roots()
1675/// # .unwrap()
1676/// # .https_or_http()
1677/// # .enable_http1()
1678/// # .build()
1679/// # );
1680/// # let mut hub = PubsubLite::new(client, auth);
1681/// // As the method needs a request, you would usually fill it with the desired information
1682/// // into the respective structure. Some of the parts shown here might not be applicable !
1683/// // Values shown here are possibly random and not representative !
1684/// let mut req = CancelOperationRequest::default();
1685///
1686/// // You can configure optional parameters by calling the respective setters at will, and
1687/// // execute the final call using `doit()`.
1688/// // Values shown here are possibly random and not representative !
1689/// let result = hub.admin().projects_locations_operations_cancel(req, "name")
1690/// .doit().await;
1691/// # }
1692/// ```
1693pub struct AdminProjectLocationOperationCancelCall<'a, C>
1694where
1695 C: 'a,
1696{
1697 hub: &'a PubsubLite<C>,
1698 _request: CancelOperationRequest,
1699 _name: String,
1700 _delegate: Option<&'a mut dyn common::Delegate>,
1701 _additional_params: HashMap<String, String>,
1702 _scopes: BTreeSet<String>,
1703}
1704
1705impl<'a, C> common::CallBuilder for AdminProjectLocationOperationCancelCall<'a, C> {}
1706
1707impl<'a, C> AdminProjectLocationOperationCancelCall<'a, C>
1708where
1709 C: common::Connector,
1710{
1711 /// Perform the operation you have build so far.
1712 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1713 use std::borrow::Cow;
1714 use std::io::{Read, Seek};
1715
1716 use common::{url::Params, ToParts};
1717 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1718
1719 let mut dd = common::DefaultDelegate;
1720 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1721 dlg.begin(common::MethodInfo {
1722 id: "pubsublite.admin.projects.locations.operations.cancel",
1723 http_method: hyper::Method::POST,
1724 });
1725
1726 for &field in ["alt", "name"].iter() {
1727 if self._additional_params.contains_key(field) {
1728 dlg.finished(false);
1729 return Err(common::Error::FieldClash(field));
1730 }
1731 }
1732
1733 let mut params = Params::with_capacity(4 + self._additional_params.len());
1734 params.push("name", self._name);
1735
1736 params.extend(self._additional_params.iter());
1737
1738 params.push("alt", "json");
1739 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}:cancel";
1740 if self._scopes.is_empty() {
1741 self._scopes
1742 .insert(Scope::CloudPlatform.as_ref().to_string());
1743 }
1744
1745 #[allow(clippy::single_element_loop)]
1746 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1747 url = params.uri_replacement(url, param_name, find_this, true);
1748 }
1749 {
1750 let to_remove = ["name"];
1751 params.remove_params(&to_remove);
1752 }
1753
1754 let url = params.parse_with_url(&url);
1755
1756 let mut json_mime_type = mime::APPLICATION_JSON;
1757 let mut request_value_reader = {
1758 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1759 common::remove_json_null_values(&mut value);
1760 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1761 serde_json::to_writer(&mut dst, &value).unwrap();
1762 dst
1763 };
1764 let request_size = request_value_reader
1765 .seek(std::io::SeekFrom::End(0))
1766 .unwrap();
1767 request_value_reader
1768 .seek(std::io::SeekFrom::Start(0))
1769 .unwrap();
1770
1771 loop {
1772 let token = match self
1773 .hub
1774 .auth
1775 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1776 .await
1777 {
1778 Ok(token) => token,
1779 Err(e) => match dlg.token(e) {
1780 Ok(token) => token,
1781 Err(e) => {
1782 dlg.finished(false);
1783 return Err(common::Error::MissingToken(e));
1784 }
1785 },
1786 };
1787 request_value_reader
1788 .seek(std::io::SeekFrom::Start(0))
1789 .unwrap();
1790 let mut req_result = {
1791 let client = &self.hub.client;
1792 dlg.pre_request();
1793 let mut req_builder = hyper::Request::builder()
1794 .method(hyper::Method::POST)
1795 .uri(url.as_str())
1796 .header(USER_AGENT, self.hub._user_agent.clone());
1797
1798 if let Some(token) = token.as_ref() {
1799 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1800 }
1801
1802 let request = req_builder
1803 .header(CONTENT_TYPE, json_mime_type.to_string())
1804 .header(CONTENT_LENGTH, request_size as u64)
1805 .body(common::to_body(
1806 request_value_reader.get_ref().clone().into(),
1807 ));
1808
1809 client.request(request.unwrap()).await
1810 };
1811
1812 match req_result {
1813 Err(err) => {
1814 if let common::Retry::After(d) = dlg.http_error(&err) {
1815 sleep(d).await;
1816 continue;
1817 }
1818 dlg.finished(false);
1819 return Err(common::Error::HttpError(err));
1820 }
1821 Ok(res) => {
1822 let (mut parts, body) = res.into_parts();
1823 let mut body = common::Body::new(body);
1824 if !parts.status.is_success() {
1825 let bytes = common::to_bytes(body).await.unwrap_or_default();
1826 let error = serde_json::from_str(&common::to_string(&bytes));
1827 let response = common::to_response(parts, bytes.into());
1828
1829 if let common::Retry::After(d) =
1830 dlg.http_failure(&response, error.as_ref().ok())
1831 {
1832 sleep(d).await;
1833 continue;
1834 }
1835
1836 dlg.finished(false);
1837
1838 return Err(match error {
1839 Ok(value) => common::Error::BadRequest(value),
1840 _ => common::Error::Failure(response),
1841 });
1842 }
1843 let response = {
1844 let bytes = common::to_bytes(body).await.unwrap_or_default();
1845 let encoded = common::to_string(&bytes);
1846 match serde_json::from_str(&encoded) {
1847 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1848 Err(error) => {
1849 dlg.response_json_decode_error(&encoded, &error);
1850 return Err(common::Error::JsonDecodeError(
1851 encoded.to_string(),
1852 error,
1853 ));
1854 }
1855 }
1856 };
1857
1858 dlg.finished(true);
1859 return Ok(response);
1860 }
1861 }
1862 }
1863 }
1864
1865 ///
1866 /// Sets the *request* property to the given value.
1867 ///
1868 /// Even though the property as already been set when instantiating this call,
1869 /// we provide this method for API completeness.
1870 pub fn request(
1871 mut self,
1872 new_value: CancelOperationRequest,
1873 ) -> AdminProjectLocationOperationCancelCall<'a, C> {
1874 self._request = new_value;
1875 self
1876 }
1877 /// The name of the operation resource to be cancelled.
1878 ///
1879 /// Sets the *name* path property to the given value.
1880 ///
1881 /// Even though the property as already been set when instantiating this call,
1882 /// we provide this method for API completeness.
1883 pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationCancelCall<'a, C> {
1884 self._name = new_value.to_string();
1885 self
1886 }
1887 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1888 /// while executing the actual API request.
1889 ///
1890 /// ````text
1891 /// It should be used to handle progress information, and to implement a certain level of resilience.
1892 /// ````
1893 ///
1894 /// Sets the *delegate* property to the given value.
1895 pub fn delegate(
1896 mut self,
1897 new_value: &'a mut dyn common::Delegate,
1898 ) -> AdminProjectLocationOperationCancelCall<'a, C> {
1899 self._delegate = Some(new_value);
1900 self
1901 }
1902
1903 /// Set any additional parameter of the query string used in the request.
1904 /// It should be used to set parameters which are not yet available through their own
1905 /// setters.
1906 ///
1907 /// Please note that this method must not be used to set any of the known parameters
1908 /// which have their own setter method. If done anyway, the request will fail.
1909 ///
1910 /// # Additional Parameters
1911 ///
1912 /// * *$.xgafv* (query-string) - V1 error format.
1913 /// * *access_token* (query-string) - OAuth access token.
1914 /// * *alt* (query-string) - Data format for response.
1915 /// * *callback* (query-string) - JSONP
1916 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1917 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1918 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1919 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1920 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1921 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1922 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1923 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationCancelCall<'a, C>
1924 where
1925 T: AsRef<str>,
1926 {
1927 self._additional_params
1928 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1929 self
1930 }
1931
1932 /// Identifies the authorization scope for the method you are building.
1933 ///
1934 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1935 /// [`Scope::CloudPlatform`].
1936 ///
1937 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1938 /// tokens for more than one scope.
1939 ///
1940 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1941 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1942 /// sufficient, a read-write scope will do as well.
1943 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationCancelCall<'a, C>
1944 where
1945 St: AsRef<str>,
1946 {
1947 self._scopes.insert(String::from(scope.as_ref()));
1948 self
1949 }
1950 /// Identifies the authorization scope(s) for the method you are building.
1951 ///
1952 /// See [`Self::add_scope()`] for details.
1953 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationCancelCall<'a, C>
1954 where
1955 I: IntoIterator<Item = St>,
1956 St: AsRef<str>,
1957 {
1958 self._scopes
1959 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1960 self
1961 }
1962
1963 /// Removes all scopes, and no default scope will be used either.
1964 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1965 /// for details).
1966 pub fn clear_scopes(mut self) -> AdminProjectLocationOperationCancelCall<'a, C> {
1967 self._scopes.clear();
1968 self
1969 }
1970}
1971
1972/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
1973///
1974/// A builder for the *projects.locations.operations.delete* method supported by a *admin* resource.
1975/// It is not used directly, but through a [`AdminMethods`] instance.
1976///
1977/// # Example
1978///
1979/// Instantiate a resource method builder
1980///
1981/// ```test_harness,no_run
1982/// # extern crate hyper;
1983/// # extern crate hyper_rustls;
1984/// # extern crate google_pubsublite1 as pubsublite1;
1985/// # async fn dox() {
1986/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1987///
1988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1989/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1990/// # secret,
1991/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1992/// # ).build().await.unwrap();
1993///
1994/// # let client = hyper_util::client::legacy::Client::builder(
1995/// # hyper_util::rt::TokioExecutor::new()
1996/// # )
1997/// # .build(
1998/// # hyper_rustls::HttpsConnectorBuilder::new()
1999/// # .with_native_roots()
2000/// # .unwrap()
2001/// # .https_or_http()
2002/// # .enable_http1()
2003/// # .build()
2004/// # );
2005/// # let mut hub = PubsubLite::new(client, auth);
2006/// // You can configure optional parameters by calling the respective setters at will, and
2007/// // execute the final call using `doit()`.
2008/// // Values shown here are possibly random and not representative !
2009/// let result = hub.admin().projects_locations_operations_delete("name")
2010/// .doit().await;
2011/// # }
2012/// ```
2013pub struct AdminProjectLocationOperationDeleteCall<'a, C>
2014where
2015 C: 'a,
2016{
2017 hub: &'a PubsubLite<C>,
2018 _name: String,
2019 _delegate: Option<&'a mut dyn common::Delegate>,
2020 _additional_params: HashMap<String, String>,
2021 _scopes: BTreeSet<String>,
2022}
2023
2024impl<'a, C> common::CallBuilder for AdminProjectLocationOperationDeleteCall<'a, C> {}
2025
2026impl<'a, C> AdminProjectLocationOperationDeleteCall<'a, C>
2027where
2028 C: common::Connector,
2029{
2030 /// Perform the operation you have build so far.
2031 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2032 use std::borrow::Cow;
2033 use std::io::{Read, Seek};
2034
2035 use common::{url::Params, ToParts};
2036 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2037
2038 let mut dd = common::DefaultDelegate;
2039 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2040 dlg.begin(common::MethodInfo {
2041 id: "pubsublite.admin.projects.locations.operations.delete",
2042 http_method: hyper::Method::DELETE,
2043 });
2044
2045 for &field in ["alt", "name"].iter() {
2046 if self._additional_params.contains_key(field) {
2047 dlg.finished(false);
2048 return Err(common::Error::FieldClash(field));
2049 }
2050 }
2051
2052 let mut params = Params::with_capacity(3 + self._additional_params.len());
2053 params.push("name", self._name);
2054
2055 params.extend(self._additional_params.iter());
2056
2057 params.push("alt", "json");
2058 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
2059 if self._scopes.is_empty() {
2060 self._scopes
2061 .insert(Scope::CloudPlatform.as_ref().to_string());
2062 }
2063
2064 #[allow(clippy::single_element_loop)]
2065 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2066 url = params.uri_replacement(url, param_name, find_this, true);
2067 }
2068 {
2069 let to_remove = ["name"];
2070 params.remove_params(&to_remove);
2071 }
2072
2073 let url = params.parse_with_url(&url);
2074
2075 loop {
2076 let token = match self
2077 .hub
2078 .auth
2079 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2080 .await
2081 {
2082 Ok(token) => token,
2083 Err(e) => match dlg.token(e) {
2084 Ok(token) => token,
2085 Err(e) => {
2086 dlg.finished(false);
2087 return Err(common::Error::MissingToken(e));
2088 }
2089 },
2090 };
2091 let mut req_result = {
2092 let client = &self.hub.client;
2093 dlg.pre_request();
2094 let mut req_builder = hyper::Request::builder()
2095 .method(hyper::Method::DELETE)
2096 .uri(url.as_str())
2097 .header(USER_AGENT, self.hub._user_agent.clone());
2098
2099 if let Some(token) = token.as_ref() {
2100 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2101 }
2102
2103 let request = req_builder
2104 .header(CONTENT_LENGTH, 0_u64)
2105 .body(common::to_body::<String>(None));
2106
2107 client.request(request.unwrap()).await
2108 };
2109
2110 match req_result {
2111 Err(err) => {
2112 if let common::Retry::After(d) = dlg.http_error(&err) {
2113 sleep(d).await;
2114 continue;
2115 }
2116 dlg.finished(false);
2117 return Err(common::Error::HttpError(err));
2118 }
2119 Ok(res) => {
2120 let (mut parts, body) = res.into_parts();
2121 let mut body = common::Body::new(body);
2122 if !parts.status.is_success() {
2123 let bytes = common::to_bytes(body).await.unwrap_or_default();
2124 let error = serde_json::from_str(&common::to_string(&bytes));
2125 let response = common::to_response(parts, bytes.into());
2126
2127 if let common::Retry::After(d) =
2128 dlg.http_failure(&response, error.as_ref().ok())
2129 {
2130 sleep(d).await;
2131 continue;
2132 }
2133
2134 dlg.finished(false);
2135
2136 return Err(match error {
2137 Ok(value) => common::Error::BadRequest(value),
2138 _ => common::Error::Failure(response),
2139 });
2140 }
2141 let response = {
2142 let bytes = common::to_bytes(body).await.unwrap_or_default();
2143 let encoded = common::to_string(&bytes);
2144 match serde_json::from_str(&encoded) {
2145 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2146 Err(error) => {
2147 dlg.response_json_decode_error(&encoded, &error);
2148 return Err(common::Error::JsonDecodeError(
2149 encoded.to_string(),
2150 error,
2151 ));
2152 }
2153 }
2154 };
2155
2156 dlg.finished(true);
2157 return Ok(response);
2158 }
2159 }
2160 }
2161 }
2162
2163 /// The name of the operation resource to be deleted.
2164 ///
2165 /// Sets the *name* path property to the given value.
2166 ///
2167 /// Even though the property as already been set when instantiating this call,
2168 /// we provide this method for API completeness.
2169 pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationDeleteCall<'a, C> {
2170 self._name = new_value.to_string();
2171 self
2172 }
2173 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2174 /// while executing the actual API request.
2175 ///
2176 /// ````text
2177 /// It should be used to handle progress information, and to implement a certain level of resilience.
2178 /// ````
2179 ///
2180 /// Sets the *delegate* property to the given value.
2181 pub fn delegate(
2182 mut self,
2183 new_value: &'a mut dyn common::Delegate,
2184 ) -> AdminProjectLocationOperationDeleteCall<'a, C> {
2185 self._delegate = Some(new_value);
2186 self
2187 }
2188
2189 /// Set any additional parameter of the query string used in the request.
2190 /// It should be used to set parameters which are not yet available through their own
2191 /// setters.
2192 ///
2193 /// Please note that this method must not be used to set any of the known parameters
2194 /// which have their own setter method. If done anyway, the request will fail.
2195 ///
2196 /// # Additional Parameters
2197 ///
2198 /// * *$.xgafv* (query-string) - V1 error format.
2199 /// * *access_token* (query-string) - OAuth access token.
2200 /// * *alt* (query-string) - Data format for response.
2201 /// * *callback* (query-string) - JSONP
2202 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2203 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2204 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2205 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2206 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2207 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2208 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2209 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationDeleteCall<'a, C>
2210 where
2211 T: AsRef<str>,
2212 {
2213 self._additional_params
2214 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2215 self
2216 }
2217
2218 /// Identifies the authorization scope for the method you are building.
2219 ///
2220 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2221 /// [`Scope::CloudPlatform`].
2222 ///
2223 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2224 /// tokens for more than one scope.
2225 ///
2226 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2227 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2228 /// sufficient, a read-write scope will do as well.
2229 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationDeleteCall<'a, C>
2230 where
2231 St: AsRef<str>,
2232 {
2233 self._scopes.insert(String::from(scope.as_ref()));
2234 self
2235 }
2236 /// Identifies the authorization scope(s) for the method you are building.
2237 ///
2238 /// See [`Self::add_scope()`] for details.
2239 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationDeleteCall<'a, C>
2240 where
2241 I: IntoIterator<Item = St>,
2242 St: AsRef<str>,
2243 {
2244 self._scopes
2245 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2246 self
2247 }
2248
2249 /// Removes all scopes, and no default scope will be used either.
2250 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2251 /// for details).
2252 pub fn clear_scopes(mut self) -> AdminProjectLocationOperationDeleteCall<'a, C> {
2253 self._scopes.clear();
2254 self
2255 }
2256}
2257
2258/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
2259///
2260/// A builder for the *projects.locations.operations.get* method supported by a *admin* resource.
2261/// It is not used directly, but through a [`AdminMethods`] instance.
2262///
2263/// # Example
2264///
2265/// Instantiate a resource method builder
2266///
2267/// ```test_harness,no_run
2268/// # extern crate hyper;
2269/// # extern crate hyper_rustls;
2270/// # extern crate google_pubsublite1 as pubsublite1;
2271/// # async fn dox() {
2272/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2273///
2274/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2276/// # secret,
2277/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2278/// # ).build().await.unwrap();
2279///
2280/// # let client = hyper_util::client::legacy::Client::builder(
2281/// # hyper_util::rt::TokioExecutor::new()
2282/// # )
2283/// # .build(
2284/// # hyper_rustls::HttpsConnectorBuilder::new()
2285/// # .with_native_roots()
2286/// # .unwrap()
2287/// # .https_or_http()
2288/// # .enable_http1()
2289/// # .build()
2290/// # );
2291/// # let mut hub = PubsubLite::new(client, auth);
2292/// // You can configure optional parameters by calling the respective setters at will, and
2293/// // execute the final call using `doit()`.
2294/// // Values shown here are possibly random and not representative !
2295/// let result = hub.admin().projects_locations_operations_get("name")
2296/// .doit().await;
2297/// # }
2298/// ```
2299pub struct AdminProjectLocationOperationGetCall<'a, C>
2300where
2301 C: 'a,
2302{
2303 hub: &'a PubsubLite<C>,
2304 _name: String,
2305 _delegate: Option<&'a mut dyn common::Delegate>,
2306 _additional_params: HashMap<String, String>,
2307 _scopes: BTreeSet<String>,
2308}
2309
2310impl<'a, C> common::CallBuilder for AdminProjectLocationOperationGetCall<'a, C> {}
2311
2312impl<'a, C> AdminProjectLocationOperationGetCall<'a, C>
2313where
2314 C: common::Connector,
2315{
2316 /// Perform the operation you have build so far.
2317 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2318 use std::borrow::Cow;
2319 use std::io::{Read, Seek};
2320
2321 use common::{url::Params, ToParts};
2322 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2323
2324 let mut dd = common::DefaultDelegate;
2325 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2326 dlg.begin(common::MethodInfo {
2327 id: "pubsublite.admin.projects.locations.operations.get",
2328 http_method: hyper::Method::GET,
2329 });
2330
2331 for &field in ["alt", "name"].iter() {
2332 if self._additional_params.contains_key(field) {
2333 dlg.finished(false);
2334 return Err(common::Error::FieldClash(field));
2335 }
2336 }
2337
2338 let mut params = Params::with_capacity(3 + self._additional_params.len());
2339 params.push("name", self._name);
2340
2341 params.extend(self._additional_params.iter());
2342
2343 params.push("alt", "json");
2344 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
2345 if self._scopes.is_empty() {
2346 self._scopes
2347 .insert(Scope::CloudPlatform.as_ref().to_string());
2348 }
2349
2350 #[allow(clippy::single_element_loop)]
2351 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2352 url = params.uri_replacement(url, param_name, find_this, true);
2353 }
2354 {
2355 let to_remove = ["name"];
2356 params.remove_params(&to_remove);
2357 }
2358
2359 let url = params.parse_with_url(&url);
2360
2361 loop {
2362 let token = match self
2363 .hub
2364 .auth
2365 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2366 .await
2367 {
2368 Ok(token) => token,
2369 Err(e) => match dlg.token(e) {
2370 Ok(token) => token,
2371 Err(e) => {
2372 dlg.finished(false);
2373 return Err(common::Error::MissingToken(e));
2374 }
2375 },
2376 };
2377 let mut req_result = {
2378 let client = &self.hub.client;
2379 dlg.pre_request();
2380 let mut req_builder = hyper::Request::builder()
2381 .method(hyper::Method::GET)
2382 .uri(url.as_str())
2383 .header(USER_AGENT, self.hub._user_agent.clone());
2384
2385 if let Some(token) = token.as_ref() {
2386 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2387 }
2388
2389 let request = req_builder
2390 .header(CONTENT_LENGTH, 0_u64)
2391 .body(common::to_body::<String>(None));
2392
2393 client.request(request.unwrap()).await
2394 };
2395
2396 match req_result {
2397 Err(err) => {
2398 if let common::Retry::After(d) = dlg.http_error(&err) {
2399 sleep(d).await;
2400 continue;
2401 }
2402 dlg.finished(false);
2403 return Err(common::Error::HttpError(err));
2404 }
2405 Ok(res) => {
2406 let (mut parts, body) = res.into_parts();
2407 let mut body = common::Body::new(body);
2408 if !parts.status.is_success() {
2409 let bytes = common::to_bytes(body).await.unwrap_or_default();
2410 let error = serde_json::from_str(&common::to_string(&bytes));
2411 let response = common::to_response(parts, bytes.into());
2412
2413 if let common::Retry::After(d) =
2414 dlg.http_failure(&response, error.as_ref().ok())
2415 {
2416 sleep(d).await;
2417 continue;
2418 }
2419
2420 dlg.finished(false);
2421
2422 return Err(match error {
2423 Ok(value) => common::Error::BadRequest(value),
2424 _ => common::Error::Failure(response),
2425 });
2426 }
2427 let response = {
2428 let bytes = common::to_bytes(body).await.unwrap_or_default();
2429 let encoded = common::to_string(&bytes);
2430 match serde_json::from_str(&encoded) {
2431 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2432 Err(error) => {
2433 dlg.response_json_decode_error(&encoded, &error);
2434 return Err(common::Error::JsonDecodeError(
2435 encoded.to_string(),
2436 error,
2437 ));
2438 }
2439 }
2440 };
2441
2442 dlg.finished(true);
2443 return Ok(response);
2444 }
2445 }
2446 }
2447 }
2448
2449 /// The name of the operation resource.
2450 ///
2451 /// Sets the *name* path property to the given value.
2452 ///
2453 /// Even though the property as already been set when instantiating this call,
2454 /// we provide this method for API completeness.
2455 pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationGetCall<'a, C> {
2456 self._name = new_value.to_string();
2457 self
2458 }
2459 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2460 /// while executing the actual API request.
2461 ///
2462 /// ````text
2463 /// It should be used to handle progress information, and to implement a certain level of resilience.
2464 /// ````
2465 ///
2466 /// Sets the *delegate* property to the given value.
2467 pub fn delegate(
2468 mut self,
2469 new_value: &'a mut dyn common::Delegate,
2470 ) -> AdminProjectLocationOperationGetCall<'a, C> {
2471 self._delegate = Some(new_value);
2472 self
2473 }
2474
2475 /// Set any additional parameter of the query string used in the request.
2476 /// It should be used to set parameters which are not yet available through their own
2477 /// setters.
2478 ///
2479 /// Please note that this method must not be used to set any of the known parameters
2480 /// which have their own setter method. If done anyway, the request will fail.
2481 ///
2482 /// # Additional Parameters
2483 ///
2484 /// * *$.xgafv* (query-string) - V1 error format.
2485 /// * *access_token* (query-string) - OAuth access token.
2486 /// * *alt* (query-string) - Data format for response.
2487 /// * *callback* (query-string) - JSONP
2488 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2489 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2490 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2491 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2492 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2493 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2494 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2495 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationGetCall<'a, C>
2496 where
2497 T: AsRef<str>,
2498 {
2499 self._additional_params
2500 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2501 self
2502 }
2503
2504 /// Identifies the authorization scope for the method you are building.
2505 ///
2506 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2507 /// [`Scope::CloudPlatform`].
2508 ///
2509 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2510 /// tokens for more than one scope.
2511 ///
2512 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2513 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2514 /// sufficient, a read-write scope will do as well.
2515 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationGetCall<'a, C>
2516 where
2517 St: AsRef<str>,
2518 {
2519 self._scopes.insert(String::from(scope.as_ref()));
2520 self
2521 }
2522 /// Identifies the authorization scope(s) for the method you are building.
2523 ///
2524 /// See [`Self::add_scope()`] for details.
2525 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationGetCall<'a, C>
2526 where
2527 I: IntoIterator<Item = St>,
2528 St: AsRef<str>,
2529 {
2530 self._scopes
2531 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2532 self
2533 }
2534
2535 /// Removes all scopes, and no default scope will be used either.
2536 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2537 /// for details).
2538 pub fn clear_scopes(mut self) -> AdminProjectLocationOperationGetCall<'a, C> {
2539 self._scopes.clear();
2540 self
2541 }
2542}
2543
2544/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2545///
2546/// A builder for the *projects.locations.operations.list* method supported by a *admin* resource.
2547/// It is not used directly, but through a [`AdminMethods`] instance.
2548///
2549/// # Example
2550///
2551/// Instantiate a resource method builder
2552///
2553/// ```test_harness,no_run
2554/// # extern crate hyper;
2555/// # extern crate hyper_rustls;
2556/// # extern crate google_pubsublite1 as pubsublite1;
2557/// # async fn dox() {
2558/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2559///
2560/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2561/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2562/// # secret,
2563/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2564/// # ).build().await.unwrap();
2565///
2566/// # let client = hyper_util::client::legacy::Client::builder(
2567/// # hyper_util::rt::TokioExecutor::new()
2568/// # )
2569/// # .build(
2570/// # hyper_rustls::HttpsConnectorBuilder::new()
2571/// # .with_native_roots()
2572/// # .unwrap()
2573/// # .https_or_http()
2574/// # .enable_http1()
2575/// # .build()
2576/// # );
2577/// # let mut hub = PubsubLite::new(client, auth);
2578/// // You can configure optional parameters by calling the respective setters at will, and
2579/// // execute the final call using `doit()`.
2580/// // Values shown here are possibly random and not representative !
2581/// let result = hub.admin().projects_locations_operations_list("name")
2582/// .page_token("sed")
2583/// .page_size(-2)
2584/// .filter("takimata")
2585/// .doit().await;
2586/// # }
2587/// ```
2588pub struct AdminProjectLocationOperationListCall<'a, C>
2589where
2590 C: 'a,
2591{
2592 hub: &'a PubsubLite<C>,
2593 _name: String,
2594 _page_token: Option<String>,
2595 _page_size: Option<i32>,
2596 _filter: Option<String>,
2597 _delegate: Option<&'a mut dyn common::Delegate>,
2598 _additional_params: HashMap<String, String>,
2599 _scopes: BTreeSet<String>,
2600}
2601
2602impl<'a, C> common::CallBuilder for AdminProjectLocationOperationListCall<'a, C> {}
2603
2604impl<'a, C> AdminProjectLocationOperationListCall<'a, C>
2605where
2606 C: common::Connector,
2607{
2608 /// Perform the operation you have build so far.
2609 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
2610 use std::borrow::Cow;
2611 use std::io::{Read, Seek};
2612
2613 use common::{url::Params, ToParts};
2614 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2615
2616 let mut dd = common::DefaultDelegate;
2617 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2618 dlg.begin(common::MethodInfo {
2619 id: "pubsublite.admin.projects.locations.operations.list",
2620 http_method: hyper::Method::GET,
2621 });
2622
2623 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
2624 if self._additional_params.contains_key(field) {
2625 dlg.finished(false);
2626 return Err(common::Error::FieldClash(field));
2627 }
2628 }
2629
2630 let mut params = Params::with_capacity(6 + self._additional_params.len());
2631 params.push("name", self._name);
2632 if let Some(value) = self._page_token.as_ref() {
2633 params.push("pageToken", value);
2634 }
2635 if let Some(value) = self._page_size.as_ref() {
2636 params.push("pageSize", value.to_string());
2637 }
2638 if let Some(value) = self._filter.as_ref() {
2639 params.push("filter", value);
2640 }
2641
2642 params.extend(self._additional_params.iter());
2643
2644 params.push("alt", "json");
2645 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/operations";
2646 if self._scopes.is_empty() {
2647 self._scopes
2648 .insert(Scope::CloudPlatform.as_ref().to_string());
2649 }
2650
2651 #[allow(clippy::single_element_loop)]
2652 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2653 url = params.uri_replacement(url, param_name, find_this, true);
2654 }
2655 {
2656 let to_remove = ["name"];
2657 params.remove_params(&to_remove);
2658 }
2659
2660 let url = params.parse_with_url(&url);
2661
2662 loop {
2663 let token = match self
2664 .hub
2665 .auth
2666 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2667 .await
2668 {
2669 Ok(token) => token,
2670 Err(e) => match dlg.token(e) {
2671 Ok(token) => token,
2672 Err(e) => {
2673 dlg.finished(false);
2674 return Err(common::Error::MissingToken(e));
2675 }
2676 },
2677 };
2678 let mut req_result = {
2679 let client = &self.hub.client;
2680 dlg.pre_request();
2681 let mut req_builder = hyper::Request::builder()
2682 .method(hyper::Method::GET)
2683 .uri(url.as_str())
2684 .header(USER_AGENT, self.hub._user_agent.clone());
2685
2686 if let Some(token) = token.as_ref() {
2687 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2688 }
2689
2690 let request = req_builder
2691 .header(CONTENT_LENGTH, 0_u64)
2692 .body(common::to_body::<String>(None));
2693
2694 client.request(request.unwrap()).await
2695 };
2696
2697 match req_result {
2698 Err(err) => {
2699 if let common::Retry::After(d) = dlg.http_error(&err) {
2700 sleep(d).await;
2701 continue;
2702 }
2703 dlg.finished(false);
2704 return Err(common::Error::HttpError(err));
2705 }
2706 Ok(res) => {
2707 let (mut parts, body) = res.into_parts();
2708 let mut body = common::Body::new(body);
2709 if !parts.status.is_success() {
2710 let bytes = common::to_bytes(body).await.unwrap_or_default();
2711 let error = serde_json::from_str(&common::to_string(&bytes));
2712 let response = common::to_response(parts, bytes.into());
2713
2714 if let common::Retry::After(d) =
2715 dlg.http_failure(&response, error.as_ref().ok())
2716 {
2717 sleep(d).await;
2718 continue;
2719 }
2720
2721 dlg.finished(false);
2722
2723 return Err(match error {
2724 Ok(value) => common::Error::BadRequest(value),
2725 _ => common::Error::Failure(response),
2726 });
2727 }
2728 let response = {
2729 let bytes = common::to_bytes(body).await.unwrap_or_default();
2730 let encoded = common::to_string(&bytes);
2731 match serde_json::from_str(&encoded) {
2732 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2733 Err(error) => {
2734 dlg.response_json_decode_error(&encoded, &error);
2735 return Err(common::Error::JsonDecodeError(
2736 encoded.to_string(),
2737 error,
2738 ));
2739 }
2740 }
2741 };
2742
2743 dlg.finished(true);
2744 return Ok(response);
2745 }
2746 }
2747 }
2748 }
2749
2750 /// The name of the operation's parent resource.
2751 ///
2752 /// Sets the *name* path property to the given value.
2753 ///
2754 /// Even though the property as already been set when instantiating this call,
2755 /// we provide this method for API completeness.
2756 pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationListCall<'a, C> {
2757 self._name = new_value.to_string();
2758 self
2759 }
2760 /// The standard list page token.
2761 ///
2762 /// Sets the *page token* query property to the given value.
2763 pub fn page_token(mut self, new_value: &str) -> AdminProjectLocationOperationListCall<'a, C> {
2764 self._page_token = Some(new_value.to_string());
2765 self
2766 }
2767 /// The standard list page size.
2768 ///
2769 /// Sets the *page size* query property to the given value.
2770 pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationOperationListCall<'a, C> {
2771 self._page_size = Some(new_value);
2772 self
2773 }
2774 /// The standard list filter.
2775 ///
2776 /// Sets the *filter* query property to the given value.
2777 pub fn filter(mut self, new_value: &str) -> AdminProjectLocationOperationListCall<'a, C> {
2778 self._filter = Some(new_value.to_string());
2779 self
2780 }
2781 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2782 /// while executing the actual API request.
2783 ///
2784 /// ````text
2785 /// It should be used to handle progress information, and to implement a certain level of resilience.
2786 /// ````
2787 ///
2788 /// Sets the *delegate* property to the given value.
2789 pub fn delegate(
2790 mut self,
2791 new_value: &'a mut dyn common::Delegate,
2792 ) -> AdminProjectLocationOperationListCall<'a, C> {
2793 self._delegate = Some(new_value);
2794 self
2795 }
2796
2797 /// Set any additional parameter of the query string used in the request.
2798 /// It should be used to set parameters which are not yet available through their own
2799 /// setters.
2800 ///
2801 /// Please note that this method must not be used to set any of the known parameters
2802 /// which have their own setter method. If done anyway, the request will fail.
2803 ///
2804 /// # Additional Parameters
2805 ///
2806 /// * *$.xgafv* (query-string) - V1 error format.
2807 /// * *access_token* (query-string) - OAuth access token.
2808 /// * *alt* (query-string) - Data format for response.
2809 /// * *callback* (query-string) - JSONP
2810 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2811 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2812 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2813 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2814 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2815 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2816 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2817 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationListCall<'a, C>
2818 where
2819 T: AsRef<str>,
2820 {
2821 self._additional_params
2822 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2823 self
2824 }
2825
2826 /// Identifies the authorization scope for the method you are building.
2827 ///
2828 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2829 /// [`Scope::CloudPlatform`].
2830 ///
2831 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2832 /// tokens for more than one scope.
2833 ///
2834 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2835 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2836 /// sufficient, a read-write scope will do as well.
2837 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationListCall<'a, C>
2838 where
2839 St: AsRef<str>,
2840 {
2841 self._scopes.insert(String::from(scope.as_ref()));
2842 self
2843 }
2844 /// Identifies the authorization scope(s) for the method you are building.
2845 ///
2846 /// See [`Self::add_scope()`] for details.
2847 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationListCall<'a, C>
2848 where
2849 I: IntoIterator<Item = St>,
2850 St: AsRef<str>,
2851 {
2852 self._scopes
2853 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2854 self
2855 }
2856
2857 /// Removes all scopes, and no default scope will be used either.
2858 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2859 /// for details).
2860 pub fn clear_scopes(mut self) -> AdminProjectLocationOperationListCall<'a, C> {
2861 self._scopes.clear();
2862 self
2863 }
2864}
2865
2866/// Lists the topics attached to the specified reservation.
2867///
2868/// A builder for the *projects.locations.reservations.topics.list* method supported by a *admin* resource.
2869/// It is not used directly, but through a [`AdminMethods`] instance.
2870///
2871/// # Example
2872///
2873/// Instantiate a resource method builder
2874///
2875/// ```test_harness,no_run
2876/// # extern crate hyper;
2877/// # extern crate hyper_rustls;
2878/// # extern crate google_pubsublite1 as pubsublite1;
2879/// # async fn dox() {
2880/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2881///
2882/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2884/// # secret,
2885/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2886/// # ).build().await.unwrap();
2887///
2888/// # let client = hyper_util::client::legacy::Client::builder(
2889/// # hyper_util::rt::TokioExecutor::new()
2890/// # )
2891/// # .build(
2892/// # hyper_rustls::HttpsConnectorBuilder::new()
2893/// # .with_native_roots()
2894/// # .unwrap()
2895/// # .https_or_http()
2896/// # .enable_http1()
2897/// # .build()
2898/// # );
2899/// # let mut hub = PubsubLite::new(client, auth);
2900/// // You can configure optional parameters by calling the respective setters at will, and
2901/// // execute the final call using `doit()`.
2902/// // Values shown here are possibly random and not representative !
2903/// let result = hub.admin().projects_locations_reservations_topics_list("name")
2904/// .page_token("duo")
2905/// .page_size(-55)
2906/// .doit().await;
2907/// # }
2908/// ```
2909pub struct AdminProjectLocationReservationTopicListCall<'a, C>
2910where
2911 C: 'a,
2912{
2913 hub: &'a PubsubLite<C>,
2914 _name: String,
2915 _page_token: Option<String>,
2916 _page_size: Option<i32>,
2917 _delegate: Option<&'a mut dyn common::Delegate>,
2918 _additional_params: HashMap<String, String>,
2919 _scopes: BTreeSet<String>,
2920}
2921
2922impl<'a, C> common::CallBuilder for AdminProjectLocationReservationTopicListCall<'a, C> {}
2923
2924impl<'a, C> AdminProjectLocationReservationTopicListCall<'a, C>
2925where
2926 C: common::Connector,
2927{
2928 /// Perform the operation you have build so far.
2929 pub async fn doit(
2930 mut self,
2931 ) -> common::Result<(common::Response, ListReservationTopicsResponse)> {
2932 use std::borrow::Cow;
2933 use std::io::{Read, Seek};
2934
2935 use common::{url::Params, ToParts};
2936 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2937
2938 let mut dd = common::DefaultDelegate;
2939 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2940 dlg.begin(common::MethodInfo {
2941 id: "pubsublite.admin.projects.locations.reservations.topics.list",
2942 http_method: hyper::Method::GET,
2943 });
2944
2945 for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
2946 if self._additional_params.contains_key(field) {
2947 dlg.finished(false);
2948 return Err(common::Error::FieldClash(field));
2949 }
2950 }
2951
2952 let mut params = Params::with_capacity(5 + self._additional_params.len());
2953 params.push("name", self._name);
2954 if let Some(value) = self._page_token.as_ref() {
2955 params.push("pageToken", value);
2956 }
2957 if let Some(value) = self._page_size.as_ref() {
2958 params.push("pageSize", value.to_string());
2959 }
2960
2961 params.extend(self._additional_params.iter());
2962
2963 params.push("alt", "json");
2964 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/topics";
2965 if self._scopes.is_empty() {
2966 self._scopes
2967 .insert(Scope::CloudPlatform.as_ref().to_string());
2968 }
2969
2970 #[allow(clippy::single_element_loop)]
2971 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2972 url = params.uri_replacement(url, param_name, find_this, true);
2973 }
2974 {
2975 let to_remove = ["name"];
2976 params.remove_params(&to_remove);
2977 }
2978
2979 let url = params.parse_with_url(&url);
2980
2981 loop {
2982 let token = match self
2983 .hub
2984 .auth
2985 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2986 .await
2987 {
2988 Ok(token) => token,
2989 Err(e) => match dlg.token(e) {
2990 Ok(token) => token,
2991 Err(e) => {
2992 dlg.finished(false);
2993 return Err(common::Error::MissingToken(e));
2994 }
2995 },
2996 };
2997 let mut req_result = {
2998 let client = &self.hub.client;
2999 dlg.pre_request();
3000 let mut req_builder = hyper::Request::builder()
3001 .method(hyper::Method::GET)
3002 .uri(url.as_str())
3003 .header(USER_AGENT, self.hub._user_agent.clone());
3004
3005 if let Some(token) = token.as_ref() {
3006 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3007 }
3008
3009 let request = req_builder
3010 .header(CONTENT_LENGTH, 0_u64)
3011 .body(common::to_body::<String>(None));
3012
3013 client.request(request.unwrap()).await
3014 };
3015
3016 match req_result {
3017 Err(err) => {
3018 if let common::Retry::After(d) = dlg.http_error(&err) {
3019 sleep(d).await;
3020 continue;
3021 }
3022 dlg.finished(false);
3023 return Err(common::Error::HttpError(err));
3024 }
3025 Ok(res) => {
3026 let (mut parts, body) = res.into_parts();
3027 let mut body = common::Body::new(body);
3028 if !parts.status.is_success() {
3029 let bytes = common::to_bytes(body).await.unwrap_or_default();
3030 let error = serde_json::from_str(&common::to_string(&bytes));
3031 let response = common::to_response(parts, bytes.into());
3032
3033 if let common::Retry::After(d) =
3034 dlg.http_failure(&response, error.as_ref().ok())
3035 {
3036 sleep(d).await;
3037 continue;
3038 }
3039
3040 dlg.finished(false);
3041
3042 return Err(match error {
3043 Ok(value) => common::Error::BadRequest(value),
3044 _ => common::Error::Failure(response),
3045 });
3046 }
3047 let response = {
3048 let bytes = common::to_bytes(body).await.unwrap_or_default();
3049 let encoded = common::to_string(&bytes);
3050 match serde_json::from_str(&encoded) {
3051 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3052 Err(error) => {
3053 dlg.response_json_decode_error(&encoded, &error);
3054 return Err(common::Error::JsonDecodeError(
3055 encoded.to_string(),
3056 error,
3057 ));
3058 }
3059 }
3060 };
3061
3062 dlg.finished(true);
3063 return Ok(response);
3064 }
3065 }
3066 }
3067 }
3068
3069 /// Required. The name of the reservation whose topics to list. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
3070 ///
3071 /// Sets the *name* path property to the given value.
3072 ///
3073 /// Even though the property as already been set when instantiating this call,
3074 /// we provide this method for API completeness.
3075 pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3076 self._name = new_value.to_string();
3077 self
3078 }
3079 /// A page token, received from a previous `ListReservationTopics` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListReservationTopics` must match the call that provided the page token.
3080 ///
3081 /// Sets the *page token* query property to the given value.
3082 pub fn page_token(
3083 mut self,
3084 new_value: &str,
3085 ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3086 self._page_token = Some(new_value.to_string());
3087 self
3088 }
3089 /// The maximum number of topics to return. The service may return fewer than this value. If unset or zero, all topics for the given reservation will be returned.
3090 ///
3091 /// Sets the *page size* query property to the given value.
3092 pub fn page_size(
3093 mut self,
3094 new_value: i32,
3095 ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3096 self._page_size = Some(new_value);
3097 self
3098 }
3099 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3100 /// while executing the actual API request.
3101 ///
3102 /// ````text
3103 /// It should be used to handle progress information, and to implement a certain level of resilience.
3104 /// ````
3105 ///
3106 /// Sets the *delegate* property to the given value.
3107 pub fn delegate(
3108 mut self,
3109 new_value: &'a mut dyn common::Delegate,
3110 ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3111 self._delegate = Some(new_value);
3112 self
3113 }
3114
3115 /// Set any additional parameter of the query string used in the request.
3116 /// It should be used to set parameters which are not yet available through their own
3117 /// setters.
3118 ///
3119 /// Please note that this method must not be used to set any of the known parameters
3120 /// which have their own setter method. If done anyway, the request will fail.
3121 ///
3122 /// # Additional Parameters
3123 ///
3124 /// * *$.xgafv* (query-string) - V1 error format.
3125 /// * *access_token* (query-string) - OAuth access token.
3126 /// * *alt* (query-string) - Data format for response.
3127 /// * *callback* (query-string) - JSONP
3128 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3129 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3130 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3131 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3132 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3133 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3134 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3135 pub fn param<T>(
3136 mut self,
3137 name: T,
3138 value: T,
3139 ) -> AdminProjectLocationReservationTopicListCall<'a, C>
3140 where
3141 T: AsRef<str>,
3142 {
3143 self._additional_params
3144 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3145 self
3146 }
3147
3148 /// Identifies the authorization scope for the method you are building.
3149 ///
3150 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3151 /// [`Scope::CloudPlatform`].
3152 ///
3153 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3154 /// tokens for more than one scope.
3155 ///
3156 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3157 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3158 /// sufficient, a read-write scope will do as well.
3159 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationTopicListCall<'a, C>
3160 where
3161 St: AsRef<str>,
3162 {
3163 self._scopes.insert(String::from(scope.as_ref()));
3164 self
3165 }
3166 /// Identifies the authorization scope(s) for the method you are building.
3167 ///
3168 /// See [`Self::add_scope()`] for details.
3169 pub fn add_scopes<I, St>(
3170 mut self,
3171 scopes: I,
3172 ) -> AdminProjectLocationReservationTopicListCall<'a, C>
3173 where
3174 I: IntoIterator<Item = St>,
3175 St: AsRef<str>,
3176 {
3177 self._scopes
3178 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3179 self
3180 }
3181
3182 /// Removes all scopes, and no default scope will be used either.
3183 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3184 /// for details).
3185 pub fn clear_scopes(mut self) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3186 self._scopes.clear();
3187 self
3188 }
3189}
3190
3191/// Creates a new reservation.
3192///
3193/// A builder for the *projects.locations.reservations.create* method supported by a *admin* resource.
3194/// It is not used directly, but through a [`AdminMethods`] instance.
3195///
3196/// # Example
3197///
3198/// Instantiate a resource method builder
3199///
3200/// ```test_harness,no_run
3201/// # extern crate hyper;
3202/// # extern crate hyper_rustls;
3203/// # extern crate google_pubsublite1 as pubsublite1;
3204/// use pubsublite1::api::Reservation;
3205/// # async fn dox() {
3206/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3207///
3208/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3209/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3210/// # secret,
3211/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3212/// # ).build().await.unwrap();
3213///
3214/// # let client = hyper_util::client::legacy::Client::builder(
3215/// # hyper_util::rt::TokioExecutor::new()
3216/// # )
3217/// # .build(
3218/// # hyper_rustls::HttpsConnectorBuilder::new()
3219/// # .with_native_roots()
3220/// # .unwrap()
3221/// # .https_or_http()
3222/// # .enable_http1()
3223/// # .build()
3224/// # );
3225/// # let mut hub = PubsubLite::new(client, auth);
3226/// // As the method needs a request, you would usually fill it with the desired information
3227/// // into the respective structure. Some of the parts shown here might not be applicable !
3228/// // Values shown here are possibly random and not representative !
3229/// let mut req = Reservation::default();
3230///
3231/// // You can configure optional parameters by calling the respective setters at will, and
3232/// // execute the final call using `doit()`.
3233/// // Values shown here are possibly random and not representative !
3234/// let result = hub.admin().projects_locations_reservations_create(req, "parent")
3235/// .reservation_id("Lorem")
3236/// .doit().await;
3237/// # }
3238/// ```
3239pub struct AdminProjectLocationReservationCreateCall<'a, C>
3240where
3241 C: 'a,
3242{
3243 hub: &'a PubsubLite<C>,
3244 _request: Reservation,
3245 _parent: String,
3246 _reservation_id: Option<String>,
3247 _delegate: Option<&'a mut dyn common::Delegate>,
3248 _additional_params: HashMap<String, String>,
3249 _scopes: BTreeSet<String>,
3250}
3251
3252impl<'a, C> common::CallBuilder for AdminProjectLocationReservationCreateCall<'a, C> {}
3253
3254impl<'a, C> AdminProjectLocationReservationCreateCall<'a, C>
3255where
3256 C: common::Connector,
3257{
3258 /// Perform the operation you have build so far.
3259 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
3260 use std::borrow::Cow;
3261 use std::io::{Read, Seek};
3262
3263 use common::{url::Params, ToParts};
3264 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3265
3266 let mut dd = common::DefaultDelegate;
3267 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3268 dlg.begin(common::MethodInfo {
3269 id: "pubsublite.admin.projects.locations.reservations.create",
3270 http_method: hyper::Method::POST,
3271 });
3272
3273 for &field in ["alt", "parent", "reservationId"].iter() {
3274 if self._additional_params.contains_key(field) {
3275 dlg.finished(false);
3276 return Err(common::Error::FieldClash(field));
3277 }
3278 }
3279
3280 let mut params = Params::with_capacity(5 + self._additional_params.len());
3281 params.push("parent", self._parent);
3282 if let Some(value) = self._reservation_id.as_ref() {
3283 params.push("reservationId", value);
3284 }
3285
3286 params.extend(self._additional_params.iter());
3287
3288 params.push("alt", "json");
3289 let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/reservations";
3290 if self._scopes.is_empty() {
3291 self._scopes
3292 .insert(Scope::CloudPlatform.as_ref().to_string());
3293 }
3294
3295 #[allow(clippy::single_element_loop)]
3296 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3297 url = params.uri_replacement(url, param_name, find_this, true);
3298 }
3299 {
3300 let to_remove = ["parent"];
3301 params.remove_params(&to_remove);
3302 }
3303
3304 let url = params.parse_with_url(&url);
3305
3306 let mut json_mime_type = mime::APPLICATION_JSON;
3307 let mut request_value_reader = {
3308 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3309 common::remove_json_null_values(&mut value);
3310 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3311 serde_json::to_writer(&mut dst, &value).unwrap();
3312 dst
3313 };
3314 let request_size = request_value_reader
3315 .seek(std::io::SeekFrom::End(0))
3316 .unwrap();
3317 request_value_reader
3318 .seek(std::io::SeekFrom::Start(0))
3319 .unwrap();
3320
3321 loop {
3322 let token = match self
3323 .hub
3324 .auth
3325 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3326 .await
3327 {
3328 Ok(token) => token,
3329 Err(e) => match dlg.token(e) {
3330 Ok(token) => token,
3331 Err(e) => {
3332 dlg.finished(false);
3333 return Err(common::Error::MissingToken(e));
3334 }
3335 },
3336 };
3337 request_value_reader
3338 .seek(std::io::SeekFrom::Start(0))
3339 .unwrap();
3340 let mut req_result = {
3341 let client = &self.hub.client;
3342 dlg.pre_request();
3343 let mut req_builder = hyper::Request::builder()
3344 .method(hyper::Method::POST)
3345 .uri(url.as_str())
3346 .header(USER_AGENT, self.hub._user_agent.clone());
3347
3348 if let Some(token) = token.as_ref() {
3349 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3350 }
3351
3352 let request = req_builder
3353 .header(CONTENT_TYPE, json_mime_type.to_string())
3354 .header(CONTENT_LENGTH, request_size as u64)
3355 .body(common::to_body(
3356 request_value_reader.get_ref().clone().into(),
3357 ));
3358
3359 client.request(request.unwrap()).await
3360 };
3361
3362 match req_result {
3363 Err(err) => {
3364 if let common::Retry::After(d) = dlg.http_error(&err) {
3365 sleep(d).await;
3366 continue;
3367 }
3368 dlg.finished(false);
3369 return Err(common::Error::HttpError(err));
3370 }
3371 Ok(res) => {
3372 let (mut parts, body) = res.into_parts();
3373 let mut body = common::Body::new(body);
3374 if !parts.status.is_success() {
3375 let bytes = common::to_bytes(body).await.unwrap_or_default();
3376 let error = serde_json::from_str(&common::to_string(&bytes));
3377 let response = common::to_response(parts, bytes.into());
3378
3379 if let common::Retry::After(d) =
3380 dlg.http_failure(&response, error.as_ref().ok())
3381 {
3382 sleep(d).await;
3383 continue;
3384 }
3385
3386 dlg.finished(false);
3387
3388 return Err(match error {
3389 Ok(value) => common::Error::BadRequest(value),
3390 _ => common::Error::Failure(response),
3391 });
3392 }
3393 let response = {
3394 let bytes = common::to_bytes(body).await.unwrap_or_default();
3395 let encoded = common::to_string(&bytes);
3396 match serde_json::from_str(&encoded) {
3397 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3398 Err(error) => {
3399 dlg.response_json_decode_error(&encoded, &error);
3400 return Err(common::Error::JsonDecodeError(
3401 encoded.to_string(),
3402 error,
3403 ));
3404 }
3405 }
3406 };
3407
3408 dlg.finished(true);
3409 return Ok(response);
3410 }
3411 }
3412 }
3413 }
3414
3415 ///
3416 /// Sets the *request* property to the given value.
3417 ///
3418 /// Even though the property as already been set when instantiating this call,
3419 /// we provide this method for API completeness.
3420 pub fn request(
3421 mut self,
3422 new_value: Reservation,
3423 ) -> AdminProjectLocationReservationCreateCall<'a, C> {
3424 self._request = new_value;
3425 self
3426 }
3427 /// Required. The parent location in which to create the reservation. Structured like `projects/{project_number}/locations/{location}`.
3428 ///
3429 /// Sets the *parent* path property to the given value.
3430 ///
3431 /// Even though the property as already been set when instantiating this call,
3432 /// we provide this method for API completeness.
3433 pub fn parent(mut self, new_value: &str) -> AdminProjectLocationReservationCreateCall<'a, C> {
3434 self._parent = new_value.to_string();
3435 self
3436 }
3437 /// Required. The ID to use for the reservation, which will become the final component of the reservation's name. This value is structured like: `my-reservation-name`.
3438 ///
3439 /// Sets the *reservation id* query property to the given value.
3440 pub fn reservation_id(
3441 mut self,
3442 new_value: &str,
3443 ) -> AdminProjectLocationReservationCreateCall<'a, C> {
3444 self._reservation_id = Some(new_value.to_string());
3445 self
3446 }
3447 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3448 /// while executing the actual API request.
3449 ///
3450 /// ````text
3451 /// It should be used to handle progress information, and to implement a certain level of resilience.
3452 /// ````
3453 ///
3454 /// Sets the *delegate* property to the given value.
3455 pub fn delegate(
3456 mut self,
3457 new_value: &'a mut dyn common::Delegate,
3458 ) -> AdminProjectLocationReservationCreateCall<'a, C> {
3459 self._delegate = Some(new_value);
3460 self
3461 }
3462
3463 /// Set any additional parameter of the query string used in the request.
3464 /// It should be used to set parameters which are not yet available through their own
3465 /// setters.
3466 ///
3467 /// Please note that this method must not be used to set any of the known parameters
3468 /// which have their own setter method. If done anyway, the request will fail.
3469 ///
3470 /// # Additional Parameters
3471 ///
3472 /// * *$.xgafv* (query-string) - V1 error format.
3473 /// * *access_token* (query-string) - OAuth access token.
3474 /// * *alt* (query-string) - Data format for response.
3475 /// * *callback* (query-string) - JSONP
3476 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3477 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3478 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3479 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3480 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3481 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3482 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3483 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationCreateCall<'a, C>
3484 where
3485 T: AsRef<str>,
3486 {
3487 self._additional_params
3488 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3489 self
3490 }
3491
3492 /// Identifies the authorization scope for the method you are building.
3493 ///
3494 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3495 /// [`Scope::CloudPlatform`].
3496 ///
3497 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3498 /// tokens for more than one scope.
3499 ///
3500 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3501 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3502 /// sufficient, a read-write scope will do as well.
3503 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationCreateCall<'a, C>
3504 where
3505 St: AsRef<str>,
3506 {
3507 self._scopes.insert(String::from(scope.as_ref()));
3508 self
3509 }
3510 /// Identifies the authorization scope(s) for the method you are building.
3511 ///
3512 /// See [`Self::add_scope()`] for details.
3513 pub fn add_scopes<I, St>(
3514 mut self,
3515 scopes: I,
3516 ) -> AdminProjectLocationReservationCreateCall<'a, C>
3517 where
3518 I: IntoIterator<Item = St>,
3519 St: AsRef<str>,
3520 {
3521 self._scopes
3522 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3523 self
3524 }
3525
3526 /// Removes all scopes, and no default scope will be used either.
3527 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3528 /// for details).
3529 pub fn clear_scopes(mut self) -> AdminProjectLocationReservationCreateCall<'a, C> {
3530 self._scopes.clear();
3531 self
3532 }
3533}
3534
3535/// Deletes the specified reservation.
3536///
3537/// A builder for the *projects.locations.reservations.delete* method supported by a *admin* resource.
3538/// It is not used directly, but through a [`AdminMethods`] instance.
3539///
3540/// # Example
3541///
3542/// Instantiate a resource method builder
3543///
3544/// ```test_harness,no_run
3545/// # extern crate hyper;
3546/// # extern crate hyper_rustls;
3547/// # extern crate google_pubsublite1 as pubsublite1;
3548/// # async fn dox() {
3549/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3550///
3551/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3552/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3553/// # secret,
3554/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3555/// # ).build().await.unwrap();
3556///
3557/// # let client = hyper_util::client::legacy::Client::builder(
3558/// # hyper_util::rt::TokioExecutor::new()
3559/// # )
3560/// # .build(
3561/// # hyper_rustls::HttpsConnectorBuilder::new()
3562/// # .with_native_roots()
3563/// # .unwrap()
3564/// # .https_or_http()
3565/// # .enable_http1()
3566/// # .build()
3567/// # );
3568/// # let mut hub = PubsubLite::new(client, auth);
3569/// // You can configure optional parameters by calling the respective setters at will, and
3570/// // execute the final call using `doit()`.
3571/// // Values shown here are possibly random and not representative !
3572/// let result = hub.admin().projects_locations_reservations_delete("name")
3573/// .doit().await;
3574/// # }
3575/// ```
3576pub struct AdminProjectLocationReservationDeleteCall<'a, C>
3577where
3578 C: 'a,
3579{
3580 hub: &'a PubsubLite<C>,
3581 _name: String,
3582 _delegate: Option<&'a mut dyn common::Delegate>,
3583 _additional_params: HashMap<String, String>,
3584 _scopes: BTreeSet<String>,
3585}
3586
3587impl<'a, C> common::CallBuilder for AdminProjectLocationReservationDeleteCall<'a, C> {}
3588
3589impl<'a, C> AdminProjectLocationReservationDeleteCall<'a, C>
3590where
3591 C: common::Connector,
3592{
3593 /// Perform the operation you have build so far.
3594 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3595 use std::borrow::Cow;
3596 use std::io::{Read, Seek};
3597
3598 use common::{url::Params, ToParts};
3599 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3600
3601 let mut dd = common::DefaultDelegate;
3602 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3603 dlg.begin(common::MethodInfo {
3604 id: "pubsublite.admin.projects.locations.reservations.delete",
3605 http_method: hyper::Method::DELETE,
3606 });
3607
3608 for &field in ["alt", "name"].iter() {
3609 if self._additional_params.contains_key(field) {
3610 dlg.finished(false);
3611 return Err(common::Error::FieldClash(field));
3612 }
3613 }
3614
3615 let mut params = Params::with_capacity(3 + self._additional_params.len());
3616 params.push("name", self._name);
3617
3618 params.extend(self._additional_params.iter());
3619
3620 params.push("alt", "json");
3621 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
3622 if self._scopes.is_empty() {
3623 self._scopes
3624 .insert(Scope::CloudPlatform.as_ref().to_string());
3625 }
3626
3627 #[allow(clippy::single_element_loop)]
3628 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3629 url = params.uri_replacement(url, param_name, find_this, true);
3630 }
3631 {
3632 let to_remove = ["name"];
3633 params.remove_params(&to_remove);
3634 }
3635
3636 let url = params.parse_with_url(&url);
3637
3638 loop {
3639 let token = match self
3640 .hub
3641 .auth
3642 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3643 .await
3644 {
3645 Ok(token) => token,
3646 Err(e) => match dlg.token(e) {
3647 Ok(token) => token,
3648 Err(e) => {
3649 dlg.finished(false);
3650 return Err(common::Error::MissingToken(e));
3651 }
3652 },
3653 };
3654 let mut req_result = {
3655 let client = &self.hub.client;
3656 dlg.pre_request();
3657 let mut req_builder = hyper::Request::builder()
3658 .method(hyper::Method::DELETE)
3659 .uri(url.as_str())
3660 .header(USER_AGENT, self.hub._user_agent.clone());
3661
3662 if let Some(token) = token.as_ref() {
3663 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3664 }
3665
3666 let request = req_builder
3667 .header(CONTENT_LENGTH, 0_u64)
3668 .body(common::to_body::<String>(None));
3669
3670 client.request(request.unwrap()).await
3671 };
3672
3673 match req_result {
3674 Err(err) => {
3675 if let common::Retry::After(d) = dlg.http_error(&err) {
3676 sleep(d).await;
3677 continue;
3678 }
3679 dlg.finished(false);
3680 return Err(common::Error::HttpError(err));
3681 }
3682 Ok(res) => {
3683 let (mut parts, body) = res.into_parts();
3684 let mut body = common::Body::new(body);
3685 if !parts.status.is_success() {
3686 let bytes = common::to_bytes(body).await.unwrap_or_default();
3687 let error = serde_json::from_str(&common::to_string(&bytes));
3688 let response = common::to_response(parts, bytes.into());
3689
3690 if let common::Retry::After(d) =
3691 dlg.http_failure(&response, error.as_ref().ok())
3692 {
3693 sleep(d).await;
3694 continue;
3695 }
3696
3697 dlg.finished(false);
3698
3699 return Err(match error {
3700 Ok(value) => common::Error::BadRequest(value),
3701 _ => common::Error::Failure(response),
3702 });
3703 }
3704 let response = {
3705 let bytes = common::to_bytes(body).await.unwrap_or_default();
3706 let encoded = common::to_string(&bytes);
3707 match serde_json::from_str(&encoded) {
3708 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3709 Err(error) => {
3710 dlg.response_json_decode_error(&encoded, &error);
3711 return Err(common::Error::JsonDecodeError(
3712 encoded.to_string(),
3713 error,
3714 ));
3715 }
3716 }
3717 };
3718
3719 dlg.finished(true);
3720 return Ok(response);
3721 }
3722 }
3723 }
3724 }
3725
3726 /// Required. The name of the reservation to delete. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
3727 ///
3728 /// Sets the *name* path property to the given value.
3729 ///
3730 /// Even though the property as already been set when instantiating this call,
3731 /// we provide this method for API completeness.
3732 pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationDeleteCall<'a, C> {
3733 self._name = new_value.to_string();
3734 self
3735 }
3736 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3737 /// while executing the actual API request.
3738 ///
3739 /// ````text
3740 /// It should be used to handle progress information, and to implement a certain level of resilience.
3741 /// ````
3742 ///
3743 /// Sets the *delegate* property to the given value.
3744 pub fn delegate(
3745 mut self,
3746 new_value: &'a mut dyn common::Delegate,
3747 ) -> AdminProjectLocationReservationDeleteCall<'a, C> {
3748 self._delegate = Some(new_value);
3749 self
3750 }
3751
3752 /// Set any additional parameter of the query string used in the request.
3753 /// It should be used to set parameters which are not yet available through their own
3754 /// setters.
3755 ///
3756 /// Please note that this method must not be used to set any of the known parameters
3757 /// which have their own setter method. If done anyway, the request will fail.
3758 ///
3759 /// # Additional Parameters
3760 ///
3761 /// * *$.xgafv* (query-string) - V1 error format.
3762 /// * *access_token* (query-string) - OAuth access token.
3763 /// * *alt* (query-string) - Data format for response.
3764 /// * *callback* (query-string) - JSONP
3765 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3766 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3767 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3768 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3769 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3770 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3771 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3772 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationDeleteCall<'a, C>
3773 where
3774 T: AsRef<str>,
3775 {
3776 self._additional_params
3777 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3778 self
3779 }
3780
3781 /// Identifies the authorization scope for the method you are building.
3782 ///
3783 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3784 /// [`Scope::CloudPlatform`].
3785 ///
3786 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3787 /// tokens for more than one scope.
3788 ///
3789 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3790 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3791 /// sufficient, a read-write scope will do as well.
3792 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationDeleteCall<'a, C>
3793 where
3794 St: AsRef<str>,
3795 {
3796 self._scopes.insert(String::from(scope.as_ref()));
3797 self
3798 }
3799 /// Identifies the authorization scope(s) for the method you are building.
3800 ///
3801 /// See [`Self::add_scope()`] for details.
3802 pub fn add_scopes<I, St>(
3803 mut self,
3804 scopes: I,
3805 ) -> AdminProjectLocationReservationDeleteCall<'a, C>
3806 where
3807 I: IntoIterator<Item = St>,
3808 St: AsRef<str>,
3809 {
3810 self._scopes
3811 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3812 self
3813 }
3814
3815 /// Removes all scopes, and no default scope will be used either.
3816 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3817 /// for details).
3818 pub fn clear_scopes(mut self) -> AdminProjectLocationReservationDeleteCall<'a, C> {
3819 self._scopes.clear();
3820 self
3821 }
3822}
3823
3824/// Returns the reservation configuration.
3825///
3826/// A builder for the *projects.locations.reservations.get* method supported by a *admin* resource.
3827/// It is not used directly, but through a [`AdminMethods`] instance.
3828///
3829/// # Example
3830///
3831/// Instantiate a resource method builder
3832///
3833/// ```test_harness,no_run
3834/// # extern crate hyper;
3835/// # extern crate hyper_rustls;
3836/// # extern crate google_pubsublite1 as pubsublite1;
3837/// # async fn dox() {
3838/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3839///
3840/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3841/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3842/// # secret,
3843/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3844/// # ).build().await.unwrap();
3845///
3846/// # let client = hyper_util::client::legacy::Client::builder(
3847/// # hyper_util::rt::TokioExecutor::new()
3848/// # )
3849/// # .build(
3850/// # hyper_rustls::HttpsConnectorBuilder::new()
3851/// # .with_native_roots()
3852/// # .unwrap()
3853/// # .https_or_http()
3854/// # .enable_http1()
3855/// # .build()
3856/// # );
3857/// # let mut hub = PubsubLite::new(client, auth);
3858/// // You can configure optional parameters by calling the respective setters at will, and
3859/// // execute the final call using `doit()`.
3860/// // Values shown here are possibly random and not representative !
3861/// let result = hub.admin().projects_locations_reservations_get("name")
3862/// .doit().await;
3863/// # }
3864/// ```
3865pub struct AdminProjectLocationReservationGetCall<'a, C>
3866where
3867 C: 'a,
3868{
3869 hub: &'a PubsubLite<C>,
3870 _name: String,
3871 _delegate: Option<&'a mut dyn common::Delegate>,
3872 _additional_params: HashMap<String, String>,
3873 _scopes: BTreeSet<String>,
3874}
3875
3876impl<'a, C> common::CallBuilder for AdminProjectLocationReservationGetCall<'a, C> {}
3877
3878impl<'a, C> AdminProjectLocationReservationGetCall<'a, C>
3879where
3880 C: common::Connector,
3881{
3882 /// Perform the operation you have build so far.
3883 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
3884 use std::borrow::Cow;
3885 use std::io::{Read, Seek};
3886
3887 use common::{url::Params, ToParts};
3888 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3889
3890 let mut dd = common::DefaultDelegate;
3891 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3892 dlg.begin(common::MethodInfo {
3893 id: "pubsublite.admin.projects.locations.reservations.get",
3894 http_method: hyper::Method::GET,
3895 });
3896
3897 for &field in ["alt", "name"].iter() {
3898 if self._additional_params.contains_key(field) {
3899 dlg.finished(false);
3900 return Err(common::Error::FieldClash(field));
3901 }
3902 }
3903
3904 let mut params = Params::with_capacity(3 + self._additional_params.len());
3905 params.push("name", self._name);
3906
3907 params.extend(self._additional_params.iter());
3908
3909 params.push("alt", "json");
3910 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
3911 if self._scopes.is_empty() {
3912 self._scopes
3913 .insert(Scope::CloudPlatform.as_ref().to_string());
3914 }
3915
3916 #[allow(clippy::single_element_loop)]
3917 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3918 url = params.uri_replacement(url, param_name, find_this, true);
3919 }
3920 {
3921 let to_remove = ["name"];
3922 params.remove_params(&to_remove);
3923 }
3924
3925 let url = params.parse_with_url(&url);
3926
3927 loop {
3928 let token = match self
3929 .hub
3930 .auth
3931 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3932 .await
3933 {
3934 Ok(token) => token,
3935 Err(e) => match dlg.token(e) {
3936 Ok(token) => token,
3937 Err(e) => {
3938 dlg.finished(false);
3939 return Err(common::Error::MissingToken(e));
3940 }
3941 },
3942 };
3943 let mut req_result = {
3944 let client = &self.hub.client;
3945 dlg.pre_request();
3946 let mut req_builder = hyper::Request::builder()
3947 .method(hyper::Method::GET)
3948 .uri(url.as_str())
3949 .header(USER_AGENT, self.hub._user_agent.clone());
3950
3951 if let Some(token) = token.as_ref() {
3952 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3953 }
3954
3955 let request = req_builder
3956 .header(CONTENT_LENGTH, 0_u64)
3957 .body(common::to_body::<String>(None));
3958
3959 client.request(request.unwrap()).await
3960 };
3961
3962 match req_result {
3963 Err(err) => {
3964 if let common::Retry::After(d) = dlg.http_error(&err) {
3965 sleep(d).await;
3966 continue;
3967 }
3968 dlg.finished(false);
3969 return Err(common::Error::HttpError(err));
3970 }
3971 Ok(res) => {
3972 let (mut parts, body) = res.into_parts();
3973 let mut body = common::Body::new(body);
3974 if !parts.status.is_success() {
3975 let bytes = common::to_bytes(body).await.unwrap_or_default();
3976 let error = serde_json::from_str(&common::to_string(&bytes));
3977 let response = common::to_response(parts, bytes.into());
3978
3979 if let common::Retry::After(d) =
3980 dlg.http_failure(&response, error.as_ref().ok())
3981 {
3982 sleep(d).await;
3983 continue;
3984 }
3985
3986 dlg.finished(false);
3987
3988 return Err(match error {
3989 Ok(value) => common::Error::BadRequest(value),
3990 _ => common::Error::Failure(response),
3991 });
3992 }
3993 let response = {
3994 let bytes = common::to_bytes(body).await.unwrap_or_default();
3995 let encoded = common::to_string(&bytes);
3996 match serde_json::from_str(&encoded) {
3997 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3998 Err(error) => {
3999 dlg.response_json_decode_error(&encoded, &error);
4000 return Err(common::Error::JsonDecodeError(
4001 encoded.to_string(),
4002 error,
4003 ));
4004 }
4005 }
4006 };
4007
4008 dlg.finished(true);
4009 return Ok(response);
4010 }
4011 }
4012 }
4013 }
4014
4015 /// Required. The name of the reservation whose configuration to return. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
4016 ///
4017 /// Sets the *name* path property to the given value.
4018 ///
4019 /// Even though the property as already been set when instantiating this call,
4020 /// we provide this method for API completeness.
4021 pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationGetCall<'a, C> {
4022 self._name = new_value.to_string();
4023 self
4024 }
4025 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4026 /// while executing the actual API request.
4027 ///
4028 /// ````text
4029 /// It should be used to handle progress information, and to implement a certain level of resilience.
4030 /// ````
4031 ///
4032 /// Sets the *delegate* property to the given value.
4033 pub fn delegate(
4034 mut self,
4035 new_value: &'a mut dyn common::Delegate,
4036 ) -> AdminProjectLocationReservationGetCall<'a, C> {
4037 self._delegate = Some(new_value);
4038 self
4039 }
4040
4041 /// Set any additional parameter of the query string used in the request.
4042 /// It should be used to set parameters which are not yet available through their own
4043 /// setters.
4044 ///
4045 /// Please note that this method must not be used to set any of the known parameters
4046 /// which have their own setter method. If done anyway, the request will fail.
4047 ///
4048 /// # Additional Parameters
4049 ///
4050 /// * *$.xgafv* (query-string) - V1 error format.
4051 /// * *access_token* (query-string) - OAuth access token.
4052 /// * *alt* (query-string) - Data format for response.
4053 /// * *callback* (query-string) - JSONP
4054 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4055 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4056 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4057 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4058 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4059 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4060 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4061 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationGetCall<'a, C>
4062 where
4063 T: AsRef<str>,
4064 {
4065 self._additional_params
4066 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4067 self
4068 }
4069
4070 /// Identifies the authorization scope for the method you are building.
4071 ///
4072 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4073 /// [`Scope::CloudPlatform`].
4074 ///
4075 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4076 /// tokens for more than one scope.
4077 ///
4078 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4079 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4080 /// sufficient, a read-write scope will do as well.
4081 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationGetCall<'a, C>
4082 where
4083 St: AsRef<str>,
4084 {
4085 self._scopes.insert(String::from(scope.as_ref()));
4086 self
4087 }
4088 /// Identifies the authorization scope(s) for the method you are building.
4089 ///
4090 /// See [`Self::add_scope()`] for details.
4091 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationReservationGetCall<'a, C>
4092 where
4093 I: IntoIterator<Item = St>,
4094 St: AsRef<str>,
4095 {
4096 self._scopes
4097 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4098 self
4099 }
4100
4101 /// Removes all scopes, and no default scope will be used either.
4102 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4103 /// for details).
4104 pub fn clear_scopes(mut self) -> AdminProjectLocationReservationGetCall<'a, C> {
4105 self._scopes.clear();
4106 self
4107 }
4108}
4109
4110/// Returns the list of reservations for the given project.
4111///
4112/// A builder for the *projects.locations.reservations.list* method supported by a *admin* resource.
4113/// It is not used directly, but through a [`AdminMethods`] instance.
4114///
4115/// # Example
4116///
4117/// Instantiate a resource method builder
4118///
4119/// ```test_harness,no_run
4120/// # extern crate hyper;
4121/// # extern crate hyper_rustls;
4122/// # extern crate google_pubsublite1 as pubsublite1;
4123/// # async fn dox() {
4124/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4125///
4126/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4127/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4128/// # secret,
4129/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4130/// # ).build().await.unwrap();
4131///
4132/// # let client = hyper_util::client::legacy::Client::builder(
4133/// # hyper_util::rt::TokioExecutor::new()
4134/// # )
4135/// # .build(
4136/// # hyper_rustls::HttpsConnectorBuilder::new()
4137/// # .with_native_roots()
4138/// # .unwrap()
4139/// # .https_or_http()
4140/// # .enable_http1()
4141/// # .build()
4142/// # );
4143/// # let mut hub = PubsubLite::new(client, auth);
4144/// // You can configure optional parameters by calling the respective setters at will, and
4145/// // execute the final call using `doit()`.
4146/// // Values shown here are possibly random and not representative !
4147/// let result = hub.admin().projects_locations_reservations_list("parent")
4148/// .page_token("ea")
4149/// .page_size(-55)
4150/// .doit().await;
4151/// # }
4152/// ```
4153pub struct AdminProjectLocationReservationListCall<'a, C>
4154where
4155 C: 'a,
4156{
4157 hub: &'a PubsubLite<C>,
4158 _parent: String,
4159 _page_token: Option<String>,
4160 _page_size: Option<i32>,
4161 _delegate: Option<&'a mut dyn common::Delegate>,
4162 _additional_params: HashMap<String, String>,
4163 _scopes: BTreeSet<String>,
4164}
4165
4166impl<'a, C> common::CallBuilder for AdminProjectLocationReservationListCall<'a, C> {}
4167
4168impl<'a, C> AdminProjectLocationReservationListCall<'a, C>
4169where
4170 C: common::Connector,
4171{
4172 /// Perform the operation you have build so far.
4173 pub async fn doit(mut self) -> common::Result<(common::Response, ListReservationsResponse)> {
4174 use std::borrow::Cow;
4175 use std::io::{Read, Seek};
4176
4177 use common::{url::Params, ToParts};
4178 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4179
4180 let mut dd = common::DefaultDelegate;
4181 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4182 dlg.begin(common::MethodInfo {
4183 id: "pubsublite.admin.projects.locations.reservations.list",
4184 http_method: hyper::Method::GET,
4185 });
4186
4187 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4188 if self._additional_params.contains_key(field) {
4189 dlg.finished(false);
4190 return Err(common::Error::FieldClash(field));
4191 }
4192 }
4193
4194 let mut params = Params::with_capacity(5 + self._additional_params.len());
4195 params.push("parent", self._parent);
4196 if let Some(value) = self._page_token.as_ref() {
4197 params.push("pageToken", value);
4198 }
4199 if let Some(value) = self._page_size.as_ref() {
4200 params.push("pageSize", value.to_string());
4201 }
4202
4203 params.extend(self._additional_params.iter());
4204
4205 params.push("alt", "json");
4206 let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/reservations";
4207 if self._scopes.is_empty() {
4208 self._scopes
4209 .insert(Scope::CloudPlatform.as_ref().to_string());
4210 }
4211
4212 #[allow(clippy::single_element_loop)]
4213 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4214 url = params.uri_replacement(url, param_name, find_this, true);
4215 }
4216 {
4217 let to_remove = ["parent"];
4218 params.remove_params(&to_remove);
4219 }
4220
4221 let url = params.parse_with_url(&url);
4222
4223 loop {
4224 let token = match self
4225 .hub
4226 .auth
4227 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4228 .await
4229 {
4230 Ok(token) => token,
4231 Err(e) => match dlg.token(e) {
4232 Ok(token) => token,
4233 Err(e) => {
4234 dlg.finished(false);
4235 return Err(common::Error::MissingToken(e));
4236 }
4237 },
4238 };
4239 let mut req_result = {
4240 let client = &self.hub.client;
4241 dlg.pre_request();
4242 let mut req_builder = hyper::Request::builder()
4243 .method(hyper::Method::GET)
4244 .uri(url.as_str())
4245 .header(USER_AGENT, self.hub._user_agent.clone());
4246
4247 if let Some(token) = token.as_ref() {
4248 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4249 }
4250
4251 let request = req_builder
4252 .header(CONTENT_LENGTH, 0_u64)
4253 .body(common::to_body::<String>(None));
4254
4255 client.request(request.unwrap()).await
4256 };
4257
4258 match req_result {
4259 Err(err) => {
4260 if let common::Retry::After(d) = dlg.http_error(&err) {
4261 sleep(d).await;
4262 continue;
4263 }
4264 dlg.finished(false);
4265 return Err(common::Error::HttpError(err));
4266 }
4267 Ok(res) => {
4268 let (mut parts, body) = res.into_parts();
4269 let mut body = common::Body::new(body);
4270 if !parts.status.is_success() {
4271 let bytes = common::to_bytes(body).await.unwrap_or_default();
4272 let error = serde_json::from_str(&common::to_string(&bytes));
4273 let response = common::to_response(parts, bytes.into());
4274
4275 if let common::Retry::After(d) =
4276 dlg.http_failure(&response, error.as_ref().ok())
4277 {
4278 sleep(d).await;
4279 continue;
4280 }
4281
4282 dlg.finished(false);
4283
4284 return Err(match error {
4285 Ok(value) => common::Error::BadRequest(value),
4286 _ => common::Error::Failure(response),
4287 });
4288 }
4289 let response = {
4290 let bytes = common::to_bytes(body).await.unwrap_or_default();
4291 let encoded = common::to_string(&bytes);
4292 match serde_json::from_str(&encoded) {
4293 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4294 Err(error) => {
4295 dlg.response_json_decode_error(&encoded, &error);
4296 return Err(common::Error::JsonDecodeError(
4297 encoded.to_string(),
4298 error,
4299 ));
4300 }
4301 }
4302 };
4303
4304 dlg.finished(true);
4305 return Ok(response);
4306 }
4307 }
4308 }
4309 }
4310
4311 /// Required. The parent whose reservations are to be listed. Structured like `projects/{project_number}/locations/{location}`.
4312 ///
4313 /// Sets the *parent* path property to the given value.
4314 ///
4315 /// Even though the property as already been set when instantiating this call,
4316 /// we provide this method for API completeness.
4317 pub fn parent(mut self, new_value: &str) -> AdminProjectLocationReservationListCall<'a, C> {
4318 self._parent = new_value.to_string();
4319 self
4320 }
4321 /// A page token, received from a previous `ListReservations` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListReservations` must match the call that provided the page token.
4322 ///
4323 /// Sets the *page token* query property to the given value.
4324 pub fn page_token(mut self, new_value: &str) -> AdminProjectLocationReservationListCall<'a, C> {
4325 self._page_token = Some(new_value.to_string());
4326 self
4327 }
4328 /// The maximum number of reservations to return. The service may return fewer than this value. If unset or zero, all reservations for the parent will be returned.
4329 ///
4330 /// Sets the *page size* query property to the given value.
4331 pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationReservationListCall<'a, C> {
4332 self._page_size = Some(new_value);
4333 self
4334 }
4335 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4336 /// while executing the actual API request.
4337 ///
4338 /// ````text
4339 /// It should be used to handle progress information, and to implement a certain level of resilience.
4340 /// ````
4341 ///
4342 /// Sets the *delegate* property to the given value.
4343 pub fn delegate(
4344 mut self,
4345 new_value: &'a mut dyn common::Delegate,
4346 ) -> AdminProjectLocationReservationListCall<'a, C> {
4347 self._delegate = Some(new_value);
4348 self
4349 }
4350
4351 /// Set any additional parameter of the query string used in the request.
4352 /// It should be used to set parameters which are not yet available through their own
4353 /// setters.
4354 ///
4355 /// Please note that this method must not be used to set any of the known parameters
4356 /// which have their own setter method. If done anyway, the request will fail.
4357 ///
4358 /// # Additional Parameters
4359 ///
4360 /// * *$.xgafv* (query-string) - V1 error format.
4361 /// * *access_token* (query-string) - OAuth access token.
4362 /// * *alt* (query-string) - Data format for response.
4363 /// * *callback* (query-string) - JSONP
4364 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4365 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4366 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4367 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4368 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4369 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4370 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4371 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationListCall<'a, C>
4372 where
4373 T: AsRef<str>,
4374 {
4375 self._additional_params
4376 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4377 self
4378 }
4379
4380 /// Identifies the authorization scope for the method you are building.
4381 ///
4382 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4383 /// [`Scope::CloudPlatform`].
4384 ///
4385 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4386 /// tokens for more than one scope.
4387 ///
4388 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4389 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4390 /// sufficient, a read-write scope will do as well.
4391 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationListCall<'a, C>
4392 where
4393 St: AsRef<str>,
4394 {
4395 self._scopes.insert(String::from(scope.as_ref()));
4396 self
4397 }
4398 /// Identifies the authorization scope(s) for the method you are building.
4399 ///
4400 /// See [`Self::add_scope()`] for details.
4401 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationReservationListCall<'a, C>
4402 where
4403 I: IntoIterator<Item = St>,
4404 St: AsRef<str>,
4405 {
4406 self._scopes
4407 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4408 self
4409 }
4410
4411 /// Removes all scopes, and no default scope will be used either.
4412 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4413 /// for details).
4414 pub fn clear_scopes(mut self) -> AdminProjectLocationReservationListCall<'a, C> {
4415 self._scopes.clear();
4416 self
4417 }
4418}
4419
4420/// Updates properties of the specified reservation.
4421///
4422/// A builder for the *projects.locations.reservations.patch* method supported by a *admin* resource.
4423/// It is not used directly, but through a [`AdminMethods`] instance.
4424///
4425/// # Example
4426///
4427/// Instantiate a resource method builder
4428///
4429/// ```test_harness,no_run
4430/// # extern crate hyper;
4431/// # extern crate hyper_rustls;
4432/// # extern crate google_pubsublite1 as pubsublite1;
4433/// use pubsublite1::api::Reservation;
4434/// # async fn dox() {
4435/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4436///
4437/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4438/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4439/// # secret,
4440/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4441/// # ).build().await.unwrap();
4442///
4443/// # let client = hyper_util::client::legacy::Client::builder(
4444/// # hyper_util::rt::TokioExecutor::new()
4445/// # )
4446/// # .build(
4447/// # hyper_rustls::HttpsConnectorBuilder::new()
4448/// # .with_native_roots()
4449/// # .unwrap()
4450/// # .https_or_http()
4451/// # .enable_http1()
4452/// # .build()
4453/// # );
4454/// # let mut hub = PubsubLite::new(client, auth);
4455/// // As the method needs a request, you would usually fill it with the desired information
4456/// // into the respective structure. Some of the parts shown here might not be applicable !
4457/// // Values shown here are possibly random and not representative !
4458/// let mut req = Reservation::default();
4459///
4460/// // You can configure optional parameters by calling the respective setters at will, and
4461/// // execute the final call using `doit()`.
4462/// // Values shown here are possibly random and not representative !
4463/// let result = hub.admin().projects_locations_reservations_patch(req, "name")
4464/// .update_mask(FieldMask::new::<&str>(&[]))
4465/// .doit().await;
4466/// # }
4467/// ```
4468pub struct AdminProjectLocationReservationPatchCall<'a, C>
4469where
4470 C: 'a,
4471{
4472 hub: &'a PubsubLite<C>,
4473 _request: Reservation,
4474 _name: String,
4475 _update_mask: Option<common::FieldMask>,
4476 _delegate: Option<&'a mut dyn common::Delegate>,
4477 _additional_params: HashMap<String, String>,
4478 _scopes: BTreeSet<String>,
4479}
4480
4481impl<'a, C> common::CallBuilder for AdminProjectLocationReservationPatchCall<'a, C> {}
4482
4483impl<'a, C> AdminProjectLocationReservationPatchCall<'a, C>
4484where
4485 C: common::Connector,
4486{
4487 /// Perform the operation you have build so far.
4488 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
4489 use std::borrow::Cow;
4490 use std::io::{Read, Seek};
4491
4492 use common::{url::Params, ToParts};
4493 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4494
4495 let mut dd = common::DefaultDelegate;
4496 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4497 dlg.begin(common::MethodInfo {
4498 id: "pubsublite.admin.projects.locations.reservations.patch",
4499 http_method: hyper::Method::PATCH,
4500 });
4501
4502 for &field in ["alt", "name", "updateMask"].iter() {
4503 if self._additional_params.contains_key(field) {
4504 dlg.finished(false);
4505 return Err(common::Error::FieldClash(field));
4506 }
4507 }
4508
4509 let mut params = Params::with_capacity(5 + self._additional_params.len());
4510 params.push("name", self._name);
4511 if let Some(value) = self._update_mask.as_ref() {
4512 params.push("updateMask", value.to_string());
4513 }
4514
4515 params.extend(self._additional_params.iter());
4516
4517 params.push("alt", "json");
4518 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
4519 if self._scopes.is_empty() {
4520 self._scopes
4521 .insert(Scope::CloudPlatform.as_ref().to_string());
4522 }
4523
4524 #[allow(clippy::single_element_loop)]
4525 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4526 url = params.uri_replacement(url, param_name, find_this, true);
4527 }
4528 {
4529 let to_remove = ["name"];
4530 params.remove_params(&to_remove);
4531 }
4532
4533 let url = params.parse_with_url(&url);
4534
4535 let mut json_mime_type = mime::APPLICATION_JSON;
4536 let mut request_value_reader = {
4537 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4538 common::remove_json_null_values(&mut value);
4539 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4540 serde_json::to_writer(&mut dst, &value).unwrap();
4541 dst
4542 };
4543 let request_size = request_value_reader
4544 .seek(std::io::SeekFrom::End(0))
4545 .unwrap();
4546 request_value_reader
4547 .seek(std::io::SeekFrom::Start(0))
4548 .unwrap();
4549
4550 loop {
4551 let token = match self
4552 .hub
4553 .auth
4554 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4555 .await
4556 {
4557 Ok(token) => token,
4558 Err(e) => match dlg.token(e) {
4559 Ok(token) => token,
4560 Err(e) => {
4561 dlg.finished(false);
4562 return Err(common::Error::MissingToken(e));
4563 }
4564 },
4565 };
4566 request_value_reader
4567 .seek(std::io::SeekFrom::Start(0))
4568 .unwrap();
4569 let mut req_result = {
4570 let client = &self.hub.client;
4571 dlg.pre_request();
4572 let mut req_builder = hyper::Request::builder()
4573 .method(hyper::Method::PATCH)
4574 .uri(url.as_str())
4575 .header(USER_AGENT, self.hub._user_agent.clone());
4576
4577 if let Some(token) = token.as_ref() {
4578 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4579 }
4580
4581 let request = req_builder
4582 .header(CONTENT_TYPE, json_mime_type.to_string())
4583 .header(CONTENT_LENGTH, request_size as u64)
4584 .body(common::to_body(
4585 request_value_reader.get_ref().clone().into(),
4586 ));
4587
4588 client.request(request.unwrap()).await
4589 };
4590
4591 match req_result {
4592 Err(err) => {
4593 if let common::Retry::After(d) = dlg.http_error(&err) {
4594 sleep(d).await;
4595 continue;
4596 }
4597 dlg.finished(false);
4598 return Err(common::Error::HttpError(err));
4599 }
4600 Ok(res) => {
4601 let (mut parts, body) = res.into_parts();
4602 let mut body = common::Body::new(body);
4603 if !parts.status.is_success() {
4604 let bytes = common::to_bytes(body).await.unwrap_or_default();
4605 let error = serde_json::from_str(&common::to_string(&bytes));
4606 let response = common::to_response(parts, bytes.into());
4607
4608 if let common::Retry::After(d) =
4609 dlg.http_failure(&response, error.as_ref().ok())
4610 {
4611 sleep(d).await;
4612 continue;
4613 }
4614
4615 dlg.finished(false);
4616
4617 return Err(match error {
4618 Ok(value) => common::Error::BadRequest(value),
4619 _ => common::Error::Failure(response),
4620 });
4621 }
4622 let response = {
4623 let bytes = common::to_bytes(body).await.unwrap_or_default();
4624 let encoded = common::to_string(&bytes);
4625 match serde_json::from_str(&encoded) {
4626 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4627 Err(error) => {
4628 dlg.response_json_decode_error(&encoded, &error);
4629 return Err(common::Error::JsonDecodeError(
4630 encoded.to_string(),
4631 error,
4632 ));
4633 }
4634 }
4635 };
4636
4637 dlg.finished(true);
4638 return Ok(response);
4639 }
4640 }
4641 }
4642 }
4643
4644 ///
4645 /// Sets the *request* property to the given value.
4646 ///
4647 /// Even though the property as already been set when instantiating this call,
4648 /// we provide this method for API completeness.
4649 pub fn request(
4650 mut self,
4651 new_value: Reservation,
4652 ) -> AdminProjectLocationReservationPatchCall<'a, C> {
4653 self._request = new_value;
4654 self
4655 }
4656 /// The name of the reservation. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
4657 ///
4658 /// Sets the *name* path property to the given value.
4659 ///
4660 /// Even though the property as already been set when instantiating this call,
4661 /// we provide this method for API completeness.
4662 pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationPatchCall<'a, C> {
4663 self._name = new_value.to_string();
4664 self
4665 }
4666 /// Required. A mask specifying the reservation fields to change.
4667 ///
4668 /// Sets the *update mask* query property to the given value.
4669 pub fn update_mask(
4670 mut self,
4671 new_value: common::FieldMask,
4672 ) -> AdminProjectLocationReservationPatchCall<'a, C> {
4673 self._update_mask = Some(new_value);
4674 self
4675 }
4676 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4677 /// while executing the actual API request.
4678 ///
4679 /// ````text
4680 /// It should be used to handle progress information, and to implement a certain level of resilience.
4681 /// ````
4682 ///
4683 /// Sets the *delegate* property to the given value.
4684 pub fn delegate(
4685 mut self,
4686 new_value: &'a mut dyn common::Delegate,
4687 ) -> AdminProjectLocationReservationPatchCall<'a, C> {
4688 self._delegate = Some(new_value);
4689 self
4690 }
4691
4692 /// Set any additional parameter of the query string used in the request.
4693 /// It should be used to set parameters which are not yet available through their own
4694 /// setters.
4695 ///
4696 /// Please note that this method must not be used to set any of the known parameters
4697 /// which have their own setter method. If done anyway, the request will fail.
4698 ///
4699 /// # Additional Parameters
4700 ///
4701 /// * *$.xgafv* (query-string) - V1 error format.
4702 /// * *access_token* (query-string) - OAuth access token.
4703 /// * *alt* (query-string) - Data format for response.
4704 /// * *callback* (query-string) - JSONP
4705 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4706 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4707 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4708 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4709 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4710 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4711 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4712 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationPatchCall<'a, C>
4713 where
4714 T: AsRef<str>,
4715 {
4716 self._additional_params
4717 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4718 self
4719 }
4720
4721 /// Identifies the authorization scope for the method you are building.
4722 ///
4723 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4724 /// [`Scope::CloudPlatform`].
4725 ///
4726 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4727 /// tokens for more than one scope.
4728 ///
4729 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4730 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4731 /// sufficient, a read-write scope will do as well.
4732 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationPatchCall<'a, C>
4733 where
4734 St: AsRef<str>,
4735 {
4736 self._scopes.insert(String::from(scope.as_ref()));
4737 self
4738 }
4739 /// Identifies the authorization scope(s) for the method you are building.
4740 ///
4741 /// See [`Self::add_scope()`] for details.
4742 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationReservationPatchCall<'a, C>
4743 where
4744 I: IntoIterator<Item = St>,
4745 St: AsRef<str>,
4746 {
4747 self._scopes
4748 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4749 self
4750 }
4751
4752 /// Removes all scopes, and no default scope will be used either.
4753 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4754 /// for details).
4755 pub fn clear_scopes(mut self) -> AdminProjectLocationReservationPatchCall<'a, C> {
4756 self._scopes.clear();
4757 self
4758 }
4759}
4760
4761/// Creates a new subscription.
4762///
4763/// A builder for the *projects.locations.subscriptions.create* method supported by a *admin* resource.
4764/// It is not used directly, but through a [`AdminMethods`] instance.
4765///
4766/// # Example
4767///
4768/// Instantiate a resource method builder
4769///
4770/// ```test_harness,no_run
4771/// # extern crate hyper;
4772/// # extern crate hyper_rustls;
4773/// # extern crate google_pubsublite1 as pubsublite1;
4774/// use pubsublite1::api::Subscription;
4775/// # async fn dox() {
4776/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4777///
4778/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4780/// # secret,
4781/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4782/// # ).build().await.unwrap();
4783///
4784/// # let client = hyper_util::client::legacy::Client::builder(
4785/// # hyper_util::rt::TokioExecutor::new()
4786/// # )
4787/// # .build(
4788/// # hyper_rustls::HttpsConnectorBuilder::new()
4789/// # .with_native_roots()
4790/// # .unwrap()
4791/// # .https_or_http()
4792/// # .enable_http1()
4793/// # .build()
4794/// # );
4795/// # let mut hub = PubsubLite::new(client, auth);
4796/// // As the method needs a request, you would usually fill it with the desired information
4797/// // into the respective structure. Some of the parts shown here might not be applicable !
4798/// // Values shown here are possibly random and not representative !
4799/// let mut req = Subscription::default();
4800///
4801/// // You can configure optional parameters by calling the respective setters at will, and
4802/// // execute the final call using `doit()`.
4803/// // Values shown here are possibly random and not representative !
4804/// let result = hub.admin().projects_locations_subscriptions_create(req, "parent")
4805/// .subscription_id("duo")
4806/// .skip_backlog(true)
4807/// .doit().await;
4808/// # }
4809/// ```
4810pub struct AdminProjectLocationSubscriptionCreateCall<'a, C>
4811where
4812 C: 'a,
4813{
4814 hub: &'a PubsubLite<C>,
4815 _request: Subscription,
4816 _parent: String,
4817 _subscription_id: Option<String>,
4818 _skip_backlog: Option<bool>,
4819 _delegate: Option<&'a mut dyn common::Delegate>,
4820 _additional_params: HashMap<String, String>,
4821 _scopes: BTreeSet<String>,
4822}
4823
4824impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionCreateCall<'a, C> {}
4825
4826impl<'a, C> AdminProjectLocationSubscriptionCreateCall<'a, C>
4827where
4828 C: common::Connector,
4829{
4830 /// Perform the operation you have build so far.
4831 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
4832 use std::borrow::Cow;
4833 use std::io::{Read, Seek};
4834
4835 use common::{url::Params, ToParts};
4836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4837
4838 let mut dd = common::DefaultDelegate;
4839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4840 dlg.begin(common::MethodInfo {
4841 id: "pubsublite.admin.projects.locations.subscriptions.create",
4842 http_method: hyper::Method::POST,
4843 });
4844
4845 for &field in ["alt", "parent", "subscriptionId", "skipBacklog"].iter() {
4846 if self._additional_params.contains_key(field) {
4847 dlg.finished(false);
4848 return Err(common::Error::FieldClash(field));
4849 }
4850 }
4851
4852 let mut params = Params::with_capacity(6 + self._additional_params.len());
4853 params.push("parent", self._parent);
4854 if let Some(value) = self._subscription_id.as_ref() {
4855 params.push("subscriptionId", value);
4856 }
4857 if let Some(value) = self._skip_backlog.as_ref() {
4858 params.push("skipBacklog", value.to_string());
4859 }
4860
4861 params.extend(self._additional_params.iter());
4862
4863 params.push("alt", "json");
4864 let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/subscriptions";
4865 if self._scopes.is_empty() {
4866 self._scopes
4867 .insert(Scope::CloudPlatform.as_ref().to_string());
4868 }
4869
4870 #[allow(clippy::single_element_loop)]
4871 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4872 url = params.uri_replacement(url, param_name, find_this, true);
4873 }
4874 {
4875 let to_remove = ["parent"];
4876 params.remove_params(&to_remove);
4877 }
4878
4879 let url = params.parse_with_url(&url);
4880
4881 let mut json_mime_type = mime::APPLICATION_JSON;
4882 let mut request_value_reader = {
4883 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4884 common::remove_json_null_values(&mut value);
4885 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4886 serde_json::to_writer(&mut dst, &value).unwrap();
4887 dst
4888 };
4889 let request_size = request_value_reader
4890 .seek(std::io::SeekFrom::End(0))
4891 .unwrap();
4892 request_value_reader
4893 .seek(std::io::SeekFrom::Start(0))
4894 .unwrap();
4895
4896 loop {
4897 let token = match self
4898 .hub
4899 .auth
4900 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4901 .await
4902 {
4903 Ok(token) => token,
4904 Err(e) => match dlg.token(e) {
4905 Ok(token) => token,
4906 Err(e) => {
4907 dlg.finished(false);
4908 return Err(common::Error::MissingToken(e));
4909 }
4910 },
4911 };
4912 request_value_reader
4913 .seek(std::io::SeekFrom::Start(0))
4914 .unwrap();
4915 let mut req_result = {
4916 let client = &self.hub.client;
4917 dlg.pre_request();
4918 let mut req_builder = hyper::Request::builder()
4919 .method(hyper::Method::POST)
4920 .uri(url.as_str())
4921 .header(USER_AGENT, self.hub._user_agent.clone());
4922
4923 if let Some(token) = token.as_ref() {
4924 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4925 }
4926
4927 let request = req_builder
4928 .header(CONTENT_TYPE, json_mime_type.to_string())
4929 .header(CONTENT_LENGTH, request_size as u64)
4930 .body(common::to_body(
4931 request_value_reader.get_ref().clone().into(),
4932 ));
4933
4934 client.request(request.unwrap()).await
4935 };
4936
4937 match req_result {
4938 Err(err) => {
4939 if let common::Retry::After(d) = dlg.http_error(&err) {
4940 sleep(d).await;
4941 continue;
4942 }
4943 dlg.finished(false);
4944 return Err(common::Error::HttpError(err));
4945 }
4946 Ok(res) => {
4947 let (mut parts, body) = res.into_parts();
4948 let mut body = common::Body::new(body);
4949 if !parts.status.is_success() {
4950 let bytes = common::to_bytes(body).await.unwrap_or_default();
4951 let error = serde_json::from_str(&common::to_string(&bytes));
4952 let response = common::to_response(parts, bytes.into());
4953
4954 if let common::Retry::After(d) =
4955 dlg.http_failure(&response, error.as_ref().ok())
4956 {
4957 sleep(d).await;
4958 continue;
4959 }
4960
4961 dlg.finished(false);
4962
4963 return Err(match error {
4964 Ok(value) => common::Error::BadRequest(value),
4965 _ => common::Error::Failure(response),
4966 });
4967 }
4968 let response = {
4969 let bytes = common::to_bytes(body).await.unwrap_or_default();
4970 let encoded = common::to_string(&bytes);
4971 match serde_json::from_str(&encoded) {
4972 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4973 Err(error) => {
4974 dlg.response_json_decode_error(&encoded, &error);
4975 return Err(common::Error::JsonDecodeError(
4976 encoded.to_string(),
4977 error,
4978 ));
4979 }
4980 }
4981 };
4982
4983 dlg.finished(true);
4984 return Ok(response);
4985 }
4986 }
4987 }
4988 }
4989
4990 ///
4991 /// Sets the *request* property to the given value.
4992 ///
4993 /// Even though the property as already been set when instantiating this call,
4994 /// we provide this method for API completeness.
4995 pub fn request(
4996 mut self,
4997 new_value: Subscription,
4998 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
4999 self._request = new_value;
5000 self
5001 }
5002 /// Required. The parent location in which to create the subscription. Structured like `projects/{project_number}/locations/{location}`.
5003 ///
5004 /// Sets the *parent* path property to the given value.
5005 ///
5006 /// Even though the property as already been set when instantiating this call,
5007 /// we provide this method for API completeness.
5008 pub fn parent(mut self, new_value: &str) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5009 self._parent = new_value.to_string();
5010 self
5011 }
5012 /// Required. The ID to use for the subscription, which will become the final component of the subscription's name. This value is structured like: `my-sub-name`.
5013 ///
5014 /// Sets the *subscription id* query property to the given value.
5015 pub fn subscription_id(
5016 mut self,
5017 new_value: &str,
5018 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5019 self._subscription_id = Some(new_value.to_string());
5020 self
5021 }
5022 /// If true, the newly created subscription will only receive messages published after the subscription was created. Otherwise, the entire message backlog will be received on the subscription. Defaults to false.
5023 ///
5024 /// Sets the *skip backlog* query property to the given value.
5025 pub fn skip_backlog(
5026 mut self,
5027 new_value: bool,
5028 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5029 self._skip_backlog = Some(new_value);
5030 self
5031 }
5032 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5033 /// while executing the actual API request.
5034 ///
5035 /// ````text
5036 /// It should be used to handle progress information, and to implement a certain level of resilience.
5037 /// ````
5038 ///
5039 /// Sets the *delegate* property to the given value.
5040 pub fn delegate(
5041 mut self,
5042 new_value: &'a mut dyn common::Delegate,
5043 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5044 self._delegate = Some(new_value);
5045 self
5046 }
5047
5048 /// Set any additional parameter of the query string used in the request.
5049 /// It should be used to set parameters which are not yet available through their own
5050 /// setters.
5051 ///
5052 /// Please note that this method must not be used to set any of the known parameters
5053 /// which have their own setter method. If done anyway, the request will fail.
5054 ///
5055 /// # Additional Parameters
5056 ///
5057 /// * *$.xgafv* (query-string) - V1 error format.
5058 /// * *access_token* (query-string) - OAuth access token.
5059 /// * *alt* (query-string) - Data format for response.
5060 /// * *callback* (query-string) - JSONP
5061 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5062 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5063 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5064 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5065 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5066 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5067 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5068 pub fn param<T>(
5069 mut self,
5070 name: T,
5071 value: T,
5072 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C>
5073 where
5074 T: AsRef<str>,
5075 {
5076 self._additional_params
5077 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5078 self
5079 }
5080
5081 /// Identifies the authorization scope for the method you are building.
5082 ///
5083 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5084 /// [`Scope::CloudPlatform`].
5085 ///
5086 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5087 /// tokens for more than one scope.
5088 ///
5089 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5090 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5091 /// sufficient, a read-write scope will do as well.
5092 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionCreateCall<'a, C>
5093 where
5094 St: AsRef<str>,
5095 {
5096 self._scopes.insert(String::from(scope.as_ref()));
5097 self
5098 }
5099 /// Identifies the authorization scope(s) for the method you are building.
5100 ///
5101 /// See [`Self::add_scope()`] for details.
5102 pub fn add_scopes<I, St>(
5103 mut self,
5104 scopes: I,
5105 ) -> AdminProjectLocationSubscriptionCreateCall<'a, C>
5106 where
5107 I: IntoIterator<Item = St>,
5108 St: AsRef<str>,
5109 {
5110 self._scopes
5111 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5112 self
5113 }
5114
5115 /// Removes all scopes, and no default scope will be used either.
5116 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5117 /// for details).
5118 pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5119 self._scopes.clear();
5120 self
5121 }
5122}
5123
5124/// Deletes the specified subscription.
5125///
5126/// A builder for the *projects.locations.subscriptions.delete* method supported by a *admin* resource.
5127/// It is not used directly, but through a [`AdminMethods`] instance.
5128///
5129/// # Example
5130///
5131/// Instantiate a resource method builder
5132///
5133/// ```test_harness,no_run
5134/// # extern crate hyper;
5135/// # extern crate hyper_rustls;
5136/// # extern crate google_pubsublite1 as pubsublite1;
5137/// # async fn dox() {
5138/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5139///
5140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5141/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5142/// # secret,
5143/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5144/// # ).build().await.unwrap();
5145///
5146/// # let client = hyper_util::client::legacy::Client::builder(
5147/// # hyper_util::rt::TokioExecutor::new()
5148/// # )
5149/// # .build(
5150/// # hyper_rustls::HttpsConnectorBuilder::new()
5151/// # .with_native_roots()
5152/// # .unwrap()
5153/// # .https_or_http()
5154/// # .enable_http1()
5155/// # .build()
5156/// # );
5157/// # let mut hub = PubsubLite::new(client, auth);
5158/// // You can configure optional parameters by calling the respective setters at will, and
5159/// // execute the final call using `doit()`.
5160/// // Values shown here are possibly random and not representative !
5161/// let result = hub.admin().projects_locations_subscriptions_delete("name")
5162/// .doit().await;
5163/// # }
5164/// ```
5165pub struct AdminProjectLocationSubscriptionDeleteCall<'a, C>
5166where
5167 C: 'a,
5168{
5169 hub: &'a PubsubLite<C>,
5170 _name: String,
5171 _delegate: Option<&'a mut dyn common::Delegate>,
5172 _additional_params: HashMap<String, String>,
5173 _scopes: BTreeSet<String>,
5174}
5175
5176impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionDeleteCall<'a, C> {}
5177
5178impl<'a, C> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5179where
5180 C: common::Connector,
5181{
5182 /// Perform the operation you have build so far.
5183 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5184 use std::borrow::Cow;
5185 use std::io::{Read, Seek};
5186
5187 use common::{url::Params, ToParts};
5188 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5189
5190 let mut dd = common::DefaultDelegate;
5191 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5192 dlg.begin(common::MethodInfo {
5193 id: "pubsublite.admin.projects.locations.subscriptions.delete",
5194 http_method: hyper::Method::DELETE,
5195 });
5196
5197 for &field in ["alt", "name"].iter() {
5198 if self._additional_params.contains_key(field) {
5199 dlg.finished(false);
5200 return Err(common::Error::FieldClash(field));
5201 }
5202 }
5203
5204 let mut params = Params::with_capacity(3 + self._additional_params.len());
5205 params.push("name", self._name);
5206
5207 params.extend(self._additional_params.iter());
5208
5209 params.push("alt", "json");
5210 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
5211 if self._scopes.is_empty() {
5212 self._scopes
5213 .insert(Scope::CloudPlatform.as_ref().to_string());
5214 }
5215
5216 #[allow(clippy::single_element_loop)]
5217 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5218 url = params.uri_replacement(url, param_name, find_this, true);
5219 }
5220 {
5221 let to_remove = ["name"];
5222 params.remove_params(&to_remove);
5223 }
5224
5225 let url = params.parse_with_url(&url);
5226
5227 loop {
5228 let token = match self
5229 .hub
5230 .auth
5231 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5232 .await
5233 {
5234 Ok(token) => token,
5235 Err(e) => match dlg.token(e) {
5236 Ok(token) => token,
5237 Err(e) => {
5238 dlg.finished(false);
5239 return Err(common::Error::MissingToken(e));
5240 }
5241 },
5242 };
5243 let mut req_result = {
5244 let client = &self.hub.client;
5245 dlg.pre_request();
5246 let mut req_builder = hyper::Request::builder()
5247 .method(hyper::Method::DELETE)
5248 .uri(url.as_str())
5249 .header(USER_AGENT, self.hub._user_agent.clone());
5250
5251 if let Some(token) = token.as_ref() {
5252 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5253 }
5254
5255 let request = req_builder
5256 .header(CONTENT_LENGTH, 0_u64)
5257 .body(common::to_body::<String>(None));
5258
5259 client.request(request.unwrap()).await
5260 };
5261
5262 match req_result {
5263 Err(err) => {
5264 if let common::Retry::After(d) = dlg.http_error(&err) {
5265 sleep(d).await;
5266 continue;
5267 }
5268 dlg.finished(false);
5269 return Err(common::Error::HttpError(err));
5270 }
5271 Ok(res) => {
5272 let (mut parts, body) = res.into_parts();
5273 let mut body = common::Body::new(body);
5274 if !parts.status.is_success() {
5275 let bytes = common::to_bytes(body).await.unwrap_or_default();
5276 let error = serde_json::from_str(&common::to_string(&bytes));
5277 let response = common::to_response(parts, bytes.into());
5278
5279 if let common::Retry::After(d) =
5280 dlg.http_failure(&response, error.as_ref().ok())
5281 {
5282 sleep(d).await;
5283 continue;
5284 }
5285
5286 dlg.finished(false);
5287
5288 return Err(match error {
5289 Ok(value) => common::Error::BadRequest(value),
5290 _ => common::Error::Failure(response),
5291 });
5292 }
5293 let response = {
5294 let bytes = common::to_bytes(body).await.unwrap_or_default();
5295 let encoded = common::to_string(&bytes);
5296 match serde_json::from_str(&encoded) {
5297 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5298 Err(error) => {
5299 dlg.response_json_decode_error(&encoded, &error);
5300 return Err(common::Error::JsonDecodeError(
5301 encoded.to_string(),
5302 error,
5303 ));
5304 }
5305 }
5306 };
5307
5308 dlg.finished(true);
5309 return Ok(response);
5310 }
5311 }
5312 }
5313 }
5314
5315 /// Required. The name of the subscription to delete.
5316 ///
5317 /// Sets the *name* path property to the given value.
5318 ///
5319 /// Even though the property as already been set when instantiating this call,
5320 /// we provide this method for API completeness.
5321 pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
5322 self._name = new_value.to_string();
5323 self
5324 }
5325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5326 /// while executing the actual API request.
5327 ///
5328 /// ````text
5329 /// It should be used to handle progress information, and to implement a certain level of resilience.
5330 /// ````
5331 ///
5332 /// Sets the *delegate* property to the given value.
5333 pub fn delegate(
5334 mut self,
5335 new_value: &'a mut dyn common::Delegate,
5336 ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
5337 self._delegate = Some(new_value);
5338 self
5339 }
5340
5341 /// Set any additional parameter of the query string used in the request.
5342 /// It should be used to set parameters which are not yet available through their own
5343 /// setters.
5344 ///
5345 /// Please note that this method must not be used to set any of the known parameters
5346 /// which have their own setter method. If done anyway, the request will fail.
5347 ///
5348 /// # Additional Parameters
5349 ///
5350 /// * *$.xgafv* (query-string) - V1 error format.
5351 /// * *access_token* (query-string) - OAuth access token.
5352 /// * *alt* (query-string) - Data format for response.
5353 /// * *callback* (query-string) - JSONP
5354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5355 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5358 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5361 pub fn param<T>(
5362 mut self,
5363 name: T,
5364 value: T,
5365 ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5366 where
5367 T: AsRef<str>,
5368 {
5369 self._additional_params
5370 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5371 self
5372 }
5373
5374 /// Identifies the authorization scope for the method you are building.
5375 ///
5376 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5377 /// [`Scope::CloudPlatform`].
5378 ///
5379 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5380 /// tokens for more than one scope.
5381 ///
5382 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5383 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5384 /// sufficient, a read-write scope will do as well.
5385 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5386 where
5387 St: AsRef<str>,
5388 {
5389 self._scopes.insert(String::from(scope.as_ref()));
5390 self
5391 }
5392 /// Identifies the authorization scope(s) for the method you are building.
5393 ///
5394 /// See [`Self::add_scope()`] for details.
5395 pub fn add_scopes<I, St>(
5396 mut self,
5397 scopes: I,
5398 ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5399 where
5400 I: IntoIterator<Item = St>,
5401 St: AsRef<str>,
5402 {
5403 self._scopes
5404 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5405 self
5406 }
5407
5408 /// Removes all scopes, and no default scope will be used either.
5409 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5410 /// for details).
5411 pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
5412 self._scopes.clear();
5413 self
5414 }
5415}
5416
5417/// Returns the subscription configuration.
5418///
5419/// A builder for the *projects.locations.subscriptions.get* method supported by a *admin* resource.
5420/// It is not used directly, but through a [`AdminMethods`] instance.
5421///
5422/// # Example
5423///
5424/// Instantiate a resource method builder
5425///
5426/// ```test_harness,no_run
5427/// # extern crate hyper;
5428/// # extern crate hyper_rustls;
5429/// # extern crate google_pubsublite1 as pubsublite1;
5430/// # async fn dox() {
5431/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5432///
5433/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5434/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5435/// # secret,
5436/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5437/// # ).build().await.unwrap();
5438///
5439/// # let client = hyper_util::client::legacy::Client::builder(
5440/// # hyper_util::rt::TokioExecutor::new()
5441/// # )
5442/// # .build(
5443/// # hyper_rustls::HttpsConnectorBuilder::new()
5444/// # .with_native_roots()
5445/// # .unwrap()
5446/// # .https_or_http()
5447/// # .enable_http1()
5448/// # .build()
5449/// # );
5450/// # let mut hub = PubsubLite::new(client, auth);
5451/// // You can configure optional parameters by calling the respective setters at will, and
5452/// // execute the final call using `doit()`.
5453/// // Values shown here are possibly random and not representative !
5454/// let result = hub.admin().projects_locations_subscriptions_get("name")
5455/// .doit().await;
5456/// # }
5457/// ```
5458pub struct AdminProjectLocationSubscriptionGetCall<'a, C>
5459where
5460 C: 'a,
5461{
5462 hub: &'a PubsubLite<C>,
5463 _name: String,
5464 _delegate: Option<&'a mut dyn common::Delegate>,
5465 _additional_params: HashMap<String, String>,
5466 _scopes: BTreeSet<String>,
5467}
5468
5469impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionGetCall<'a, C> {}
5470
5471impl<'a, C> AdminProjectLocationSubscriptionGetCall<'a, C>
5472where
5473 C: common::Connector,
5474{
5475 /// Perform the operation you have build so far.
5476 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
5477 use std::borrow::Cow;
5478 use std::io::{Read, Seek};
5479
5480 use common::{url::Params, ToParts};
5481 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5482
5483 let mut dd = common::DefaultDelegate;
5484 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5485 dlg.begin(common::MethodInfo {
5486 id: "pubsublite.admin.projects.locations.subscriptions.get",
5487 http_method: hyper::Method::GET,
5488 });
5489
5490 for &field in ["alt", "name"].iter() {
5491 if self._additional_params.contains_key(field) {
5492 dlg.finished(false);
5493 return Err(common::Error::FieldClash(field));
5494 }
5495 }
5496
5497 let mut params = Params::with_capacity(3 + self._additional_params.len());
5498 params.push("name", self._name);
5499
5500 params.extend(self._additional_params.iter());
5501
5502 params.push("alt", "json");
5503 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
5504 if self._scopes.is_empty() {
5505 self._scopes
5506 .insert(Scope::CloudPlatform.as_ref().to_string());
5507 }
5508
5509 #[allow(clippy::single_element_loop)]
5510 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5511 url = params.uri_replacement(url, param_name, find_this, true);
5512 }
5513 {
5514 let to_remove = ["name"];
5515 params.remove_params(&to_remove);
5516 }
5517
5518 let url = params.parse_with_url(&url);
5519
5520 loop {
5521 let token = match self
5522 .hub
5523 .auth
5524 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5525 .await
5526 {
5527 Ok(token) => token,
5528 Err(e) => match dlg.token(e) {
5529 Ok(token) => token,
5530 Err(e) => {
5531 dlg.finished(false);
5532 return Err(common::Error::MissingToken(e));
5533 }
5534 },
5535 };
5536 let mut req_result = {
5537 let client = &self.hub.client;
5538 dlg.pre_request();
5539 let mut req_builder = hyper::Request::builder()
5540 .method(hyper::Method::GET)
5541 .uri(url.as_str())
5542 .header(USER_AGENT, self.hub._user_agent.clone());
5543
5544 if let Some(token) = token.as_ref() {
5545 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5546 }
5547
5548 let request = req_builder
5549 .header(CONTENT_LENGTH, 0_u64)
5550 .body(common::to_body::<String>(None));
5551
5552 client.request(request.unwrap()).await
5553 };
5554
5555 match req_result {
5556 Err(err) => {
5557 if let common::Retry::After(d) = dlg.http_error(&err) {
5558 sleep(d).await;
5559 continue;
5560 }
5561 dlg.finished(false);
5562 return Err(common::Error::HttpError(err));
5563 }
5564 Ok(res) => {
5565 let (mut parts, body) = res.into_parts();
5566 let mut body = common::Body::new(body);
5567 if !parts.status.is_success() {
5568 let bytes = common::to_bytes(body).await.unwrap_or_default();
5569 let error = serde_json::from_str(&common::to_string(&bytes));
5570 let response = common::to_response(parts, bytes.into());
5571
5572 if let common::Retry::After(d) =
5573 dlg.http_failure(&response, error.as_ref().ok())
5574 {
5575 sleep(d).await;
5576 continue;
5577 }
5578
5579 dlg.finished(false);
5580
5581 return Err(match error {
5582 Ok(value) => common::Error::BadRequest(value),
5583 _ => common::Error::Failure(response),
5584 });
5585 }
5586 let response = {
5587 let bytes = common::to_bytes(body).await.unwrap_or_default();
5588 let encoded = common::to_string(&bytes);
5589 match serde_json::from_str(&encoded) {
5590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5591 Err(error) => {
5592 dlg.response_json_decode_error(&encoded, &error);
5593 return Err(common::Error::JsonDecodeError(
5594 encoded.to_string(),
5595 error,
5596 ));
5597 }
5598 }
5599 };
5600
5601 dlg.finished(true);
5602 return Ok(response);
5603 }
5604 }
5605 }
5606 }
5607
5608 /// Required. The name of the subscription whose configuration to return.
5609 ///
5610 /// Sets the *name* path property to the given value.
5611 ///
5612 /// Even though the property as already been set when instantiating this call,
5613 /// we provide this method for API completeness.
5614 pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
5615 self._name = new_value.to_string();
5616 self
5617 }
5618 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5619 /// while executing the actual API request.
5620 ///
5621 /// ````text
5622 /// It should be used to handle progress information, and to implement a certain level of resilience.
5623 /// ````
5624 ///
5625 /// Sets the *delegate* property to the given value.
5626 pub fn delegate(
5627 mut self,
5628 new_value: &'a mut dyn common::Delegate,
5629 ) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
5630 self._delegate = Some(new_value);
5631 self
5632 }
5633
5634 /// Set any additional parameter of the query string used in the request.
5635 /// It should be used to set parameters which are not yet available through their own
5636 /// setters.
5637 ///
5638 /// Please note that this method must not be used to set any of the known parameters
5639 /// which have their own setter method. If done anyway, the request will fail.
5640 ///
5641 /// # Additional Parameters
5642 ///
5643 /// * *$.xgafv* (query-string) - V1 error format.
5644 /// * *access_token* (query-string) - OAuth access token.
5645 /// * *alt* (query-string) - Data format for response.
5646 /// * *callback* (query-string) - JSONP
5647 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5648 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5649 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5650 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5651 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5652 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5653 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5654 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionGetCall<'a, C>
5655 where
5656 T: AsRef<str>,
5657 {
5658 self._additional_params
5659 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5660 self
5661 }
5662
5663 /// Identifies the authorization scope for the method you are building.
5664 ///
5665 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5666 /// [`Scope::CloudPlatform`].
5667 ///
5668 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5669 /// tokens for more than one scope.
5670 ///
5671 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5672 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5673 /// sufficient, a read-write scope will do as well.
5674 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionGetCall<'a, C>
5675 where
5676 St: AsRef<str>,
5677 {
5678 self._scopes.insert(String::from(scope.as_ref()));
5679 self
5680 }
5681 /// Identifies the authorization scope(s) for the method you are building.
5682 ///
5683 /// See [`Self::add_scope()`] for details.
5684 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationSubscriptionGetCall<'a, C>
5685 where
5686 I: IntoIterator<Item = St>,
5687 St: AsRef<str>,
5688 {
5689 self._scopes
5690 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5691 self
5692 }
5693
5694 /// Removes all scopes, and no default scope will be used either.
5695 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5696 /// for details).
5697 pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
5698 self._scopes.clear();
5699 self
5700 }
5701}
5702
5703/// Returns the list of subscriptions for the given project.
5704///
5705/// A builder for the *projects.locations.subscriptions.list* method supported by a *admin* resource.
5706/// It is not used directly, but through a [`AdminMethods`] instance.
5707///
5708/// # Example
5709///
5710/// Instantiate a resource method builder
5711///
5712/// ```test_harness,no_run
5713/// # extern crate hyper;
5714/// # extern crate hyper_rustls;
5715/// # extern crate google_pubsublite1 as pubsublite1;
5716/// # async fn dox() {
5717/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5718///
5719/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5720/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5721/// # secret,
5722/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5723/// # ).build().await.unwrap();
5724///
5725/// # let client = hyper_util::client::legacy::Client::builder(
5726/// # hyper_util::rt::TokioExecutor::new()
5727/// # )
5728/// # .build(
5729/// # hyper_rustls::HttpsConnectorBuilder::new()
5730/// # .with_native_roots()
5731/// # .unwrap()
5732/// # .https_or_http()
5733/// # .enable_http1()
5734/// # .build()
5735/// # );
5736/// # let mut hub = PubsubLite::new(client, auth);
5737/// // You can configure optional parameters by calling the respective setters at will, and
5738/// // execute the final call using `doit()`.
5739/// // Values shown here are possibly random and not representative !
5740/// let result = hub.admin().projects_locations_subscriptions_list("parent")
5741/// .page_token("rebum.")
5742/// .page_size(-57)
5743/// .doit().await;
5744/// # }
5745/// ```
5746pub struct AdminProjectLocationSubscriptionListCall<'a, C>
5747where
5748 C: 'a,
5749{
5750 hub: &'a PubsubLite<C>,
5751 _parent: String,
5752 _page_token: Option<String>,
5753 _page_size: Option<i32>,
5754 _delegate: Option<&'a mut dyn common::Delegate>,
5755 _additional_params: HashMap<String, String>,
5756 _scopes: BTreeSet<String>,
5757}
5758
5759impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionListCall<'a, C> {}
5760
5761impl<'a, C> AdminProjectLocationSubscriptionListCall<'a, C>
5762where
5763 C: common::Connector,
5764{
5765 /// Perform the operation you have build so far.
5766 pub async fn doit(mut self) -> common::Result<(common::Response, ListSubscriptionsResponse)> {
5767 use std::borrow::Cow;
5768 use std::io::{Read, Seek};
5769
5770 use common::{url::Params, ToParts};
5771 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5772
5773 let mut dd = common::DefaultDelegate;
5774 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5775 dlg.begin(common::MethodInfo {
5776 id: "pubsublite.admin.projects.locations.subscriptions.list",
5777 http_method: hyper::Method::GET,
5778 });
5779
5780 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5781 if self._additional_params.contains_key(field) {
5782 dlg.finished(false);
5783 return Err(common::Error::FieldClash(field));
5784 }
5785 }
5786
5787 let mut params = Params::with_capacity(5 + self._additional_params.len());
5788 params.push("parent", self._parent);
5789 if let Some(value) = self._page_token.as_ref() {
5790 params.push("pageToken", value);
5791 }
5792 if let Some(value) = self._page_size.as_ref() {
5793 params.push("pageSize", value.to_string());
5794 }
5795
5796 params.extend(self._additional_params.iter());
5797
5798 params.push("alt", "json");
5799 let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/subscriptions";
5800 if self._scopes.is_empty() {
5801 self._scopes
5802 .insert(Scope::CloudPlatform.as_ref().to_string());
5803 }
5804
5805 #[allow(clippy::single_element_loop)]
5806 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5807 url = params.uri_replacement(url, param_name, find_this, true);
5808 }
5809 {
5810 let to_remove = ["parent"];
5811 params.remove_params(&to_remove);
5812 }
5813
5814 let url = params.parse_with_url(&url);
5815
5816 loop {
5817 let token = match self
5818 .hub
5819 .auth
5820 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5821 .await
5822 {
5823 Ok(token) => token,
5824 Err(e) => match dlg.token(e) {
5825 Ok(token) => token,
5826 Err(e) => {
5827 dlg.finished(false);
5828 return Err(common::Error::MissingToken(e));
5829 }
5830 },
5831 };
5832 let mut req_result = {
5833 let client = &self.hub.client;
5834 dlg.pre_request();
5835 let mut req_builder = hyper::Request::builder()
5836 .method(hyper::Method::GET)
5837 .uri(url.as_str())
5838 .header(USER_AGENT, self.hub._user_agent.clone());
5839
5840 if let Some(token) = token.as_ref() {
5841 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5842 }
5843
5844 let request = req_builder
5845 .header(CONTENT_LENGTH, 0_u64)
5846 .body(common::to_body::<String>(None));
5847
5848 client.request(request.unwrap()).await
5849 };
5850
5851 match req_result {
5852 Err(err) => {
5853 if let common::Retry::After(d) = dlg.http_error(&err) {
5854 sleep(d).await;
5855 continue;
5856 }
5857 dlg.finished(false);
5858 return Err(common::Error::HttpError(err));
5859 }
5860 Ok(res) => {
5861 let (mut parts, body) = res.into_parts();
5862 let mut body = common::Body::new(body);
5863 if !parts.status.is_success() {
5864 let bytes = common::to_bytes(body).await.unwrap_or_default();
5865 let error = serde_json::from_str(&common::to_string(&bytes));
5866 let response = common::to_response(parts, bytes.into());
5867
5868 if let common::Retry::After(d) =
5869 dlg.http_failure(&response, error.as_ref().ok())
5870 {
5871 sleep(d).await;
5872 continue;
5873 }
5874
5875 dlg.finished(false);
5876
5877 return Err(match error {
5878 Ok(value) => common::Error::BadRequest(value),
5879 _ => common::Error::Failure(response),
5880 });
5881 }
5882 let response = {
5883 let bytes = common::to_bytes(body).await.unwrap_or_default();
5884 let encoded = common::to_string(&bytes);
5885 match serde_json::from_str(&encoded) {
5886 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5887 Err(error) => {
5888 dlg.response_json_decode_error(&encoded, &error);
5889 return Err(common::Error::JsonDecodeError(
5890 encoded.to_string(),
5891 error,
5892 ));
5893 }
5894 }
5895 };
5896
5897 dlg.finished(true);
5898 return Ok(response);
5899 }
5900 }
5901 }
5902 }
5903
5904 /// Required. The parent whose subscriptions are to be listed. Structured like `projects/{project_number}/locations/{location}`.
5905 ///
5906 /// Sets the *parent* path property to the given value.
5907 ///
5908 /// Even though the property as already been set when instantiating this call,
5909 /// we provide this method for API completeness.
5910 pub fn parent(mut self, new_value: &str) -> AdminProjectLocationSubscriptionListCall<'a, C> {
5911 self._parent = new_value.to_string();
5912 self
5913 }
5914 /// A page token, received from a previous `ListSubscriptions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSubscriptions` must match the call that provided the page token.
5915 ///
5916 /// Sets the *page token* query property to the given value.
5917 pub fn page_token(
5918 mut self,
5919 new_value: &str,
5920 ) -> AdminProjectLocationSubscriptionListCall<'a, C> {
5921 self._page_token = Some(new_value.to_string());
5922 self
5923 }
5924 /// The maximum number of subscriptions to return. The service may return fewer than this value. If unset or zero, all subscriptions for the parent will be returned.
5925 ///
5926 /// Sets the *page size* query property to the given value.
5927 pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationSubscriptionListCall<'a, C> {
5928 self._page_size = Some(new_value);
5929 self
5930 }
5931 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5932 /// while executing the actual API request.
5933 ///
5934 /// ````text
5935 /// It should be used to handle progress information, and to implement a certain level of resilience.
5936 /// ````
5937 ///
5938 /// Sets the *delegate* property to the given value.
5939 pub fn delegate(
5940 mut self,
5941 new_value: &'a mut dyn common::Delegate,
5942 ) -> AdminProjectLocationSubscriptionListCall<'a, C> {
5943 self._delegate = Some(new_value);
5944 self
5945 }
5946
5947 /// Set any additional parameter of the query string used in the request.
5948 /// It should be used to set parameters which are not yet available through their own
5949 /// setters.
5950 ///
5951 /// Please note that this method must not be used to set any of the known parameters
5952 /// which have their own setter method. If done anyway, the request will fail.
5953 ///
5954 /// # Additional Parameters
5955 ///
5956 /// * *$.xgafv* (query-string) - V1 error format.
5957 /// * *access_token* (query-string) - OAuth access token.
5958 /// * *alt* (query-string) - Data format for response.
5959 /// * *callback* (query-string) - JSONP
5960 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5961 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5962 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5963 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5964 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5965 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5966 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5967 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionListCall<'a, C>
5968 where
5969 T: AsRef<str>,
5970 {
5971 self._additional_params
5972 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5973 self
5974 }
5975
5976 /// Identifies the authorization scope for the method you are building.
5977 ///
5978 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5979 /// [`Scope::CloudPlatform`].
5980 ///
5981 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5982 /// tokens for more than one scope.
5983 ///
5984 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5985 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5986 /// sufficient, a read-write scope will do as well.
5987 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionListCall<'a, C>
5988 where
5989 St: AsRef<str>,
5990 {
5991 self._scopes.insert(String::from(scope.as_ref()));
5992 self
5993 }
5994 /// Identifies the authorization scope(s) for the method you are building.
5995 ///
5996 /// See [`Self::add_scope()`] for details.
5997 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationSubscriptionListCall<'a, C>
5998 where
5999 I: IntoIterator<Item = St>,
6000 St: AsRef<str>,
6001 {
6002 self._scopes
6003 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6004 self
6005 }
6006
6007 /// Removes all scopes, and no default scope will be used either.
6008 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6009 /// for details).
6010 pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionListCall<'a, C> {
6011 self._scopes.clear();
6012 self
6013 }
6014}
6015
6016/// Updates properties of the specified subscription.
6017///
6018/// A builder for the *projects.locations.subscriptions.patch* method supported by a *admin* resource.
6019/// It is not used directly, but through a [`AdminMethods`] instance.
6020///
6021/// # Example
6022///
6023/// Instantiate a resource method builder
6024///
6025/// ```test_harness,no_run
6026/// # extern crate hyper;
6027/// # extern crate hyper_rustls;
6028/// # extern crate google_pubsublite1 as pubsublite1;
6029/// use pubsublite1::api::Subscription;
6030/// # async fn dox() {
6031/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6032///
6033/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6034/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6035/// # secret,
6036/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6037/// # ).build().await.unwrap();
6038///
6039/// # let client = hyper_util::client::legacy::Client::builder(
6040/// # hyper_util::rt::TokioExecutor::new()
6041/// # )
6042/// # .build(
6043/// # hyper_rustls::HttpsConnectorBuilder::new()
6044/// # .with_native_roots()
6045/// # .unwrap()
6046/// # .https_or_http()
6047/// # .enable_http1()
6048/// # .build()
6049/// # );
6050/// # let mut hub = PubsubLite::new(client, auth);
6051/// // As the method needs a request, you would usually fill it with the desired information
6052/// // into the respective structure. Some of the parts shown here might not be applicable !
6053/// // Values shown here are possibly random and not representative !
6054/// let mut req = Subscription::default();
6055///
6056/// // You can configure optional parameters by calling the respective setters at will, and
6057/// // execute the final call using `doit()`.
6058/// // Values shown here are possibly random and not representative !
6059/// let result = hub.admin().projects_locations_subscriptions_patch(req, "name")
6060/// .update_mask(FieldMask::new::<&str>(&[]))
6061/// .doit().await;
6062/// # }
6063/// ```
6064pub struct AdminProjectLocationSubscriptionPatchCall<'a, C>
6065where
6066 C: 'a,
6067{
6068 hub: &'a PubsubLite<C>,
6069 _request: Subscription,
6070 _name: String,
6071 _update_mask: Option<common::FieldMask>,
6072 _delegate: Option<&'a mut dyn common::Delegate>,
6073 _additional_params: HashMap<String, String>,
6074 _scopes: BTreeSet<String>,
6075}
6076
6077impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionPatchCall<'a, C> {}
6078
6079impl<'a, C> AdminProjectLocationSubscriptionPatchCall<'a, C>
6080where
6081 C: common::Connector,
6082{
6083 /// Perform the operation you have build so far.
6084 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
6085 use std::borrow::Cow;
6086 use std::io::{Read, Seek};
6087
6088 use common::{url::Params, ToParts};
6089 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6090
6091 let mut dd = common::DefaultDelegate;
6092 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6093 dlg.begin(common::MethodInfo {
6094 id: "pubsublite.admin.projects.locations.subscriptions.patch",
6095 http_method: hyper::Method::PATCH,
6096 });
6097
6098 for &field in ["alt", "name", "updateMask"].iter() {
6099 if self._additional_params.contains_key(field) {
6100 dlg.finished(false);
6101 return Err(common::Error::FieldClash(field));
6102 }
6103 }
6104
6105 let mut params = Params::with_capacity(5 + self._additional_params.len());
6106 params.push("name", self._name);
6107 if let Some(value) = self._update_mask.as_ref() {
6108 params.push("updateMask", value.to_string());
6109 }
6110
6111 params.extend(self._additional_params.iter());
6112
6113 params.push("alt", "json");
6114 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
6115 if self._scopes.is_empty() {
6116 self._scopes
6117 .insert(Scope::CloudPlatform.as_ref().to_string());
6118 }
6119
6120 #[allow(clippy::single_element_loop)]
6121 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6122 url = params.uri_replacement(url, param_name, find_this, true);
6123 }
6124 {
6125 let to_remove = ["name"];
6126 params.remove_params(&to_remove);
6127 }
6128
6129 let url = params.parse_with_url(&url);
6130
6131 let mut json_mime_type = mime::APPLICATION_JSON;
6132 let mut request_value_reader = {
6133 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6134 common::remove_json_null_values(&mut value);
6135 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6136 serde_json::to_writer(&mut dst, &value).unwrap();
6137 dst
6138 };
6139 let request_size = request_value_reader
6140 .seek(std::io::SeekFrom::End(0))
6141 .unwrap();
6142 request_value_reader
6143 .seek(std::io::SeekFrom::Start(0))
6144 .unwrap();
6145
6146 loop {
6147 let token = match self
6148 .hub
6149 .auth
6150 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6151 .await
6152 {
6153 Ok(token) => token,
6154 Err(e) => match dlg.token(e) {
6155 Ok(token) => token,
6156 Err(e) => {
6157 dlg.finished(false);
6158 return Err(common::Error::MissingToken(e));
6159 }
6160 },
6161 };
6162 request_value_reader
6163 .seek(std::io::SeekFrom::Start(0))
6164 .unwrap();
6165 let mut req_result = {
6166 let client = &self.hub.client;
6167 dlg.pre_request();
6168 let mut req_builder = hyper::Request::builder()
6169 .method(hyper::Method::PATCH)
6170 .uri(url.as_str())
6171 .header(USER_AGENT, self.hub._user_agent.clone());
6172
6173 if let Some(token) = token.as_ref() {
6174 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6175 }
6176
6177 let request = req_builder
6178 .header(CONTENT_TYPE, json_mime_type.to_string())
6179 .header(CONTENT_LENGTH, request_size as u64)
6180 .body(common::to_body(
6181 request_value_reader.get_ref().clone().into(),
6182 ));
6183
6184 client.request(request.unwrap()).await
6185 };
6186
6187 match req_result {
6188 Err(err) => {
6189 if let common::Retry::After(d) = dlg.http_error(&err) {
6190 sleep(d).await;
6191 continue;
6192 }
6193 dlg.finished(false);
6194 return Err(common::Error::HttpError(err));
6195 }
6196 Ok(res) => {
6197 let (mut parts, body) = res.into_parts();
6198 let mut body = common::Body::new(body);
6199 if !parts.status.is_success() {
6200 let bytes = common::to_bytes(body).await.unwrap_or_default();
6201 let error = serde_json::from_str(&common::to_string(&bytes));
6202 let response = common::to_response(parts, bytes.into());
6203
6204 if let common::Retry::After(d) =
6205 dlg.http_failure(&response, error.as_ref().ok())
6206 {
6207 sleep(d).await;
6208 continue;
6209 }
6210
6211 dlg.finished(false);
6212
6213 return Err(match error {
6214 Ok(value) => common::Error::BadRequest(value),
6215 _ => common::Error::Failure(response),
6216 });
6217 }
6218 let response = {
6219 let bytes = common::to_bytes(body).await.unwrap_or_default();
6220 let encoded = common::to_string(&bytes);
6221 match serde_json::from_str(&encoded) {
6222 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6223 Err(error) => {
6224 dlg.response_json_decode_error(&encoded, &error);
6225 return Err(common::Error::JsonDecodeError(
6226 encoded.to_string(),
6227 error,
6228 ));
6229 }
6230 }
6231 };
6232
6233 dlg.finished(true);
6234 return Ok(response);
6235 }
6236 }
6237 }
6238 }
6239
6240 ///
6241 /// Sets the *request* property to the given value.
6242 ///
6243 /// Even though the property as already been set when instantiating this call,
6244 /// we provide this method for API completeness.
6245 pub fn request(
6246 mut self,
6247 new_value: Subscription,
6248 ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6249 self._request = new_value;
6250 self
6251 }
6252 /// The name of the subscription. Structured like: projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
6253 ///
6254 /// Sets the *name* path property to the given value.
6255 ///
6256 /// Even though the property as already been set when instantiating this call,
6257 /// we provide this method for API completeness.
6258 pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6259 self._name = new_value.to_string();
6260 self
6261 }
6262 /// Required. A mask specifying the subscription fields to change.
6263 ///
6264 /// Sets the *update mask* query property to the given value.
6265 pub fn update_mask(
6266 mut self,
6267 new_value: common::FieldMask,
6268 ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6269 self._update_mask = Some(new_value);
6270 self
6271 }
6272 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6273 /// while executing the actual API request.
6274 ///
6275 /// ````text
6276 /// It should be used to handle progress information, and to implement a certain level of resilience.
6277 /// ````
6278 ///
6279 /// Sets the *delegate* property to the given value.
6280 pub fn delegate(
6281 mut self,
6282 new_value: &'a mut dyn common::Delegate,
6283 ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6284 self._delegate = Some(new_value);
6285 self
6286 }
6287
6288 /// Set any additional parameter of the query string used in the request.
6289 /// It should be used to set parameters which are not yet available through their own
6290 /// setters.
6291 ///
6292 /// Please note that this method must not be used to set any of the known parameters
6293 /// which have their own setter method. If done anyway, the request will fail.
6294 ///
6295 /// # Additional Parameters
6296 ///
6297 /// * *$.xgafv* (query-string) - V1 error format.
6298 /// * *access_token* (query-string) - OAuth access token.
6299 /// * *alt* (query-string) - Data format for response.
6300 /// * *callback* (query-string) - JSONP
6301 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6302 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6303 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6304 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6305 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6306 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6307 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6308 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionPatchCall<'a, C>
6309 where
6310 T: AsRef<str>,
6311 {
6312 self._additional_params
6313 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6314 self
6315 }
6316
6317 /// Identifies the authorization scope for the method you are building.
6318 ///
6319 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6320 /// [`Scope::CloudPlatform`].
6321 ///
6322 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6323 /// tokens for more than one scope.
6324 ///
6325 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6326 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6327 /// sufficient, a read-write scope will do as well.
6328 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionPatchCall<'a, C>
6329 where
6330 St: AsRef<str>,
6331 {
6332 self._scopes.insert(String::from(scope.as_ref()));
6333 self
6334 }
6335 /// Identifies the authorization scope(s) for the method you are building.
6336 ///
6337 /// See [`Self::add_scope()`] for details.
6338 pub fn add_scopes<I, St>(
6339 mut self,
6340 scopes: I,
6341 ) -> AdminProjectLocationSubscriptionPatchCall<'a, C>
6342 where
6343 I: IntoIterator<Item = St>,
6344 St: AsRef<str>,
6345 {
6346 self._scopes
6347 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6348 self
6349 }
6350
6351 /// Removes all scopes, and no default scope will be used either.
6352 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6353 /// for details).
6354 pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6355 self._scopes.clear();
6356 self
6357 }
6358}
6359
6360/// Performs an out-of-band seek for a subscription to a specified target, which may be timestamps or named positions within the message backlog. Seek translates these targets to cursors for each partition and orchestrates subscribers to start consuming messages from these seek cursors. If an operation is returned, the seek has been registered and subscribers will eventually receive messages from the seek cursors (i.e. eventual consistency), as long as they are using a minimum supported client library version and not a system that tracks cursors independently of Pub/Sub Lite (e.g. Apache Beam, Dataflow, Spark). The seek operation will fail for unsupported clients. If clients would like to know when subscribers react to the seek (or not), they can poll the operation. The seek operation will succeed and complete once subscribers are ready to receive messages from the seek cursors for all partitions of the topic. This means that the seek operation will not complete until all subscribers come online. If the previous seek operation has not yet completed, it will be aborted and the new invocation of seek will supersede it.
6361///
6362/// A builder for the *projects.locations.subscriptions.seek* method supported by a *admin* resource.
6363/// It is not used directly, but through a [`AdminMethods`] instance.
6364///
6365/// # Example
6366///
6367/// Instantiate a resource method builder
6368///
6369/// ```test_harness,no_run
6370/// # extern crate hyper;
6371/// # extern crate hyper_rustls;
6372/// # extern crate google_pubsublite1 as pubsublite1;
6373/// use pubsublite1::api::SeekSubscriptionRequest;
6374/// # async fn dox() {
6375/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6376///
6377/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6378/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6379/// # secret,
6380/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6381/// # ).build().await.unwrap();
6382///
6383/// # let client = hyper_util::client::legacy::Client::builder(
6384/// # hyper_util::rt::TokioExecutor::new()
6385/// # )
6386/// # .build(
6387/// # hyper_rustls::HttpsConnectorBuilder::new()
6388/// # .with_native_roots()
6389/// # .unwrap()
6390/// # .https_or_http()
6391/// # .enable_http1()
6392/// # .build()
6393/// # );
6394/// # let mut hub = PubsubLite::new(client, auth);
6395/// // As the method needs a request, you would usually fill it with the desired information
6396/// // into the respective structure. Some of the parts shown here might not be applicable !
6397/// // Values shown here are possibly random and not representative !
6398/// let mut req = SeekSubscriptionRequest::default();
6399///
6400/// // You can configure optional parameters by calling the respective setters at will, and
6401/// // execute the final call using `doit()`.
6402/// // Values shown here are possibly random and not representative !
6403/// let result = hub.admin().projects_locations_subscriptions_seek(req, "name")
6404/// .doit().await;
6405/// # }
6406/// ```
6407pub struct AdminProjectLocationSubscriptionSeekCall<'a, C>
6408where
6409 C: 'a,
6410{
6411 hub: &'a PubsubLite<C>,
6412 _request: SeekSubscriptionRequest,
6413 _name: String,
6414 _delegate: Option<&'a mut dyn common::Delegate>,
6415 _additional_params: HashMap<String, String>,
6416 _scopes: BTreeSet<String>,
6417}
6418
6419impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionSeekCall<'a, C> {}
6420
6421impl<'a, C> AdminProjectLocationSubscriptionSeekCall<'a, C>
6422where
6423 C: common::Connector,
6424{
6425 /// Perform the operation you have build so far.
6426 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6427 use std::borrow::Cow;
6428 use std::io::{Read, Seek};
6429
6430 use common::{url::Params, ToParts};
6431 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6432
6433 let mut dd = common::DefaultDelegate;
6434 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6435 dlg.begin(common::MethodInfo {
6436 id: "pubsublite.admin.projects.locations.subscriptions.seek",
6437 http_method: hyper::Method::POST,
6438 });
6439
6440 for &field in ["alt", "name"].iter() {
6441 if self._additional_params.contains_key(field) {
6442 dlg.finished(false);
6443 return Err(common::Error::FieldClash(field));
6444 }
6445 }
6446
6447 let mut params = Params::with_capacity(4 + self._additional_params.len());
6448 params.push("name", self._name);
6449
6450 params.extend(self._additional_params.iter());
6451
6452 params.push("alt", "json");
6453 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}:seek";
6454 if self._scopes.is_empty() {
6455 self._scopes
6456 .insert(Scope::CloudPlatform.as_ref().to_string());
6457 }
6458
6459 #[allow(clippy::single_element_loop)]
6460 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6461 url = params.uri_replacement(url, param_name, find_this, true);
6462 }
6463 {
6464 let to_remove = ["name"];
6465 params.remove_params(&to_remove);
6466 }
6467
6468 let url = params.parse_with_url(&url);
6469
6470 let mut json_mime_type = mime::APPLICATION_JSON;
6471 let mut request_value_reader = {
6472 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6473 common::remove_json_null_values(&mut value);
6474 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6475 serde_json::to_writer(&mut dst, &value).unwrap();
6476 dst
6477 };
6478 let request_size = request_value_reader
6479 .seek(std::io::SeekFrom::End(0))
6480 .unwrap();
6481 request_value_reader
6482 .seek(std::io::SeekFrom::Start(0))
6483 .unwrap();
6484
6485 loop {
6486 let token = match self
6487 .hub
6488 .auth
6489 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6490 .await
6491 {
6492 Ok(token) => token,
6493 Err(e) => match dlg.token(e) {
6494 Ok(token) => token,
6495 Err(e) => {
6496 dlg.finished(false);
6497 return Err(common::Error::MissingToken(e));
6498 }
6499 },
6500 };
6501 request_value_reader
6502 .seek(std::io::SeekFrom::Start(0))
6503 .unwrap();
6504 let mut req_result = {
6505 let client = &self.hub.client;
6506 dlg.pre_request();
6507 let mut req_builder = hyper::Request::builder()
6508 .method(hyper::Method::POST)
6509 .uri(url.as_str())
6510 .header(USER_AGENT, self.hub._user_agent.clone());
6511
6512 if let Some(token) = token.as_ref() {
6513 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6514 }
6515
6516 let request = req_builder
6517 .header(CONTENT_TYPE, json_mime_type.to_string())
6518 .header(CONTENT_LENGTH, request_size as u64)
6519 .body(common::to_body(
6520 request_value_reader.get_ref().clone().into(),
6521 ));
6522
6523 client.request(request.unwrap()).await
6524 };
6525
6526 match req_result {
6527 Err(err) => {
6528 if let common::Retry::After(d) = dlg.http_error(&err) {
6529 sleep(d).await;
6530 continue;
6531 }
6532 dlg.finished(false);
6533 return Err(common::Error::HttpError(err));
6534 }
6535 Ok(res) => {
6536 let (mut parts, body) = res.into_parts();
6537 let mut body = common::Body::new(body);
6538 if !parts.status.is_success() {
6539 let bytes = common::to_bytes(body).await.unwrap_or_default();
6540 let error = serde_json::from_str(&common::to_string(&bytes));
6541 let response = common::to_response(parts, bytes.into());
6542
6543 if let common::Retry::After(d) =
6544 dlg.http_failure(&response, error.as_ref().ok())
6545 {
6546 sleep(d).await;
6547 continue;
6548 }
6549
6550 dlg.finished(false);
6551
6552 return Err(match error {
6553 Ok(value) => common::Error::BadRequest(value),
6554 _ => common::Error::Failure(response),
6555 });
6556 }
6557 let response = {
6558 let bytes = common::to_bytes(body).await.unwrap_or_default();
6559 let encoded = common::to_string(&bytes);
6560 match serde_json::from_str(&encoded) {
6561 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6562 Err(error) => {
6563 dlg.response_json_decode_error(&encoded, &error);
6564 return Err(common::Error::JsonDecodeError(
6565 encoded.to_string(),
6566 error,
6567 ));
6568 }
6569 }
6570 };
6571
6572 dlg.finished(true);
6573 return Ok(response);
6574 }
6575 }
6576 }
6577 }
6578
6579 ///
6580 /// Sets the *request* property to the given value.
6581 ///
6582 /// Even though the property as already been set when instantiating this call,
6583 /// we provide this method for API completeness.
6584 pub fn request(
6585 mut self,
6586 new_value: SeekSubscriptionRequest,
6587 ) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6588 self._request = new_value;
6589 self
6590 }
6591 /// Required. The name of the subscription to seek.
6592 ///
6593 /// Sets the *name* path property to the given value.
6594 ///
6595 /// Even though the property as already been set when instantiating this call,
6596 /// we provide this method for API completeness.
6597 pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6598 self._name = new_value.to_string();
6599 self
6600 }
6601 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6602 /// while executing the actual API request.
6603 ///
6604 /// ````text
6605 /// It should be used to handle progress information, and to implement a certain level of resilience.
6606 /// ````
6607 ///
6608 /// Sets the *delegate* property to the given value.
6609 pub fn delegate(
6610 mut self,
6611 new_value: &'a mut dyn common::Delegate,
6612 ) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6613 self._delegate = Some(new_value);
6614 self
6615 }
6616
6617 /// Set any additional parameter of the query string used in the request.
6618 /// It should be used to set parameters which are not yet available through their own
6619 /// setters.
6620 ///
6621 /// Please note that this method must not be used to set any of the known parameters
6622 /// which have their own setter method. If done anyway, the request will fail.
6623 ///
6624 /// # Additional Parameters
6625 ///
6626 /// * *$.xgafv* (query-string) - V1 error format.
6627 /// * *access_token* (query-string) - OAuth access token.
6628 /// * *alt* (query-string) - Data format for response.
6629 /// * *callback* (query-string) - JSONP
6630 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6631 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6632 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6633 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6634 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6635 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6636 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6637 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionSeekCall<'a, C>
6638 where
6639 T: AsRef<str>,
6640 {
6641 self._additional_params
6642 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6643 self
6644 }
6645
6646 /// Identifies the authorization scope for the method you are building.
6647 ///
6648 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6649 /// [`Scope::CloudPlatform`].
6650 ///
6651 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6652 /// tokens for more than one scope.
6653 ///
6654 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6655 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6656 /// sufficient, a read-write scope will do as well.
6657 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionSeekCall<'a, C>
6658 where
6659 St: AsRef<str>,
6660 {
6661 self._scopes.insert(String::from(scope.as_ref()));
6662 self
6663 }
6664 /// Identifies the authorization scope(s) for the method you are building.
6665 ///
6666 /// See [`Self::add_scope()`] for details.
6667 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationSubscriptionSeekCall<'a, C>
6668 where
6669 I: IntoIterator<Item = St>,
6670 St: AsRef<str>,
6671 {
6672 self._scopes
6673 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6674 self
6675 }
6676
6677 /// Removes all scopes, and no default scope will be used either.
6678 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6679 /// for details).
6680 pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6681 self._scopes.clear();
6682 self
6683 }
6684}
6685
6686/// Lists the subscriptions attached to the specified topic.
6687///
6688/// A builder for the *projects.locations.topics.subscriptions.list* method supported by a *admin* resource.
6689/// It is not used directly, but through a [`AdminMethods`] instance.
6690///
6691/// # Example
6692///
6693/// Instantiate a resource method builder
6694///
6695/// ```test_harness,no_run
6696/// # extern crate hyper;
6697/// # extern crate hyper_rustls;
6698/// # extern crate google_pubsublite1 as pubsublite1;
6699/// # async fn dox() {
6700/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6701///
6702/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6703/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6704/// # secret,
6705/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6706/// # ).build().await.unwrap();
6707///
6708/// # let client = hyper_util::client::legacy::Client::builder(
6709/// # hyper_util::rt::TokioExecutor::new()
6710/// # )
6711/// # .build(
6712/// # hyper_rustls::HttpsConnectorBuilder::new()
6713/// # .with_native_roots()
6714/// # .unwrap()
6715/// # .https_or_http()
6716/// # .enable_http1()
6717/// # .build()
6718/// # );
6719/// # let mut hub = PubsubLite::new(client, auth);
6720/// // You can configure optional parameters by calling the respective setters at will, and
6721/// // execute the final call using `doit()`.
6722/// // Values shown here are possibly random and not representative !
6723/// let result = hub.admin().projects_locations_topics_subscriptions_list("name")
6724/// .page_token("gubergren")
6725/// .page_size(-17)
6726/// .doit().await;
6727/// # }
6728/// ```
6729pub struct AdminProjectLocationTopicSubscriptionListCall<'a, C>
6730where
6731 C: 'a,
6732{
6733 hub: &'a PubsubLite<C>,
6734 _name: String,
6735 _page_token: Option<String>,
6736 _page_size: Option<i32>,
6737 _delegate: Option<&'a mut dyn common::Delegate>,
6738 _additional_params: HashMap<String, String>,
6739 _scopes: BTreeSet<String>,
6740}
6741
6742impl<'a, C> common::CallBuilder for AdminProjectLocationTopicSubscriptionListCall<'a, C> {}
6743
6744impl<'a, C> AdminProjectLocationTopicSubscriptionListCall<'a, C>
6745where
6746 C: common::Connector,
6747{
6748 /// Perform the operation you have build so far.
6749 pub async fn doit(
6750 mut self,
6751 ) -> common::Result<(common::Response, ListTopicSubscriptionsResponse)> {
6752 use std::borrow::Cow;
6753 use std::io::{Read, Seek};
6754
6755 use common::{url::Params, ToParts};
6756 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6757
6758 let mut dd = common::DefaultDelegate;
6759 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6760 dlg.begin(common::MethodInfo {
6761 id: "pubsublite.admin.projects.locations.topics.subscriptions.list",
6762 http_method: hyper::Method::GET,
6763 });
6764
6765 for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
6766 if self._additional_params.contains_key(field) {
6767 dlg.finished(false);
6768 return Err(common::Error::FieldClash(field));
6769 }
6770 }
6771
6772 let mut params = Params::with_capacity(5 + self._additional_params.len());
6773 params.push("name", self._name);
6774 if let Some(value) = self._page_token.as_ref() {
6775 params.push("pageToken", value);
6776 }
6777 if let Some(value) = self._page_size.as_ref() {
6778 params.push("pageSize", value.to_string());
6779 }
6780
6781 params.extend(self._additional_params.iter());
6782
6783 params.push("alt", "json");
6784 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/subscriptions";
6785 if self._scopes.is_empty() {
6786 self._scopes
6787 .insert(Scope::CloudPlatform.as_ref().to_string());
6788 }
6789
6790 #[allow(clippy::single_element_loop)]
6791 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6792 url = params.uri_replacement(url, param_name, find_this, true);
6793 }
6794 {
6795 let to_remove = ["name"];
6796 params.remove_params(&to_remove);
6797 }
6798
6799 let url = params.parse_with_url(&url);
6800
6801 loop {
6802 let token = match self
6803 .hub
6804 .auth
6805 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6806 .await
6807 {
6808 Ok(token) => token,
6809 Err(e) => match dlg.token(e) {
6810 Ok(token) => token,
6811 Err(e) => {
6812 dlg.finished(false);
6813 return Err(common::Error::MissingToken(e));
6814 }
6815 },
6816 };
6817 let mut req_result = {
6818 let client = &self.hub.client;
6819 dlg.pre_request();
6820 let mut req_builder = hyper::Request::builder()
6821 .method(hyper::Method::GET)
6822 .uri(url.as_str())
6823 .header(USER_AGENT, self.hub._user_agent.clone());
6824
6825 if let Some(token) = token.as_ref() {
6826 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6827 }
6828
6829 let request = req_builder
6830 .header(CONTENT_LENGTH, 0_u64)
6831 .body(common::to_body::<String>(None));
6832
6833 client.request(request.unwrap()).await
6834 };
6835
6836 match req_result {
6837 Err(err) => {
6838 if let common::Retry::After(d) = dlg.http_error(&err) {
6839 sleep(d).await;
6840 continue;
6841 }
6842 dlg.finished(false);
6843 return Err(common::Error::HttpError(err));
6844 }
6845 Ok(res) => {
6846 let (mut parts, body) = res.into_parts();
6847 let mut body = common::Body::new(body);
6848 if !parts.status.is_success() {
6849 let bytes = common::to_bytes(body).await.unwrap_or_default();
6850 let error = serde_json::from_str(&common::to_string(&bytes));
6851 let response = common::to_response(parts, bytes.into());
6852
6853 if let common::Retry::After(d) =
6854 dlg.http_failure(&response, error.as_ref().ok())
6855 {
6856 sleep(d).await;
6857 continue;
6858 }
6859
6860 dlg.finished(false);
6861
6862 return Err(match error {
6863 Ok(value) => common::Error::BadRequest(value),
6864 _ => common::Error::Failure(response),
6865 });
6866 }
6867 let response = {
6868 let bytes = common::to_bytes(body).await.unwrap_or_default();
6869 let encoded = common::to_string(&bytes);
6870 match serde_json::from_str(&encoded) {
6871 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6872 Err(error) => {
6873 dlg.response_json_decode_error(&encoded, &error);
6874 return Err(common::Error::JsonDecodeError(
6875 encoded.to_string(),
6876 error,
6877 ));
6878 }
6879 }
6880 };
6881
6882 dlg.finished(true);
6883 return Ok(response);
6884 }
6885 }
6886 }
6887 }
6888
6889 /// Required. The name of the topic whose subscriptions to list.
6890 ///
6891 /// Sets the *name* path property to the given value.
6892 ///
6893 /// Even though the property as already been set when instantiating this call,
6894 /// we provide this method for API completeness.
6895 pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
6896 self._name = new_value.to_string();
6897 self
6898 }
6899 /// A page token, received from a previous `ListTopicSubscriptions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListTopicSubscriptions` must match the call that provided the page token.
6900 ///
6901 /// Sets the *page token* query property to the given value.
6902 pub fn page_token(
6903 mut self,
6904 new_value: &str,
6905 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
6906 self._page_token = Some(new_value.to_string());
6907 self
6908 }
6909 /// The maximum number of subscriptions to return. The service may return fewer than this value. If unset or zero, all subscriptions for the given topic will be returned.
6910 ///
6911 /// Sets the *page size* query property to the given value.
6912 pub fn page_size(
6913 mut self,
6914 new_value: i32,
6915 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
6916 self._page_size = Some(new_value);
6917 self
6918 }
6919 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6920 /// while executing the actual API request.
6921 ///
6922 /// ````text
6923 /// It should be used to handle progress information, and to implement a certain level of resilience.
6924 /// ````
6925 ///
6926 /// Sets the *delegate* property to the given value.
6927 pub fn delegate(
6928 mut self,
6929 new_value: &'a mut dyn common::Delegate,
6930 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
6931 self._delegate = Some(new_value);
6932 self
6933 }
6934
6935 /// Set any additional parameter of the query string used in the request.
6936 /// It should be used to set parameters which are not yet available through their own
6937 /// setters.
6938 ///
6939 /// Please note that this method must not be used to set any of the known parameters
6940 /// which have their own setter method. If done anyway, the request will fail.
6941 ///
6942 /// # Additional Parameters
6943 ///
6944 /// * *$.xgafv* (query-string) - V1 error format.
6945 /// * *access_token* (query-string) - OAuth access token.
6946 /// * *alt* (query-string) - Data format for response.
6947 /// * *callback* (query-string) - JSONP
6948 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6949 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6950 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6951 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6952 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6953 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6954 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6955 pub fn param<T>(
6956 mut self,
6957 name: T,
6958 value: T,
6959 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C>
6960 where
6961 T: AsRef<str>,
6962 {
6963 self._additional_params
6964 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6965 self
6966 }
6967
6968 /// Identifies the authorization scope for the method you are building.
6969 ///
6970 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6971 /// [`Scope::CloudPlatform`].
6972 ///
6973 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6974 /// tokens for more than one scope.
6975 ///
6976 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6977 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6978 /// sufficient, a read-write scope will do as well.
6979 pub fn add_scope<St>(
6980 mut self,
6981 scope: St,
6982 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C>
6983 where
6984 St: AsRef<str>,
6985 {
6986 self._scopes.insert(String::from(scope.as_ref()));
6987 self
6988 }
6989 /// Identifies the authorization scope(s) for the method you are building.
6990 ///
6991 /// See [`Self::add_scope()`] for details.
6992 pub fn add_scopes<I, St>(
6993 mut self,
6994 scopes: I,
6995 ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C>
6996 where
6997 I: IntoIterator<Item = St>,
6998 St: AsRef<str>,
6999 {
7000 self._scopes
7001 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7002 self
7003 }
7004
7005 /// Removes all scopes, and no default scope will be used either.
7006 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7007 /// for details).
7008 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
7009 self._scopes.clear();
7010 self
7011 }
7012}
7013
7014/// Creates a new topic.
7015///
7016/// A builder for the *projects.locations.topics.create* method supported by a *admin* resource.
7017/// It is not used directly, but through a [`AdminMethods`] instance.
7018///
7019/// # Example
7020///
7021/// Instantiate a resource method builder
7022///
7023/// ```test_harness,no_run
7024/// # extern crate hyper;
7025/// # extern crate hyper_rustls;
7026/// # extern crate google_pubsublite1 as pubsublite1;
7027/// use pubsublite1::api::Topic;
7028/// # async fn dox() {
7029/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7030///
7031/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7032/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7033/// # secret,
7034/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7035/// # ).build().await.unwrap();
7036///
7037/// # let client = hyper_util::client::legacy::Client::builder(
7038/// # hyper_util::rt::TokioExecutor::new()
7039/// # )
7040/// # .build(
7041/// # hyper_rustls::HttpsConnectorBuilder::new()
7042/// # .with_native_roots()
7043/// # .unwrap()
7044/// # .https_or_http()
7045/// # .enable_http1()
7046/// # .build()
7047/// # );
7048/// # let mut hub = PubsubLite::new(client, auth);
7049/// // As the method needs a request, you would usually fill it with the desired information
7050/// // into the respective structure. Some of the parts shown here might not be applicable !
7051/// // Values shown here are possibly random and not representative !
7052/// let mut req = Topic::default();
7053///
7054/// // You can configure optional parameters by calling the respective setters at will, and
7055/// // execute the final call using `doit()`.
7056/// // Values shown here are possibly random and not representative !
7057/// let result = hub.admin().projects_locations_topics_create(req, "parent")
7058/// .topic_id("Lorem")
7059/// .doit().await;
7060/// # }
7061/// ```
7062pub struct AdminProjectLocationTopicCreateCall<'a, C>
7063where
7064 C: 'a,
7065{
7066 hub: &'a PubsubLite<C>,
7067 _request: Topic,
7068 _parent: String,
7069 _topic_id: Option<String>,
7070 _delegate: Option<&'a mut dyn common::Delegate>,
7071 _additional_params: HashMap<String, String>,
7072 _scopes: BTreeSet<String>,
7073}
7074
7075impl<'a, C> common::CallBuilder for AdminProjectLocationTopicCreateCall<'a, C> {}
7076
7077impl<'a, C> AdminProjectLocationTopicCreateCall<'a, C>
7078where
7079 C: common::Connector,
7080{
7081 /// Perform the operation you have build so far.
7082 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
7083 use std::borrow::Cow;
7084 use std::io::{Read, Seek};
7085
7086 use common::{url::Params, ToParts};
7087 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7088
7089 let mut dd = common::DefaultDelegate;
7090 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7091 dlg.begin(common::MethodInfo {
7092 id: "pubsublite.admin.projects.locations.topics.create",
7093 http_method: hyper::Method::POST,
7094 });
7095
7096 for &field in ["alt", "parent", "topicId"].iter() {
7097 if self._additional_params.contains_key(field) {
7098 dlg.finished(false);
7099 return Err(common::Error::FieldClash(field));
7100 }
7101 }
7102
7103 let mut params = Params::with_capacity(5 + self._additional_params.len());
7104 params.push("parent", self._parent);
7105 if let Some(value) = self._topic_id.as_ref() {
7106 params.push("topicId", value);
7107 }
7108
7109 params.extend(self._additional_params.iter());
7110
7111 params.push("alt", "json");
7112 let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/topics";
7113 if self._scopes.is_empty() {
7114 self._scopes
7115 .insert(Scope::CloudPlatform.as_ref().to_string());
7116 }
7117
7118 #[allow(clippy::single_element_loop)]
7119 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7120 url = params.uri_replacement(url, param_name, find_this, true);
7121 }
7122 {
7123 let to_remove = ["parent"];
7124 params.remove_params(&to_remove);
7125 }
7126
7127 let url = params.parse_with_url(&url);
7128
7129 let mut json_mime_type = mime::APPLICATION_JSON;
7130 let mut request_value_reader = {
7131 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7132 common::remove_json_null_values(&mut value);
7133 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7134 serde_json::to_writer(&mut dst, &value).unwrap();
7135 dst
7136 };
7137 let request_size = request_value_reader
7138 .seek(std::io::SeekFrom::End(0))
7139 .unwrap();
7140 request_value_reader
7141 .seek(std::io::SeekFrom::Start(0))
7142 .unwrap();
7143
7144 loop {
7145 let token = match self
7146 .hub
7147 .auth
7148 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7149 .await
7150 {
7151 Ok(token) => token,
7152 Err(e) => match dlg.token(e) {
7153 Ok(token) => token,
7154 Err(e) => {
7155 dlg.finished(false);
7156 return Err(common::Error::MissingToken(e));
7157 }
7158 },
7159 };
7160 request_value_reader
7161 .seek(std::io::SeekFrom::Start(0))
7162 .unwrap();
7163 let mut req_result = {
7164 let client = &self.hub.client;
7165 dlg.pre_request();
7166 let mut req_builder = hyper::Request::builder()
7167 .method(hyper::Method::POST)
7168 .uri(url.as_str())
7169 .header(USER_AGENT, self.hub._user_agent.clone());
7170
7171 if let Some(token) = token.as_ref() {
7172 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7173 }
7174
7175 let request = req_builder
7176 .header(CONTENT_TYPE, json_mime_type.to_string())
7177 .header(CONTENT_LENGTH, request_size as u64)
7178 .body(common::to_body(
7179 request_value_reader.get_ref().clone().into(),
7180 ));
7181
7182 client.request(request.unwrap()).await
7183 };
7184
7185 match req_result {
7186 Err(err) => {
7187 if let common::Retry::After(d) = dlg.http_error(&err) {
7188 sleep(d).await;
7189 continue;
7190 }
7191 dlg.finished(false);
7192 return Err(common::Error::HttpError(err));
7193 }
7194 Ok(res) => {
7195 let (mut parts, body) = res.into_parts();
7196 let mut body = common::Body::new(body);
7197 if !parts.status.is_success() {
7198 let bytes = common::to_bytes(body).await.unwrap_or_default();
7199 let error = serde_json::from_str(&common::to_string(&bytes));
7200 let response = common::to_response(parts, bytes.into());
7201
7202 if let common::Retry::After(d) =
7203 dlg.http_failure(&response, error.as_ref().ok())
7204 {
7205 sleep(d).await;
7206 continue;
7207 }
7208
7209 dlg.finished(false);
7210
7211 return Err(match error {
7212 Ok(value) => common::Error::BadRequest(value),
7213 _ => common::Error::Failure(response),
7214 });
7215 }
7216 let response = {
7217 let bytes = common::to_bytes(body).await.unwrap_or_default();
7218 let encoded = common::to_string(&bytes);
7219 match serde_json::from_str(&encoded) {
7220 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7221 Err(error) => {
7222 dlg.response_json_decode_error(&encoded, &error);
7223 return Err(common::Error::JsonDecodeError(
7224 encoded.to_string(),
7225 error,
7226 ));
7227 }
7228 }
7229 };
7230
7231 dlg.finished(true);
7232 return Ok(response);
7233 }
7234 }
7235 }
7236 }
7237
7238 ///
7239 /// Sets the *request* property to the given value.
7240 ///
7241 /// Even though the property as already been set when instantiating this call,
7242 /// we provide this method for API completeness.
7243 pub fn request(mut self, new_value: Topic) -> AdminProjectLocationTopicCreateCall<'a, C> {
7244 self._request = new_value;
7245 self
7246 }
7247 /// Required. The parent location in which to create the topic. Structured like `projects/{project_number}/locations/{location}`.
7248 ///
7249 /// Sets the *parent* path property to the given value.
7250 ///
7251 /// Even though the property as already been set when instantiating this call,
7252 /// we provide this method for API completeness.
7253 pub fn parent(mut self, new_value: &str) -> AdminProjectLocationTopicCreateCall<'a, C> {
7254 self._parent = new_value.to_string();
7255 self
7256 }
7257 /// Required. The ID to use for the topic, which will become the final component of the topic's name. This value is structured like: `my-topic-name`.
7258 ///
7259 /// Sets the *topic id* query property to the given value.
7260 pub fn topic_id(mut self, new_value: &str) -> AdminProjectLocationTopicCreateCall<'a, C> {
7261 self._topic_id = Some(new_value.to_string());
7262 self
7263 }
7264 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7265 /// while executing the actual API request.
7266 ///
7267 /// ````text
7268 /// It should be used to handle progress information, and to implement a certain level of resilience.
7269 /// ````
7270 ///
7271 /// Sets the *delegate* property to the given value.
7272 pub fn delegate(
7273 mut self,
7274 new_value: &'a mut dyn common::Delegate,
7275 ) -> AdminProjectLocationTopicCreateCall<'a, C> {
7276 self._delegate = Some(new_value);
7277 self
7278 }
7279
7280 /// Set any additional parameter of the query string used in the request.
7281 /// It should be used to set parameters which are not yet available through their own
7282 /// setters.
7283 ///
7284 /// Please note that this method must not be used to set any of the known parameters
7285 /// which have their own setter method. If done anyway, the request will fail.
7286 ///
7287 /// # Additional Parameters
7288 ///
7289 /// * *$.xgafv* (query-string) - V1 error format.
7290 /// * *access_token* (query-string) - OAuth access token.
7291 /// * *alt* (query-string) - Data format for response.
7292 /// * *callback* (query-string) - JSONP
7293 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7294 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7295 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7296 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7297 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7298 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7299 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7300 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicCreateCall<'a, C>
7301 where
7302 T: AsRef<str>,
7303 {
7304 self._additional_params
7305 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7306 self
7307 }
7308
7309 /// Identifies the authorization scope for the method you are building.
7310 ///
7311 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7312 /// [`Scope::CloudPlatform`].
7313 ///
7314 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7315 /// tokens for more than one scope.
7316 ///
7317 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7318 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7319 /// sufficient, a read-write scope will do as well.
7320 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicCreateCall<'a, C>
7321 where
7322 St: AsRef<str>,
7323 {
7324 self._scopes.insert(String::from(scope.as_ref()));
7325 self
7326 }
7327 /// Identifies the authorization scope(s) for the method you are building.
7328 ///
7329 /// See [`Self::add_scope()`] for details.
7330 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicCreateCall<'a, C>
7331 where
7332 I: IntoIterator<Item = St>,
7333 St: AsRef<str>,
7334 {
7335 self._scopes
7336 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7337 self
7338 }
7339
7340 /// Removes all scopes, and no default scope will be used either.
7341 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7342 /// for details).
7343 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicCreateCall<'a, C> {
7344 self._scopes.clear();
7345 self
7346 }
7347}
7348
7349/// Deletes the specified topic.
7350///
7351/// A builder for the *projects.locations.topics.delete* method supported by a *admin* resource.
7352/// It is not used directly, but through a [`AdminMethods`] instance.
7353///
7354/// # Example
7355///
7356/// Instantiate a resource method builder
7357///
7358/// ```test_harness,no_run
7359/// # extern crate hyper;
7360/// # extern crate hyper_rustls;
7361/// # extern crate google_pubsublite1 as pubsublite1;
7362/// # async fn dox() {
7363/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7364///
7365/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7366/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7367/// # secret,
7368/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7369/// # ).build().await.unwrap();
7370///
7371/// # let client = hyper_util::client::legacy::Client::builder(
7372/// # hyper_util::rt::TokioExecutor::new()
7373/// # )
7374/// # .build(
7375/// # hyper_rustls::HttpsConnectorBuilder::new()
7376/// # .with_native_roots()
7377/// # .unwrap()
7378/// # .https_or_http()
7379/// # .enable_http1()
7380/// # .build()
7381/// # );
7382/// # let mut hub = PubsubLite::new(client, auth);
7383/// // You can configure optional parameters by calling the respective setters at will, and
7384/// // execute the final call using `doit()`.
7385/// // Values shown here are possibly random and not representative !
7386/// let result = hub.admin().projects_locations_topics_delete("name")
7387/// .doit().await;
7388/// # }
7389/// ```
7390pub struct AdminProjectLocationTopicDeleteCall<'a, C>
7391where
7392 C: 'a,
7393{
7394 hub: &'a PubsubLite<C>,
7395 _name: String,
7396 _delegate: Option<&'a mut dyn common::Delegate>,
7397 _additional_params: HashMap<String, String>,
7398 _scopes: BTreeSet<String>,
7399}
7400
7401impl<'a, C> common::CallBuilder for AdminProjectLocationTopicDeleteCall<'a, C> {}
7402
7403impl<'a, C> AdminProjectLocationTopicDeleteCall<'a, C>
7404where
7405 C: common::Connector,
7406{
7407 /// Perform the operation you have build so far.
7408 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7409 use std::borrow::Cow;
7410 use std::io::{Read, Seek};
7411
7412 use common::{url::Params, ToParts};
7413 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7414
7415 let mut dd = common::DefaultDelegate;
7416 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7417 dlg.begin(common::MethodInfo {
7418 id: "pubsublite.admin.projects.locations.topics.delete",
7419 http_method: hyper::Method::DELETE,
7420 });
7421
7422 for &field in ["alt", "name"].iter() {
7423 if self._additional_params.contains_key(field) {
7424 dlg.finished(false);
7425 return Err(common::Error::FieldClash(field));
7426 }
7427 }
7428
7429 let mut params = Params::with_capacity(3 + self._additional_params.len());
7430 params.push("name", self._name);
7431
7432 params.extend(self._additional_params.iter());
7433
7434 params.push("alt", "json");
7435 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
7436 if self._scopes.is_empty() {
7437 self._scopes
7438 .insert(Scope::CloudPlatform.as_ref().to_string());
7439 }
7440
7441 #[allow(clippy::single_element_loop)]
7442 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7443 url = params.uri_replacement(url, param_name, find_this, true);
7444 }
7445 {
7446 let to_remove = ["name"];
7447 params.remove_params(&to_remove);
7448 }
7449
7450 let url = params.parse_with_url(&url);
7451
7452 loop {
7453 let token = match self
7454 .hub
7455 .auth
7456 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7457 .await
7458 {
7459 Ok(token) => token,
7460 Err(e) => match dlg.token(e) {
7461 Ok(token) => token,
7462 Err(e) => {
7463 dlg.finished(false);
7464 return Err(common::Error::MissingToken(e));
7465 }
7466 },
7467 };
7468 let mut req_result = {
7469 let client = &self.hub.client;
7470 dlg.pre_request();
7471 let mut req_builder = hyper::Request::builder()
7472 .method(hyper::Method::DELETE)
7473 .uri(url.as_str())
7474 .header(USER_AGENT, self.hub._user_agent.clone());
7475
7476 if let Some(token) = token.as_ref() {
7477 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7478 }
7479
7480 let request = req_builder
7481 .header(CONTENT_LENGTH, 0_u64)
7482 .body(common::to_body::<String>(None));
7483
7484 client.request(request.unwrap()).await
7485 };
7486
7487 match req_result {
7488 Err(err) => {
7489 if let common::Retry::After(d) = dlg.http_error(&err) {
7490 sleep(d).await;
7491 continue;
7492 }
7493 dlg.finished(false);
7494 return Err(common::Error::HttpError(err));
7495 }
7496 Ok(res) => {
7497 let (mut parts, body) = res.into_parts();
7498 let mut body = common::Body::new(body);
7499 if !parts.status.is_success() {
7500 let bytes = common::to_bytes(body).await.unwrap_or_default();
7501 let error = serde_json::from_str(&common::to_string(&bytes));
7502 let response = common::to_response(parts, bytes.into());
7503
7504 if let common::Retry::After(d) =
7505 dlg.http_failure(&response, error.as_ref().ok())
7506 {
7507 sleep(d).await;
7508 continue;
7509 }
7510
7511 dlg.finished(false);
7512
7513 return Err(match error {
7514 Ok(value) => common::Error::BadRequest(value),
7515 _ => common::Error::Failure(response),
7516 });
7517 }
7518 let response = {
7519 let bytes = common::to_bytes(body).await.unwrap_or_default();
7520 let encoded = common::to_string(&bytes);
7521 match serde_json::from_str(&encoded) {
7522 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7523 Err(error) => {
7524 dlg.response_json_decode_error(&encoded, &error);
7525 return Err(common::Error::JsonDecodeError(
7526 encoded.to_string(),
7527 error,
7528 ));
7529 }
7530 }
7531 };
7532
7533 dlg.finished(true);
7534 return Ok(response);
7535 }
7536 }
7537 }
7538 }
7539
7540 /// Required. The name of the topic to delete.
7541 ///
7542 /// Sets the *name* path property to the given value.
7543 ///
7544 /// Even though the property as already been set when instantiating this call,
7545 /// we provide this method for API completeness.
7546 pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicDeleteCall<'a, C> {
7547 self._name = new_value.to_string();
7548 self
7549 }
7550 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7551 /// while executing the actual API request.
7552 ///
7553 /// ````text
7554 /// It should be used to handle progress information, and to implement a certain level of resilience.
7555 /// ````
7556 ///
7557 /// Sets the *delegate* property to the given value.
7558 pub fn delegate(
7559 mut self,
7560 new_value: &'a mut dyn common::Delegate,
7561 ) -> AdminProjectLocationTopicDeleteCall<'a, C> {
7562 self._delegate = Some(new_value);
7563 self
7564 }
7565
7566 /// Set any additional parameter of the query string used in the request.
7567 /// It should be used to set parameters which are not yet available through their own
7568 /// setters.
7569 ///
7570 /// Please note that this method must not be used to set any of the known parameters
7571 /// which have their own setter method. If done anyway, the request will fail.
7572 ///
7573 /// # Additional Parameters
7574 ///
7575 /// * *$.xgafv* (query-string) - V1 error format.
7576 /// * *access_token* (query-string) - OAuth access token.
7577 /// * *alt* (query-string) - Data format for response.
7578 /// * *callback* (query-string) - JSONP
7579 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7580 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7581 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7582 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7583 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7584 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7585 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7586 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicDeleteCall<'a, C>
7587 where
7588 T: AsRef<str>,
7589 {
7590 self._additional_params
7591 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7592 self
7593 }
7594
7595 /// Identifies the authorization scope for the method you are building.
7596 ///
7597 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7598 /// [`Scope::CloudPlatform`].
7599 ///
7600 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7601 /// tokens for more than one scope.
7602 ///
7603 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7604 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7605 /// sufficient, a read-write scope will do as well.
7606 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicDeleteCall<'a, C>
7607 where
7608 St: AsRef<str>,
7609 {
7610 self._scopes.insert(String::from(scope.as_ref()));
7611 self
7612 }
7613 /// Identifies the authorization scope(s) for the method you are building.
7614 ///
7615 /// See [`Self::add_scope()`] for details.
7616 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicDeleteCall<'a, C>
7617 where
7618 I: IntoIterator<Item = St>,
7619 St: AsRef<str>,
7620 {
7621 self._scopes
7622 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7623 self
7624 }
7625
7626 /// Removes all scopes, and no default scope will be used either.
7627 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7628 /// for details).
7629 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicDeleteCall<'a, C> {
7630 self._scopes.clear();
7631 self
7632 }
7633}
7634
7635/// Returns the topic configuration.
7636///
7637/// A builder for the *projects.locations.topics.get* method supported by a *admin* resource.
7638/// It is not used directly, but through a [`AdminMethods`] instance.
7639///
7640/// # Example
7641///
7642/// Instantiate a resource method builder
7643///
7644/// ```test_harness,no_run
7645/// # extern crate hyper;
7646/// # extern crate hyper_rustls;
7647/// # extern crate google_pubsublite1 as pubsublite1;
7648/// # async fn dox() {
7649/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7650///
7651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7652/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7653/// # secret,
7654/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7655/// # ).build().await.unwrap();
7656///
7657/// # let client = hyper_util::client::legacy::Client::builder(
7658/// # hyper_util::rt::TokioExecutor::new()
7659/// # )
7660/// # .build(
7661/// # hyper_rustls::HttpsConnectorBuilder::new()
7662/// # .with_native_roots()
7663/// # .unwrap()
7664/// # .https_or_http()
7665/// # .enable_http1()
7666/// # .build()
7667/// # );
7668/// # let mut hub = PubsubLite::new(client, auth);
7669/// // You can configure optional parameters by calling the respective setters at will, and
7670/// // execute the final call using `doit()`.
7671/// // Values shown here are possibly random and not representative !
7672/// let result = hub.admin().projects_locations_topics_get("name")
7673/// .doit().await;
7674/// # }
7675/// ```
7676pub struct AdminProjectLocationTopicGetCall<'a, C>
7677where
7678 C: 'a,
7679{
7680 hub: &'a PubsubLite<C>,
7681 _name: String,
7682 _delegate: Option<&'a mut dyn common::Delegate>,
7683 _additional_params: HashMap<String, String>,
7684 _scopes: BTreeSet<String>,
7685}
7686
7687impl<'a, C> common::CallBuilder for AdminProjectLocationTopicGetCall<'a, C> {}
7688
7689impl<'a, C> AdminProjectLocationTopicGetCall<'a, C>
7690where
7691 C: common::Connector,
7692{
7693 /// Perform the operation you have build so far.
7694 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
7695 use std::borrow::Cow;
7696 use std::io::{Read, Seek};
7697
7698 use common::{url::Params, ToParts};
7699 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7700
7701 let mut dd = common::DefaultDelegate;
7702 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7703 dlg.begin(common::MethodInfo {
7704 id: "pubsublite.admin.projects.locations.topics.get",
7705 http_method: hyper::Method::GET,
7706 });
7707
7708 for &field in ["alt", "name"].iter() {
7709 if self._additional_params.contains_key(field) {
7710 dlg.finished(false);
7711 return Err(common::Error::FieldClash(field));
7712 }
7713 }
7714
7715 let mut params = Params::with_capacity(3 + self._additional_params.len());
7716 params.push("name", self._name);
7717
7718 params.extend(self._additional_params.iter());
7719
7720 params.push("alt", "json");
7721 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
7722 if self._scopes.is_empty() {
7723 self._scopes
7724 .insert(Scope::CloudPlatform.as_ref().to_string());
7725 }
7726
7727 #[allow(clippy::single_element_loop)]
7728 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7729 url = params.uri_replacement(url, param_name, find_this, true);
7730 }
7731 {
7732 let to_remove = ["name"];
7733 params.remove_params(&to_remove);
7734 }
7735
7736 let url = params.parse_with_url(&url);
7737
7738 loop {
7739 let token = match self
7740 .hub
7741 .auth
7742 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7743 .await
7744 {
7745 Ok(token) => token,
7746 Err(e) => match dlg.token(e) {
7747 Ok(token) => token,
7748 Err(e) => {
7749 dlg.finished(false);
7750 return Err(common::Error::MissingToken(e));
7751 }
7752 },
7753 };
7754 let mut req_result = {
7755 let client = &self.hub.client;
7756 dlg.pre_request();
7757 let mut req_builder = hyper::Request::builder()
7758 .method(hyper::Method::GET)
7759 .uri(url.as_str())
7760 .header(USER_AGENT, self.hub._user_agent.clone());
7761
7762 if let Some(token) = token.as_ref() {
7763 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7764 }
7765
7766 let request = req_builder
7767 .header(CONTENT_LENGTH, 0_u64)
7768 .body(common::to_body::<String>(None));
7769
7770 client.request(request.unwrap()).await
7771 };
7772
7773 match req_result {
7774 Err(err) => {
7775 if let common::Retry::After(d) = dlg.http_error(&err) {
7776 sleep(d).await;
7777 continue;
7778 }
7779 dlg.finished(false);
7780 return Err(common::Error::HttpError(err));
7781 }
7782 Ok(res) => {
7783 let (mut parts, body) = res.into_parts();
7784 let mut body = common::Body::new(body);
7785 if !parts.status.is_success() {
7786 let bytes = common::to_bytes(body).await.unwrap_or_default();
7787 let error = serde_json::from_str(&common::to_string(&bytes));
7788 let response = common::to_response(parts, bytes.into());
7789
7790 if let common::Retry::After(d) =
7791 dlg.http_failure(&response, error.as_ref().ok())
7792 {
7793 sleep(d).await;
7794 continue;
7795 }
7796
7797 dlg.finished(false);
7798
7799 return Err(match error {
7800 Ok(value) => common::Error::BadRequest(value),
7801 _ => common::Error::Failure(response),
7802 });
7803 }
7804 let response = {
7805 let bytes = common::to_bytes(body).await.unwrap_or_default();
7806 let encoded = common::to_string(&bytes);
7807 match serde_json::from_str(&encoded) {
7808 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7809 Err(error) => {
7810 dlg.response_json_decode_error(&encoded, &error);
7811 return Err(common::Error::JsonDecodeError(
7812 encoded.to_string(),
7813 error,
7814 ));
7815 }
7816 }
7817 };
7818
7819 dlg.finished(true);
7820 return Ok(response);
7821 }
7822 }
7823 }
7824 }
7825
7826 /// Required. The name of the topic whose configuration to return.
7827 ///
7828 /// Sets the *name* path property to the given value.
7829 ///
7830 /// Even though the property as already been set when instantiating this call,
7831 /// we provide this method for API completeness.
7832 pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicGetCall<'a, C> {
7833 self._name = new_value.to_string();
7834 self
7835 }
7836 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7837 /// while executing the actual API request.
7838 ///
7839 /// ````text
7840 /// It should be used to handle progress information, and to implement a certain level of resilience.
7841 /// ````
7842 ///
7843 /// Sets the *delegate* property to the given value.
7844 pub fn delegate(
7845 mut self,
7846 new_value: &'a mut dyn common::Delegate,
7847 ) -> AdminProjectLocationTopicGetCall<'a, C> {
7848 self._delegate = Some(new_value);
7849 self
7850 }
7851
7852 /// Set any additional parameter of the query string used in the request.
7853 /// It should be used to set parameters which are not yet available through their own
7854 /// setters.
7855 ///
7856 /// Please note that this method must not be used to set any of the known parameters
7857 /// which have their own setter method. If done anyway, the request will fail.
7858 ///
7859 /// # Additional Parameters
7860 ///
7861 /// * *$.xgafv* (query-string) - V1 error format.
7862 /// * *access_token* (query-string) - OAuth access token.
7863 /// * *alt* (query-string) - Data format for response.
7864 /// * *callback* (query-string) - JSONP
7865 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7866 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7867 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7868 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7869 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7870 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7871 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7872 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicGetCall<'a, C>
7873 where
7874 T: AsRef<str>,
7875 {
7876 self._additional_params
7877 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7878 self
7879 }
7880
7881 /// Identifies the authorization scope for the method you are building.
7882 ///
7883 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7884 /// [`Scope::CloudPlatform`].
7885 ///
7886 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7887 /// tokens for more than one scope.
7888 ///
7889 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7890 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7891 /// sufficient, a read-write scope will do as well.
7892 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicGetCall<'a, C>
7893 where
7894 St: AsRef<str>,
7895 {
7896 self._scopes.insert(String::from(scope.as_ref()));
7897 self
7898 }
7899 /// Identifies the authorization scope(s) for the method you are building.
7900 ///
7901 /// See [`Self::add_scope()`] for details.
7902 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicGetCall<'a, C>
7903 where
7904 I: IntoIterator<Item = St>,
7905 St: AsRef<str>,
7906 {
7907 self._scopes
7908 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7909 self
7910 }
7911
7912 /// Removes all scopes, and no default scope will be used either.
7913 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7914 /// for details).
7915 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicGetCall<'a, C> {
7916 self._scopes.clear();
7917 self
7918 }
7919}
7920
7921/// Returns the partition information for the requested topic.
7922///
7923/// A builder for the *projects.locations.topics.getPartitions* method supported by a *admin* resource.
7924/// It is not used directly, but through a [`AdminMethods`] instance.
7925///
7926/// # Example
7927///
7928/// Instantiate a resource method builder
7929///
7930/// ```test_harness,no_run
7931/// # extern crate hyper;
7932/// # extern crate hyper_rustls;
7933/// # extern crate google_pubsublite1 as pubsublite1;
7934/// # async fn dox() {
7935/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7936///
7937/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7938/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7939/// # secret,
7940/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7941/// # ).build().await.unwrap();
7942///
7943/// # let client = hyper_util::client::legacy::Client::builder(
7944/// # hyper_util::rt::TokioExecutor::new()
7945/// # )
7946/// # .build(
7947/// # hyper_rustls::HttpsConnectorBuilder::new()
7948/// # .with_native_roots()
7949/// # .unwrap()
7950/// # .https_or_http()
7951/// # .enable_http1()
7952/// # .build()
7953/// # );
7954/// # let mut hub = PubsubLite::new(client, auth);
7955/// // You can configure optional parameters by calling the respective setters at will, and
7956/// // execute the final call using `doit()`.
7957/// // Values shown here are possibly random and not representative !
7958/// let result = hub.admin().projects_locations_topics_get_partitions("name")
7959/// .doit().await;
7960/// # }
7961/// ```
7962pub struct AdminProjectLocationTopicGetPartitionCall<'a, C>
7963where
7964 C: 'a,
7965{
7966 hub: &'a PubsubLite<C>,
7967 _name: String,
7968 _delegate: Option<&'a mut dyn common::Delegate>,
7969 _additional_params: HashMap<String, String>,
7970 _scopes: BTreeSet<String>,
7971}
7972
7973impl<'a, C> common::CallBuilder for AdminProjectLocationTopicGetPartitionCall<'a, C> {}
7974
7975impl<'a, C> AdminProjectLocationTopicGetPartitionCall<'a, C>
7976where
7977 C: common::Connector,
7978{
7979 /// Perform the operation you have build so far.
7980 pub async fn doit(mut self) -> common::Result<(common::Response, TopicPartitions)> {
7981 use std::borrow::Cow;
7982 use std::io::{Read, Seek};
7983
7984 use common::{url::Params, ToParts};
7985 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7986
7987 let mut dd = common::DefaultDelegate;
7988 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7989 dlg.begin(common::MethodInfo {
7990 id: "pubsublite.admin.projects.locations.topics.getPartitions",
7991 http_method: hyper::Method::GET,
7992 });
7993
7994 for &field in ["alt", "name"].iter() {
7995 if self._additional_params.contains_key(field) {
7996 dlg.finished(false);
7997 return Err(common::Error::FieldClash(field));
7998 }
7999 }
8000
8001 let mut params = Params::with_capacity(3 + self._additional_params.len());
8002 params.push("name", self._name);
8003
8004 params.extend(self._additional_params.iter());
8005
8006 params.push("alt", "json");
8007 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/partitions";
8008 if self._scopes.is_empty() {
8009 self._scopes
8010 .insert(Scope::CloudPlatform.as_ref().to_string());
8011 }
8012
8013 #[allow(clippy::single_element_loop)]
8014 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8015 url = params.uri_replacement(url, param_name, find_this, true);
8016 }
8017 {
8018 let to_remove = ["name"];
8019 params.remove_params(&to_remove);
8020 }
8021
8022 let url = params.parse_with_url(&url);
8023
8024 loop {
8025 let token = match self
8026 .hub
8027 .auth
8028 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8029 .await
8030 {
8031 Ok(token) => token,
8032 Err(e) => match dlg.token(e) {
8033 Ok(token) => token,
8034 Err(e) => {
8035 dlg.finished(false);
8036 return Err(common::Error::MissingToken(e));
8037 }
8038 },
8039 };
8040 let mut req_result = {
8041 let client = &self.hub.client;
8042 dlg.pre_request();
8043 let mut req_builder = hyper::Request::builder()
8044 .method(hyper::Method::GET)
8045 .uri(url.as_str())
8046 .header(USER_AGENT, self.hub._user_agent.clone());
8047
8048 if let Some(token) = token.as_ref() {
8049 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8050 }
8051
8052 let request = req_builder
8053 .header(CONTENT_LENGTH, 0_u64)
8054 .body(common::to_body::<String>(None));
8055
8056 client.request(request.unwrap()).await
8057 };
8058
8059 match req_result {
8060 Err(err) => {
8061 if let common::Retry::After(d) = dlg.http_error(&err) {
8062 sleep(d).await;
8063 continue;
8064 }
8065 dlg.finished(false);
8066 return Err(common::Error::HttpError(err));
8067 }
8068 Ok(res) => {
8069 let (mut parts, body) = res.into_parts();
8070 let mut body = common::Body::new(body);
8071 if !parts.status.is_success() {
8072 let bytes = common::to_bytes(body).await.unwrap_or_default();
8073 let error = serde_json::from_str(&common::to_string(&bytes));
8074 let response = common::to_response(parts, bytes.into());
8075
8076 if let common::Retry::After(d) =
8077 dlg.http_failure(&response, error.as_ref().ok())
8078 {
8079 sleep(d).await;
8080 continue;
8081 }
8082
8083 dlg.finished(false);
8084
8085 return Err(match error {
8086 Ok(value) => common::Error::BadRequest(value),
8087 _ => common::Error::Failure(response),
8088 });
8089 }
8090 let response = {
8091 let bytes = common::to_bytes(body).await.unwrap_or_default();
8092 let encoded = common::to_string(&bytes);
8093 match serde_json::from_str(&encoded) {
8094 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8095 Err(error) => {
8096 dlg.response_json_decode_error(&encoded, &error);
8097 return Err(common::Error::JsonDecodeError(
8098 encoded.to_string(),
8099 error,
8100 ));
8101 }
8102 }
8103 };
8104
8105 dlg.finished(true);
8106 return Ok(response);
8107 }
8108 }
8109 }
8110 }
8111
8112 /// Required. The topic whose partition information to return.
8113 ///
8114 /// Sets the *name* path property to the given value.
8115 ///
8116 /// Even though the property as already been set when instantiating this call,
8117 /// we provide this method for API completeness.
8118 pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
8119 self._name = new_value.to_string();
8120 self
8121 }
8122 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8123 /// while executing the actual API request.
8124 ///
8125 /// ````text
8126 /// It should be used to handle progress information, and to implement a certain level of resilience.
8127 /// ````
8128 ///
8129 /// Sets the *delegate* property to the given value.
8130 pub fn delegate(
8131 mut self,
8132 new_value: &'a mut dyn common::Delegate,
8133 ) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
8134 self._delegate = Some(new_value);
8135 self
8136 }
8137
8138 /// Set any additional parameter of the query string used in the request.
8139 /// It should be used to set parameters which are not yet available through their own
8140 /// setters.
8141 ///
8142 /// Please note that this method must not be used to set any of the known parameters
8143 /// which have their own setter method. If done anyway, the request will fail.
8144 ///
8145 /// # Additional Parameters
8146 ///
8147 /// * *$.xgafv* (query-string) - V1 error format.
8148 /// * *access_token* (query-string) - OAuth access token.
8149 /// * *alt* (query-string) - Data format for response.
8150 /// * *callback* (query-string) - JSONP
8151 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8152 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8153 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8154 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8155 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8156 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8157 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8158 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicGetPartitionCall<'a, C>
8159 where
8160 T: AsRef<str>,
8161 {
8162 self._additional_params
8163 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8164 self
8165 }
8166
8167 /// Identifies the authorization scope for the method you are building.
8168 ///
8169 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8170 /// [`Scope::CloudPlatform`].
8171 ///
8172 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8173 /// tokens for more than one scope.
8174 ///
8175 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8176 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8177 /// sufficient, a read-write scope will do as well.
8178 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicGetPartitionCall<'a, C>
8179 where
8180 St: AsRef<str>,
8181 {
8182 self._scopes.insert(String::from(scope.as_ref()));
8183 self
8184 }
8185 /// Identifies the authorization scope(s) for the method you are building.
8186 ///
8187 /// See [`Self::add_scope()`] for details.
8188 pub fn add_scopes<I, St>(
8189 mut self,
8190 scopes: I,
8191 ) -> AdminProjectLocationTopicGetPartitionCall<'a, C>
8192 where
8193 I: IntoIterator<Item = St>,
8194 St: AsRef<str>,
8195 {
8196 self._scopes
8197 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8198 self
8199 }
8200
8201 /// Removes all scopes, and no default scope will be used either.
8202 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8203 /// for details).
8204 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
8205 self._scopes.clear();
8206 self
8207 }
8208}
8209
8210/// Returns the list of topics for the given project.
8211///
8212/// A builder for the *projects.locations.topics.list* method supported by a *admin* resource.
8213/// It is not used directly, but through a [`AdminMethods`] instance.
8214///
8215/// # Example
8216///
8217/// Instantiate a resource method builder
8218///
8219/// ```test_harness,no_run
8220/// # extern crate hyper;
8221/// # extern crate hyper_rustls;
8222/// # extern crate google_pubsublite1 as pubsublite1;
8223/// # async fn dox() {
8224/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8225///
8226/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8227/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8228/// # secret,
8229/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8230/// # ).build().await.unwrap();
8231///
8232/// # let client = hyper_util::client::legacy::Client::builder(
8233/// # hyper_util::rt::TokioExecutor::new()
8234/// # )
8235/// # .build(
8236/// # hyper_rustls::HttpsConnectorBuilder::new()
8237/// # .with_native_roots()
8238/// # .unwrap()
8239/// # .https_or_http()
8240/// # .enable_http1()
8241/// # .build()
8242/// # );
8243/// # let mut hub = PubsubLite::new(client, auth);
8244/// // You can configure optional parameters by calling the respective setters at will, and
8245/// // execute the final call using `doit()`.
8246/// // Values shown here are possibly random and not representative !
8247/// let result = hub.admin().projects_locations_topics_list("parent")
8248/// .page_token("sed")
8249/// .page_size(-61)
8250/// .doit().await;
8251/// # }
8252/// ```
8253pub struct AdminProjectLocationTopicListCall<'a, C>
8254where
8255 C: 'a,
8256{
8257 hub: &'a PubsubLite<C>,
8258 _parent: String,
8259 _page_token: Option<String>,
8260 _page_size: Option<i32>,
8261 _delegate: Option<&'a mut dyn common::Delegate>,
8262 _additional_params: HashMap<String, String>,
8263 _scopes: BTreeSet<String>,
8264}
8265
8266impl<'a, C> common::CallBuilder for AdminProjectLocationTopicListCall<'a, C> {}
8267
8268impl<'a, C> AdminProjectLocationTopicListCall<'a, C>
8269where
8270 C: common::Connector,
8271{
8272 /// Perform the operation you have build so far.
8273 pub async fn doit(mut self) -> common::Result<(common::Response, ListTopicsResponse)> {
8274 use std::borrow::Cow;
8275 use std::io::{Read, Seek};
8276
8277 use common::{url::Params, ToParts};
8278 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8279
8280 let mut dd = common::DefaultDelegate;
8281 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8282 dlg.begin(common::MethodInfo {
8283 id: "pubsublite.admin.projects.locations.topics.list",
8284 http_method: hyper::Method::GET,
8285 });
8286
8287 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8288 if self._additional_params.contains_key(field) {
8289 dlg.finished(false);
8290 return Err(common::Error::FieldClash(field));
8291 }
8292 }
8293
8294 let mut params = Params::with_capacity(5 + self._additional_params.len());
8295 params.push("parent", self._parent);
8296 if let Some(value) = self._page_token.as_ref() {
8297 params.push("pageToken", value);
8298 }
8299 if let Some(value) = self._page_size.as_ref() {
8300 params.push("pageSize", value.to_string());
8301 }
8302
8303 params.extend(self._additional_params.iter());
8304
8305 params.push("alt", "json");
8306 let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/topics";
8307 if self._scopes.is_empty() {
8308 self._scopes
8309 .insert(Scope::CloudPlatform.as_ref().to_string());
8310 }
8311
8312 #[allow(clippy::single_element_loop)]
8313 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8314 url = params.uri_replacement(url, param_name, find_this, true);
8315 }
8316 {
8317 let to_remove = ["parent"];
8318 params.remove_params(&to_remove);
8319 }
8320
8321 let url = params.parse_with_url(&url);
8322
8323 loop {
8324 let token = match self
8325 .hub
8326 .auth
8327 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8328 .await
8329 {
8330 Ok(token) => token,
8331 Err(e) => match dlg.token(e) {
8332 Ok(token) => token,
8333 Err(e) => {
8334 dlg.finished(false);
8335 return Err(common::Error::MissingToken(e));
8336 }
8337 },
8338 };
8339 let mut req_result = {
8340 let client = &self.hub.client;
8341 dlg.pre_request();
8342 let mut req_builder = hyper::Request::builder()
8343 .method(hyper::Method::GET)
8344 .uri(url.as_str())
8345 .header(USER_AGENT, self.hub._user_agent.clone());
8346
8347 if let Some(token) = token.as_ref() {
8348 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8349 }
8350
8351 let request = req_builder
8352 .header(CONTENT_LENGTH, 0_u64)
8353 .body(common::to_body::<String>(None));
8354
8355 client.request(request.unwrap()).await
8356 };
8357
8358 match req_result {
8359 Err(err) => {
8360 if let common::Retry::After(d) = dlg.http_error(&err) {
8361 sleep(d).await;
8362 continue;
8363 }
8364 dlg.finished(false);
8365 return Err(common::Error::HttpError(err));
8366 }
8367 Ok(res) => {
8368 let (mut parts, body) = res.into_parts();
8369 let mut body = common::Body::new(body);
8370 if !parts.status.is_success() {
8371 let bytes = common::to_bytes(body).await.unwrap_or_default();
8372 let error = serde_json::from_str(&common::to_string(&bytes));
8373 let response = common::to_response(parts, bytes.into());
8374
8375 if let common::Retry::After(d) =
8376 dlg.http_failure(&response, error.as_ref().ok())
8377 {
8378 sleep(d).await;
8379 continue;
8380 }
8381
8382 dlg.finished(false);
8383
8384 return Err(match error {
8385 Ok(value) => common::Error::BadRequest(value),
8386 _ => common::Error::Failure(response),
8387 });
8388 }
8389 let response = {
8390 let bytes = common::to_bytes(body).await.unwrap_or_default();
8391 let encoded = common::to_string(&bytes);
8392 match serde_json::from_str(&encoded) {
8393 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8394 Err(error) => {
8395 dlg.response_json_decode_error(&encoded, &error);
8396 return Err(common::Error::JsonDecodeError(
8397 encoded.to_string(),
8398 error,
8399 ));
8400 }
8401 }
8402 };
8403
8404 dlg.finished(true);
8405 return Ok(response);
8406 }
8407 }
8408 }
8409 }
8410
8411 /// Required. The parent whose topics are to be listed. Structured like `projects/{project_number}/locations/{location}`.
8412 ///
8413 /// Sets the *parent* path property to the given value.
8414 ///
8415 /// Even though the property as already been set when instantiating this call,
8416 /// we provide this method for API completeness.
8417 pub fn parent(mut self, new_value: &str) -> AdminProjectLocationTopicListCall<'a, C> {
8418 self._parent = new_value.to_string();
8419 self
8420 }
8421 /// A page token, received from a previous `ListTopics` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListTopics` must match the call that provided the page token.
8422 ///
8423 /// Sets the *page token* query property to the given value.
8424 pub fn page_token(mut self, new_value: &str) -> AdminProjectLocationTopicListCall<'a, C> {
8425 self._page_token = Some(new_value.to_string());
8426 self
8427 }
8428 /// The maximum number of topics to return. The service may return fewer than this value. If unset or zero, all topics for the parent will be returned.
8429 ///
8430 /// Sets the *page size* query property to the given value.
8431 pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationTopicListCall<'a, C> {
8432 self._page_size = Some(new_value);
8433 self
8434 }
8435 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8436 /// while executing the actual API request.
8437 ///
8438 /// ````text
8439 /// It should be used to handle progress information, and to implement a certain level of resilience.
8440 /// ````
8441 ///
8442 /// Sets the *delegate* property to the given value.
8443 pub fn delegate(
8444 mut self,
8445 new_value: &'a mut dyn common::Delegate,
8446 ) -> AdminProjectLocationTopicListCall<'a, C> {
8447 self._delegate = Some(new_value);
8448 self
8449 }
8450
8451 /// Set any additional parameter of the query string used in the request.
8452 /// It should be used to set parameters which are not yet available through their own
8453 /// setters.
8454 ///
8455 /// Please note that this method must not be used to set any of the known parameters
8456 /// which have their own setter method. If done anyway, the request will fail.
8457 ///
8458 /// # Additional Parameters
8459 ///
8460 /// * *$.xgafv* (query-string) - V1 error format.
8461 /// * *access_token* (query-string) - OAuth access token.
8462 /// * *alt* (query-string) - Data format for response.
8463 /// * *callback* (query-string) - JSONP
8464 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8465 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8466 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8467 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8468 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8469 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8470 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8471 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicListCall<'a, C>
8472 where
8473 T: AsRef<str>,
8474 {
8475 self._additional_params
8476 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8477 self
8478 }
8479
8480 /// Identifies the authorization scope for the method you are building.
8481 ///
8482 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8483 /// [`Scope::CloudPlatform`].
8484 ///
8485 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8486 /// tokens for more than one scope.
8487 ///
8488 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8489 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8490 /// sufficient, a read-write scope will do as well.
8491 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicListCall<'a, C>
8492 where
8493 St: AsRef<str>,
8494 {
8495 self._scopes.insert(String::from(scope.as_ref()));
8496 self
8497 }
8498 /// Identifies the authorization scope(s) for the method you are building.
8499 ///
8500 /// See [`Self::add_scope()`] for details.
8501 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicListCall<'a, C>
8502 where
8503 I: IntoIterator<Item = St>,
8504 St: AsRef<str>,
8505 {
8506 self._scopes
8507 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8508 self
8509 }
8510
8511 /// Removes all scopes, and no default scope will be used either.
8512 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8513 /// for details).
8514 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicListCall<'a, C> {
8515 self._scopes.clear();
8516 self
8517 }
8518}
8519
8520/// Updates properties of the specified topic.
8521///
8522/// A builder for the *projects.locations.topics.patch* method supported by a *admin* resource.
8523/// It is not used directly, but through a [`AdminMethods`] instance.
8524///
8525/// # Example
8526///
8527/// Instantiate a resource method builder
8528///
8529/// ```test_harness,no_run
8530/// # extern crate hyper;
8531/// # extern crate hyper_rustls;
8532/// # extern crate google_pubsublite1 as pubsublite1;
8533/// use pubsublite1::api::Topic;
8534/// # async fn dox() {
8535/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8536///
8537/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8538/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8539/// # secret,
8540/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8541/// # ).build().await.unwrap();
8542///
8543/// # let client = hyper_util::client::legacy::Client::builder(
8544/// # hyper_util::rt::TokioExecutor::new()
8545/// # )
8546/// # .build(
8547/// # hyper_rustls::HttpsConnectorBuilder::new()
8548/// # .with_native_roots()
8549/// # .unwrap()
8550/// # .https_or_http()
8551/// # .enable_http1()
8552/// # .build()
8553/// # );
8554/// # let mut hub = PubsubLite::new(client, auth);
8555/// // As the method needs a request, you would usually fill it with the desired information
8556/// // into the respective structure. Some of the parts shown here might not be applicable !
8557/// // Values shown here are possibly random and not representative !
8558/// let mut req = Topic::default();
8559///
8560/// // You can configure optional parameters by calling the respective setters at will, and
8561/// // execute the final call using `doit()`.
8562/// // Values shown here are possibly random and not representative !
8563/// let result = hub.admin().projects_locations_topics_patch(req, "name")
8564/// .update_mask(FieldMask::new::<&str>(&[]))
8565/// .doit().await;
8566/// # }
8567/// ```
8568pub struct AdminProjectLocationTopicPatchCall<'a, C>
8569where
8570 C: 'a,
8571{
8572 hub: &'a PubsubLite<C>,
8573 _request: Topic,
8574 _name: String,
8575 _update_mask: Option<common::FieldMask>,
8576 _delegate: Option<&'a mut dyn common::Delegate>,
8577 _additional_params: HashMap<String, String>,
8578 _scopes: BTreeSet<String>,
8579}
8580
8581impl<'a, C> common::CallBuilder for AdminProjectLocationTopicPatchCall<'a, C> {}
8582
8583impl<'a, C> AdminProjectLocationTopicPatchCall<'a, C>
8584where
8585 C: common::Connector,
8586{
8587 /// Perform the operation you have build so far.
8588 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
8589 use std::borrow::Cow;
8590 use std::io::{Read, Seek};
8591
8592 use common::{url::Params, ToParts};
8593 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8594
8595 let mut dd = common::DefaultDelegate;
8596 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8597 dlg.begin(common::MethodInfo {
8598 id: "pubsublite.admin.projects.locations.topics.patch",
8599 http_method: hyper::Method::PATCH,
8600 });
8601
8602 for &field in ["alt", "name", "updateMask"].iter() {
8603 if self._additional_params.contains_key(field) {
8604 dlg.finished(false);
8605 return Err(common::Error::FieldClash(field));
8606 }
8607 }
8608
8609 let mut params = Params::with_capacity(5 + self._additional_params.len());
8610 params.push("name", self._name);
8611 if let Some(value) = self._update_mask.as_ref() {
8612 params.push("updateMask", value.to_string());
8613 }
8614
8615 params.extend(self._additional_params.iter());
8616
8617 params.push("alt", "json");
8618 let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
8619 if self._scopes.is_empty() {
8620 self._scopes
8621 .insert(Scope::CloudPlatform.as_ref().to_string());
8622 }
8623
8624 #[allow(clippy::single_element_loop)]
8625 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8626 url = params.uri_replacement(url, param_name, find_this, true);
8627 }
8628 {
8629 let to_remove = ["name"];
8630 params.remove_params(&to_remove);
8631 }
8632
8633 let url = params.parse_with_url(&url);
8634
8635 let mut json_mime_type = mime::APPLICATION_JSON;
8636 let mut request_value_reader = {
8637 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8638 common::remove_json_null_values(&mut value);
8639 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8640 serde_json::to_writer(&mut dst, &value).unwrap();
8641 dst
8642 };
8643 let request_size = request_value_reader
8644 .seek(std::io::SeekFrom::End(0))
8645 .unwrap();
8646 request_value_reader
8647 .seek(std::io::SeekFrom::Start(0))
8648 .unwrap();
8649
8650 loop {
8651 let token = match self
8652 .hub
8653 .auth
8654 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8655 .await
8656 {
8657 Ok(token) => token,
8658 Err(e) => match dlg.token(e) {
8659 Ok(token) => token,
8660 Err(e) => {
8661 dlg.finished(false);
8662 return Err(common::Error::MissingToken(e));
8663 }
8664 },
8665 };
8666 request_value_reader
8667 .seek(std::io::SeekFrom::Start(0))
8668 .unwrap();
8669 let mut req_result = {
8670 let client = &self.hub.client;
8671 dlg.pre_request();
8672 let mut req_builder = hyper::Request::builder()
8673 .method(hyper::Method::PATCH)
8674 .uri(url.as_str())
8675 .header(USER_AGENT, self.hub._user_agent.clone());
8676
8677 if let Some(token) = token.as_ref() {
8678 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8679 }
8680
8681 let request = req_builder
8682 .header(CONTENT_TYPE, json_mime_type.to_string())
8683 .header(CONTENT_LENGTH, request_size as u64)
8684 .body(common::to_body(
8685 request_value_reader.get_ref().clone().into(),
8686 ));
8687
8688 client.request(request.unwrap()).await
8689 };
8690
8691 match req_result {
8692 Err(err) => {
8693 if let common::Retry::After(d) = dlg.http_error(&err) {
8694 sleep(d).await;
8695 continue;
8696 }
8697 dlg.finished(false);
8698 return Err(common::Error::HttpError(err));
8699 }
8700 Ok(res) => {
8701 let (mut parts, body) = res.into_parts();
8702 let mut body = common::Body::new(body);
8703 if !parts.status.is_success() {
8704 let bytes = common::to_bytes(body).await.unwrap_or_default();
8705 let error = serde_json::from_str(&common::to_string(&bytes));
8706 let response = common::to_response(parts, bytes.into());
8707
8708 if let common::Retry::After(d) =
8709 dlg.http_failure(&response, error.as_ref().ok())
8710 {
8711 sleep(d).await;
8712 continue;
8713 }
8714
8715 dlg.finished(false);
8716
8717 return Err(match error {
8718 Ok(value) => common::Error::BadRequest(value),
8719 _ => common::Error::Failure(response),
8720 });
8721 }
8722 let response = {
8723 let bytes = common::to_bytes(body).await.unwrap_or_default();
8724 let encoded = common::to_string(&bytes);
8725 match serde_json::from_str(&encoded) {
8726 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8727 Err(error) => {
8728 dlg.response_json_decode_error(&encoded, &error);
8729 return Err(common::Error::JsonDecodeError(
8730 encoded.to_string(),
8731 error,
8732 ));
8733 }
8734 }
8735 };
8736
8737 dlg.finished(true);
8738 return Ok(response);
8739 }
8740 }
8741 }
8742 }
8743
8744 ///
8745 /// Sets the *request* property to the given value.
8746 ///
8747 /// Even though the property as already been set when instantiating this call,
8748 /// we provide this method for API completeness.
8749 pub fn request(mut self, new_value: Topic) -> AdminProjectLocationTopicPatchCall<'a, C> {
8750 self._request = new_value;
8751 self
8752 }
8753 /// The name of the topic. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
8754 ///
8755 /// Sets the *name* path property to the given value.
8756 ///
8757 /// Even though the property as already been set when instantiating this call,
8758 /// we provide this method for API completeness.
8759 pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicPatchCall<'a, C> {
8760 self._name = new_value.to_string();
8761 self
8762 }
8763 /// Required. A mask specifying the topic fields to change.
8764 ///
8765 /// Sets the *update mask* query property to the given value.
8766 pub fn update_mask(
8767 mut self,
8768 new_value: common::FieldMask,
8769 ) -> AdminProjectLocationTopicPatchCall<'a, C> {
8770 self._update_mask = Some(new_value);
8771 self
8772 }
8773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8774 /// while executing the actual API request.
8775 ///
8776 /// ````text
8777 /// It should be used to handle progress information, and to implement a certain level of resilience.
8778 /// ````
8779 ///
8780 /// Sets the *delegate* property to the given value.
8781 pub fn delegate(
8782 mut self,
8783 new_value: &'a mut dyn common::Delegate,
8784 ) -> AdminProjectLocationTopicPatchCall<'a, C> {
8785 self._delegate = Some(new_value);
8786 self
8787 }
8788
8789 /// Set any additional parameter of the query string used in the request.
8790 /// It should be used to set parameters which are not yet available through their own
8791 /// setters.
8792 ///
8793 /// Please note that this method must not be used to set any of the known parameters
8794 /// which have their own setter method. If done anyway, the request will fail.
8795 ///
8796 /// # Additional Parameters
8797 ///
8798 /// * *$.xgafv* (query-string) - V1 error format.
8799 /// * *access_token* (query-string) - OAuth access token.
8800 /// * *alt* (query-string) - Data format for response.
8801 /// * *callback* (query-string) - JSONP
8802 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8803 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8804 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8805 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8806 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8807 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8808 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8809 pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicPatchCall<'a, C>
8810 where
8811 T: AsRef<str>,
8812 {
8813 self._additional_params
8814 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8815 self
8816 }
8817
8818 /// Identifies the authorization scope for the method you are building.
8819 ///
8820 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8821 /// [`Scope::CloudPlatform`].
8822 ///
8823 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8824 /// tokens for more than one scope.
8825 ///
8826 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8827 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8828 /// sufficient, a read-write scope will do as well.
8829 pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicPatchCall<'a, C>
8830 where
8831 St: AsRef<str>,
8832 {
8833 self._scopes.insert(String::from(scope.as_ref()));
8834 self
8835 }
8836 /// Identifies the authorization scope(s) for the method you are building.
8837 ///
8838 /// See [`Self::add_scope()`] for details.
8839 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicPatchCall<'a, C>
8840 where
8841 I: IntoIterator<Item = St>,
8842 St: AsRef<str>,
8843 {
8844 self._scopes
8845 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8846 self
8847 }
8848
8849 /// Removes all scopes, and no default scope will be used either.
8850 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8851 /// for details).
8852 pub fn clear_scopes(mut self) -> AdminProjectLocationTopicPatchCall<'a, C> {
8853 self._scopes.clear();
8854 self
8855 }
8856}
8857
8858/// Returns all committed cursor information for a subscription.
8859///
8860/// A builder for the *projects.locations.subscriptions.cursors.list* method supported by a *cursor* resource.
8861/// It is not used directly, but through a [`CursorMethods`] instance.
8862///
8863/// # Example
8864///
8865/// Instantiate a resource method builder
8866///
8867/// ```test_harness,no_run
8868/// # extern crate hyper;
8869/// # extern crate hyper_rustls;
8870/// # extern crate google_pubsublite1 as pubsublite1;
8871/// # async fn dox() {
8872/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8873///
8874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8875/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8876/// # secret,
8877/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8878/// # ).build().await.unwrap();
8879///
8880/// # let client = hyper_util::client::legacy::Client::builder(
8881/// # hyper_util::rt::TokioExecutor::new()
8882/// # )
8883/// # .build(
8884/// # hyper_rustls::HttpsConnectorBuilder::new()
8885/// # .with_native_roots()
8886/// # .unwrap()
8887/// # .https_or_http()
8888/// # .enable_http1()
8889/// # .build()
8890/// # );
8891/// # let mut hub = PubsubLite::new(client, auth);
8892/// // You can configure optional parameters by calling the respective setters at will, and
8893/// // execute the final call using `doit()`.
8894/// // Values shown here are possibly random and not representative !
8895/// let result = hub.cursor().projects_locations_subscriptions_cursors_list("parent")
8896/// .page_token("et")
8897/// .page_size(-43)
8898/// .doit().await;
8899/// # }
8900/// ```
8901pub struct CursorProjectLocationSubscriptionCursorListCall<'a, C>
8902where
8903 C: 'a,
8904{
8905 hub: &'a PubsubLite<C>,
8906 _parent: String,
8907 _page_token: Option<String>,
8908 _page_size: Option<i32>,
8909 _delegate: Option<&'a mut dyn common::Delegate>,
8910 _additional_params: HashMap<String, String>,
8911 _scopes: BTreeSet<String>,
8912}
8913
8914impl<'a, C> common::CallBuilder for CursorProjectLocationSubscriptionCursorListCall<'a, C> {}
8915
8916impl<'a, C> CursorProjectLocationSubscriptionCursorListCall<'a, C>
8917where
8918 C: common::Connector,
8919{
8920 /// Perform the operation you have build so far.
8921 pub async fn doit(
8922 mut self,
8923 ) -> common::Result<(common::Response, ListPartitionCursorsResponse)> {
8924 use std::borrow::Cow;
8925 use std::io::{Read, Seek};
8926
8927 use common::{url::Params, ToParts};
8928 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8929
8930 let mut dd = common::DefaultDelegate;
8931 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8932 dlg.begin(common::MethodInfo {
8933 id: "pubsublite.cursor.projects.locations.subscriptions.cursors.list",
8934 http_method: hyper::Method::GET,
8935 });
8936
8937 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8938 if self._additional_params.contains_key(field) {
8939 dlg.finished(false);
8940 return Err(common::Error::FieldClash(field));
8941 }
8942 }
8943
8944 let mut params = Params::with_capacity(5 + self._additional_params.len());
8945 params.push("parent", self._parent);
8946 if let Some(value) = self._page_token.as_ref() {
8947 params.push("pageToken", value);
8948 }
8949 if let Some(value) = self._page_size.as_ref() {
8950 params.push("pageSize", value.to_string());
8951 }
8952
8953 params.extend(self._additional_params.iter());
8954
8955 params.push("alt", "json");
8956 let mut url = self.hub._base_url.clone() + "v1/cursor/{+parent}/cursors";
8957 if self._scopes.is_empty() {
8958 self._scopes
8959 .insert(Scope::CloudPlatform.as_ref().to_string());
8960 }
8961
8962 #[allow(clippy::single_element_loop)]
8963 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8964 url = params.uri_replacement(url, param_name, find_this, true);
8965 }
8966 {
8967 let to_remove = ["parent"];
8968 params.remove_params(&to_remove);
8969 }
8970
8971 let url = params.parse_with_url(&url);
8972
8973 loop {
8974 let token = match self
8975 .hub
8976 .auth
8977 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8978 .await
8979 {
8980 Ok(token) => token,
8981 Err(e) => match dlg.token(e) {
8982 Ok(token) => token,
8983 Err(e) => {
8984 dlg.finished(false);
8985 return Err(common::Error::MissingToken(e));
8986 }
8987 },
8988 };
8989 let mut req_result = {
8990 let client = &self.hub.client;
8991 dlg.pre_request();
8992 let mut req_builder = hyper::Request::builder()
8993 .method(hyper::Method::GET)
8994 .uri(url.as_str())
8995 .header(USER_AGENT, self.hub._user_agent.clone());
8996
8997 if let Some(token) = token.as_ref() {
8998 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8999 }
9000
9001 let request = req_builder
9002 .header(CONTENT_LENGTH, 0_u64)
9003 .body(common::to_body::<String>(None));
9004
9005 client.request(request.unwrap()).await
9006 };
9007
9008 match req_result {
9009 Err(err) => {
9010 if let common::Retry::After(d) = dlg.http_error(&err) {
9011 sleep(d).await;
9012 continue;
9013 }
9014 dlg.finished(false);
9015 return Err(common::Error::HttpError(err));
9016 }
9017 Ok(res) => {
9018 let (mut parts, body) = res.into_parts();
9019 let mut body = common::Body::new(body);
9020 if !parts.status.is_success() {
9021 let bytes = common::to_bytes(body).await.unwrap_or_default();
9022 let error = serde_json::from_str(&common::to_string(&bytes));
9023 let response = common::to_response(parts, bytes.into());
9024
9025 if let common::Retry::After(d) =
9026 dlg.http_failure(&response, error.as_ref().ok())
9027 {
9028 sleep(d).await;
9029 continue;
9030 }
9031
9032 dlg.finished(false);
9033
9034 return Err(match error {
9035 Ok(value) => common::Error::BadRequest(value),
9036 _ => common::Error::Failure(response),
9037 });
9038 }
9039 let response = {
9040 let bytes = common::to_bytes(body).await.unwrap_or_default();
9041 let encoded = common::to_string(&bytes);
9042 match serde_json::from_str(&encoded) {
9043 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9044 Err(error) => {
9045 dlg.response_json_decode_error(&encoded, &error);
9046 return Err(common::Error::JsonDecodeError(
9047 encoded.to_string(),
9048 error,
9049 ));
9050 }
9051 }
9052 };
9053
9054 dlg.finished(true);
9055 return Ok(response);
9056 }
9057 }
9058 }
9059 }
9060
9061 /// Required. The subscription for which to retrieve cursors. Structured like `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
9062 ///
9063 /// Sets the *parent* path property to the given value.
9064 ///
9065 /// Even though the property as already been set when instantiating this call,
9066 /// we provide this method for API completeness.
9067 pub fn parent(
9068 mut self,
9069 new_value: &str,
9070 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9071 self._parent = new_value.to_string();
9072 self
9073 }
9074 /// A page token, received from a previous `ListPartitionCursors` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPartitionCursors` must match the call that provided the page token.
9075 ///
9076 /// Sets the *page token* query property to the given value.
9077 pub fn page_token(
9078 mut self,
9079 new_value: &str,
9080 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9081 self._page_token = Some(new_value.to_string());
9082 self
9083 }
9084 /// The maximum number of cursors to return. The service may return fewer than this value. If unset or zero, all cursors for the parent will be returned.
9085 ///
9086 /// Sets the *page size* query property to the given value.
9087 pub fn page_size(
9088 mut self,
9089 new_value: i32,
9090 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9091 self._page_size = Some(new_value);
9092 self
9093 }
9094 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9095 /// while executing the actual API request.
9096 ///
9097 /// ````text
9098 /// It should be used to handle progress information, and to implement a certain level of resilience.
9099 /// ````
9100 ///
9101 /// Sets the *delegate* property to the given value.
9102 pub fn delegate(
9103 mut self,
9104 new_value: &'a mut dyn common::Delegate,
9105 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9106 self._delegate = Some(new_value);
9107 self
9108 }
9109
9110 /// Set any additional parameter of the query string used in the request.
9111 /// It should be used to set parameters which are not yet available through their own
9112 /// setters.
9113 ///
9114 /// Please note that this method must not be used to set any of the known parameters
9115 /// which have their own setter method. If done anyway, the request will fail.
9116 ///
9117 /// # Additional Parameters
9118 ///
9119 /// * *$.xgafv* (query-string) - V1 error format.
9120 /// * *access_token* (query-string) - OAuth access token.
9121 /// * *alt* (query-string) - Data format for response.
9122 /// * *callback* (query-string) - JSONP
9123 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9124 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9125 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9126 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9127 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9128 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9129 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9130 pub fn param<T>(
9131 mut self,
9132 name: T,
9133 value: T,
9134 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9135 where
9136 T: AsRef<str>,
9137 {
9138 self._additional_params
9139 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9140 self
9141 }
9142
9143 /// Identifies the authorization scope for the method you are building.
9144 ///
9145 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9146 /// [`Scope::CloudPlatform`].
9147 ///
9148 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9149 /// tokens for more than one scope.
9150 ///
9151 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9152 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9153 /// sufficient, a read-write scope will do as well.
9154 pub fn add_scope<St>(
9155 mut self,
9156 scope: St,
9157 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9158 where
9159 St: AsRef<str>,
9160 {
9161 self._scopes.insert(String::from(scope.as_ref()));
9162 self
9163 }
9164 /// Identifies the authorization scope(s) for the method you are building.
9165 ///
9166 /// See [`Self::add_scope()`] for details.
9167 pub fn add_scopes<I, St>(
9168 mut self,
9169 scopes: I,
9170 ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9171 where
9172 I: IntoIterator<Item = St>,
9173 St: AsRef<str>,
9174 {
9175 self._scopes
9176 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9177 self
9178 }
9179
9180 /// Removes all scopes, and no default scope will be used either.
9181 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9182 /// for details).
9183 pub fn clear_scopes(mut self) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9184 self._scopes.clear();
9185 self
9186 }
9187}
9188
9189/// Updates the committed cursor.
9190///
9191/// A builder for the *projects.locations.subscriptions.commitCursor* method supported by a *cursor* resource.
9192/// It is not used directly, but through a [`CursorMethods`] instance.
9193///
9194/// # Example
9195///
9196/// Instantiate a resource method builder
9197///
9198/// ```test_harness,no_run
9199/// # extern crate hyper;
9200/// # extern crate hyper_rustls;
9201/// # extern crate google_pubsublite1 as pubsublite1;
9202/// use pubsublite1::api::CommitCursorRequest;
9203/// # async fn dox() {
9204/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9205///
9206/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9207/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9208/// # secret,
9209/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9210/// # ).build().await.unwrap();
9211///
9212/// # let client = hyper_util::client::legacy::Client::builder(
9213/// # hyper_util::rt::TokioExecutor::new()
9214/// # )
9215/// # .build(
9216/// # hyper_rustls::HttpsConnectorBuilder::new()
9217/// # .with_native_roots()
9218/// # .unwrap()
9219/// # .https_or_http()
9220/// # .enable_http1()
9221/// # .build()
9222/// # );
9223/// # let mut hub = PubsubLite::new(client, auth);
9224/// // As the method needs a request, you would usually fill it with the desired information
9225/// // into the respective structure. Some of the parts shown here might not be applicable !
9226/// // Values shown here are possibly random and not representative !
9227/// let mut req = CommitCursorRequest::default();
9228///
9229/// // You can configure optional parameters by calling the respective setters at will, and
9230/// // execute the final call using `doit()`.
9231/// // Values shown here are possibly random and not representative !
9232/// let result = hub.cursor().projects_locations_subscriptions_commit_cursor(req, "subscription")
9233/// .doit().await;
9234/// # }
9235/// ```
9236pub struct CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9237where
9238 C: 'a,
9239{
9240 hub: &'a PubsubLite<C>,
9241 _request: CommitCursorRequest,
9242 _subscription: String,
9243 _delegate: Option<&'a mut dyn common::Delegate>,
9244 _additional_params: HashMap<String, String>,
9245 _scopes: BTreeSet<String>,
9246}
9247
9248impl<'a, C> common::CallBuilder for CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {}
9249
9250impl<'a, C> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9251where
9252 C: common::Connector,
9253{
9254 /// Perform the operation you have build so far.
9255 pub async fn doit(mut self) -> common::Result<(common::Response, CommitCursorResponse)> {
9256 use std::borrow::Cow;
9257 use std::io::{Read, Seek};
9258
9259 use common::{url::Params, ToParts};
9260 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9261
9262 let mut dd = common::DefaultDelegate;
9263 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9264 dlg.begin(common::MethodInfo {
9265 id: "pubsublite.cursor.projects.locations.subscriptions.commitCursor",
9266 http_method: hyper::Method::POST,
9267 });
9268
9269 for &field in ["alt", "subscription"].iter() {
9270 if self._additional_params.contains_key(field) {
9271 dlg.finished(false);
9272 return Err(common::Error::FieldClash(field));
9273 }
9274 }
9275
9276 let mut params = Params::with_capacity(4 + self._additional_params.len());
9277 params.push("subscription", self._subscription);
9278
9279 params.extend(self._additional_params.iter());
9280
9281 params.push("alt", "json");
9282 let mut url = self.hub._base_url.clone() + "v1/cursor/{+subscription}:commitCursor";
9283 if self._scopes.is_empty() {
9284 self._scopes
9285 .insert(Scope::CloudPlatform.as_ref().to_string());
9286 }
9287
9288 #[allow(clippy::single_element_loop)]
9289 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
9290 url = params.uri_replacement(url, param_name, find_this, true);
9291 }
9292 {
9293 let to_remove = ["subscription"];
9294 params.remove_params(&to_remove);
9295 }
9296
9297 let url = params.parse_with_url(&url);
9298
9299 let mut json_mime_type = mime::APPLICATION_JSON;
9300 let mut request_value_reader = {
9301 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9302 common::remove_json_null_values(&mut value);
9303 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9304 serde_json::to_writer(&mut dst, &value).unwrap();
9305 dst
9306 };
9307 let request_size = request_value_reader
9308 .seek(std::io::SeekFrom::End(0))
9309 .unwrap();
9310 request_value_reader
9311 .seek(std::io::SeekFrom::Start(0))
9312 .unwrap();
9313
9314 loop {
9315 let token = match self
9316 .hub
9317 .auth
9318 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9319 .await
9320 {
9321 Ok(token) => token,
9322 Err(e) => match dlg.token(e) {
9323 Ok(token) => token,
9324 Err(e) => {
9325 dlg.finished(false);
9326 return Err(common::Error::MissingToken(e));
9327 }
9328 },
9329 };
9330 request_value_reader
9331 .seek(std::io::SeekFrom::Start(0))
9332 .unwrap();
9333 let mut req_result = {
9334 let client = &self.hub.client;
9335 dlg.pre_request();
9336 let mut req_builder = hyper::Request::builder()
9337 .method(hyper::Method::POST)
9338 .uri(url.as_str())
9339 .header(USER_AGENT, self.hub._user_agent.clone());
9340
9341 if let Some(token) = token.as_ref() {
9342 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9343 }
9344
9345 let request = req_builder
9346 .header(CONTENT_TYPE, json_mime_type.to_string())
9347 .header(CONTENT_LENGTH, request_size as u64)
9348 .body(common::to_body(
9349 request_value_reader.get_ref().clone().into(),
9350 ));
9351
9352 client.request(request.unwrap()).await
9353 };
9354
9355 match req_result {
9356 Err(err) => {
9357 if let common::Retry::After(d) = dlg.http_error(&err) {
9358 sleep(d).await;
9359 continue;
9360 }
9361 dlg.finished(false);
9362 return Err(common::Error::HttpError(err));
9363 }
9364 Ok(res) => {
9365 let (mut parts, body) = res.into_parts();
9366 let mut body = common::Body::new(body);
9367 if !parts.status.is_success() {
9368 let bytes = common::to_bytes(body).await.unwrap_or_default();
9369 let error = serde_json::from_str(&common::to_string(&bytes));
9370 let response = common::to_response(parts, bytes.into());
9371
9372 if let common::Retry::After(d) =
9373 dlg.http_failure(&response, error.as_ref().ok())
9374 {
9375 sleep(d).await;
9376 continue;
9377 }
9378
9379 dlg.finished(false);
9380
9381 return Err(match error {
9382 Ok(value) => common::Error::BadRequest(value),
9383 _ => common::Error::Failure(response),
9384 });
9385 }
9386 let response = {
9387 let bytes = common::to_bytes(body).await.unwrap_or_default();
9388 let encoded = common::to_string(&bytes);
9389 match serde_json::from_str(&encoded) {
9390 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9391 Err(error) => {
9392 dlg.response_json_decode_error(&encoded, &error);
9393 return Err(common::Error::JsonDecodeError(
9394 encoded.to_string(),
9395 error,
9396 ));
9397 }
9398 }
9399 };
9400
9401 dlg.finished(true);
9402 return Ok(response);
9403 }
9404 }
9405 }
9406 }
9407
9408 ///
9409 /// Sets the *request* property to the given value.
9410 ///
9411 /// Even though the property as already been set when instantiating this call,
9412 /// we provide this method for API completeness.
9413 pub fn request(
9414 mut self,
9415 new_value: CommitCursorRequest,
9416 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9417 self._request = new_value;
9418 self
9419 }
9420 /// The subscription for which to update the cursor.
9421 ///
9422 /// Sets the *subscription* path property to the given value.
9423 ///
9424 /// Even though the property as already been set when instantiating this call,
9425 /// we provide this method for API completeness.
9426 pub fn subscription(
9427 mut self,
9428 new_value: &str,
9429 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9430 self._subscription = new_value.to_string();
9431 self
9432 }
9433 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9434 /// while executing the actual API request.
9435 ///
9436 /// ````text
9437 /// It should be used to handle progress information, and to implement a certain level of resilience.
9438 /// ````
9439 ///
9440 /// Sets the *delegate* property to the given value.
9441 pub fn delegate(
9442 mut self,
9443 new_value: &'a mut dyn common::Delegate,
9444 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9445 self._delegate = Some(new_value);
9446 self
9447 }
9448
9449 /// Set any additional parameter of the query string used in the request.
9450 /// It should be used to set parameters which are not yet available through their own
9451 /// setters.
9452 ///
9453 /// Please note that this method must not be used to set any of the known parameters
9454 /// which have their own setter method. If done anyway, the request will fail.
9455 ///
9456 /// # Additional Parameters
9457 ///
9458 /// * *$.xgafv* (query-string) - V1 error format.
9459 /// * *access_token* (query-string) - OAuth access token.
9460 /// * *alt* (query-string) - Data format for response.
9461 /// * *callback* (query-string) - JSONP
9462 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9463 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9464 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9465 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9466 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9467 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9468 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9469 pub fn param<T>(
9470 mut self,
9471 name: T,
9472 value: T,
9473 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9474 where
9475 T: AsRef<str>,
9476 {
9477 self._additional_params
9478 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9479 self
9480 }
9481
9482 /// Identifies the authorization scope for the method you are building.
9483 ///
9484 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9485 /// [`Scope::CloudPlatform`].
9486 ///
9487 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9488 /// tokens for more than one scope.
9489 ///
9490 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9491 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9492 /// sufficient, a read-write scope will do as well.
9493 pub fn add_scope<St>(
9494 mut self,
9495 scope: St,
9496 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9497 where
9498 St: AsRef<str>,
9499 {
9500 self._scopes.insert(String::from(scope.as_ref()));
9501 self
9502 }
9503 /// Identifies the authorization scope(s) for the method you are building.
9504 ///
9505 /// See [`Self::add_scope()`] for details.
9506 pub fn add_scopes<I, St>(
9507 mut self,
9508 scopes: I,
9509 ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9510 where
9511 I: IntoIterator<Item = St>,
9512 St: AsRef<str>,
9513 {
9514 self._scopes
9515 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9516 self
9517 }
9518
9519 /// Removes all scopes, and no default scope will be used either.
9520 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9521 /// for details).
9522 pub fn clear_scopes(mut self) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9523 self._scopes.clear();
9524 self
9525 }
9526}
9527
9528/// Compute the head cursor for the partition. The head cursor's offset is guaranteed to be less than or equal to all messages which have not yet been acknowledged as published, and greater than the offset of any message whose publish has already been acknowledged. It is zero if there have never been messages in the partition.
9529///
9530/// A builder for the *projects.locations.topics.computeHeadCursor* method supported by a *topicStat* resource.
9531/// It is not used directly, but through a [`TopicStatMethods`] instance.
9532///
9533/// # Example
9534///
9535/// Instantiate a resource method builder
9536///
9537/// ```test_harness,no_run
9538/// # extern crate hyper;
9539/// # extern crate hyper_rustls;
9540/// # extern crate google_pubsublite1 as pubsublite1;
9541/// use pubsublite1::api::ComputeHeadCursorRequest;
9542/// # async fn dox() {
9543/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9544///
9545/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9546/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9547/// # secret,
9548/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9549/// # ).build().await.unwrap();
9550///
9551/// # let client = hyper_util::client::legacy::Client::builder(
9552/// # hyper_util::rt::TokioExecutor::new()
9553/// # )
9554/// # .build(
9555/// # hyper_rustls::HttpsConnectorBuilder::new()
9556/// # .with_native_roots()
9557/// # .unwrap()
9558/// # .https_or_http()
9559/// # .enable_http1()
9560/// # .build()
9561/// # );
9562/// # let mut hub = PubsubLite::new(client, auth);
9563/// // As the method needs a request, you would usually fill it with the desired information
9564/// // into the respective structure. Some of the parts shown here might not be applicable !
9565/// // Values shown here are possibly random and not representative !
9566/// let mut req = ComputeHeadCursorRequest::default();
9567///
9568/// // You can configure optional parameters by calling the respective setters at will, and
9569/// // execute the final call using `doit()`.
9570/// // Values shown here are possibly random and not representative !
9571/// let result = hub.topic_stats().projects_locations_topics_compute_head_cursor(req, "topic")
9572/// .doit().await;
9573/// # }
9574/// ```
9575pub struct TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9576where
9577 C: 'a,
9578{
9579 hub: &'a PubsubLite<C>,
9580 _request: ComputeHeadCursorRequest,
9581 _topic: String,
9582 _delegate: Option<&'a mut dyn common::Delegate>,
9583 _additional_params: HashMap<String, String>,
9584 _scopes: BTreeSet<String>,
9585}
9586
9587impl<'a, C> common::CallBuilder for TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {}
9588
9589impl<'a, C> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9590where
9591 C: common::Connector,
9592{
9593 /// Perform the operation you have build so far.
9594 pub async fn doit(mut self) -> common::Result<(common::Response, ComputeHeadCursorResponse)> {
9595 use std::borrow::Cow;
9596 use std::io::{Read, Seek};
9597
9598 use common::{url::Params, ToParts};
9599 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9600
9601 let mut dd = common::DefaultDelegate;
9602 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9603 dlg.begin(common::MethodInfo {
9604 id: "pubsublite.topicStats.projects.locations.topics.computeHeadCursor",
9605 http_method: hyper::Method::POST,
9606 });
9607
9608 for &field in ["alt", "topic"].iter() {
9609 if self._additional_params.contains_key(field) {
9610 dlg.finished(false);
9611 return Err(common::Error::FieldClash(field));
9612 }
9613 }
9614
9615 let mut params = Params::with_capacity(4 + self._additional_params.len());
9616 params.push("topic", self._topic);
9617
9618 params.extend(self._additional_params.iter());
9619
9620 params.push("alt", "json");
9621 let mut url = self.hub._base_url.clone() + "v1/topicStats/{+topic}:computeHeadCursor";
9622 if self._scopes.is_empty() {
9623 self._scopes
9624 .insert(Scope::CloudPlatform.as_ref().to_string());
9625 }
9626
9627 #[allow(clippy::single_element_loop)]
9628 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
9629 url = params.uri_replacement(url, param_name, find_this, true);
9630 }
9631 {
9632 let to_remove = ["topic"];
9633 params.remove_params(&to_remove);
9634 }
9635
9636 let url = params.parse_with_url(&url);
9637
9638 let mut json_mime_type = mime::APPLICATION_JSON;
9639 let mut request_value_reader = {
9640 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9641 common::remove_json_null_values(&mut value);
9642 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9643 serde_json::to_writer(&mut dst, &value).unwrap();
9644 dst
9645 };
9646 let request_size = request_value_reader
9647 .seek(std::io::SeekFrom::End(0))
9648 .unwrap();
9649 request_value_reader
9650 .seek(std::io::SeekFrom::Start(0))
9651 .unwrap();
9652
9653 loop {
9654 let token = match self
9655 .hub
9656 .auth
9657 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9658 .await
9659 {
9660 Ok(token) => token,
9661 Err(e) => match dlg.token(e) {
9662 Ok(token) => token,
9663 Err(e) => {
9664 dlg.finished(false);
9665 return Err(common::Error::MissingToken(e));
9666 }
9667 },
9668 };
9669 request_value_reader
9670 .seek(std::io::SeekFrom::Start(0))
9671 .unwrap();
9672 let mut req_result = {
9673 let client = &self.hub.client;
9674 dlg.pre_request();
9675 let mut req_builder = hyper::Request::builder()
9676 .method(hyper::Method::POST)
9677 .uri(url.as_str())
9678 .header(USER_AGENT, self.hub._user_agent.clone());
9679
9680 if let Some(token) = token.as_ref() {
9681 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9682 }
9683
9684 let request = req_builder
9685 .header(CONTENT_TYPE, json_mime_type.to_string())
9686 .header(CONTENT_LENGTH, request_size as u64)
9687 .body(common::to_body(
9688 request_value_reader.get_ref().clone().into(),
9689 ));
9690
9691 client.request(request.unwrap()).await
9692 };
9693
9694 match req_result {
9695 Err(err) => {
9696 if let common::Retry::After(d) = dlg.http_error(&err) {
9697 sleep(d).await;
9698 continue;
9699 }
9700 dlg.finished(false);
9701 return Err(common::Error::HttpError(err));
9702 }
9703 Ok(res) => {
9704 let (mut parts, body) = res.into_parts();
9705 let mut body = common::Body::new(body);
9706 if !parts.status.is_success() {
9707 let bytes = common::to_bytes(body).await.unwrap_or_default();
9708 let error = serde_json::from_str(&common::to_string(&bytes));
9709 let response = common::to_response(parts, bytes.into());
9710
9711 if let common::Retry::After(d) =
9712 dlg.http_failure(&response, error.as_ref().ok())
9713 {
9714 sleep(d).await;
9715 continue;
9716 }
9717
9718 dlg.finished(false);
9719
9720 return Err(match error {
9721 Ok(value) => common::Error::BadRequest(value),
9722 _ => common::Error::Failure(response),
9723 });
9724 }
9725 let response = {
9726 let bytes = common::to_bytes(body).await.unwrap_or_default();
9727 let encoded = common::to_string(&bytes);
9728 match serde_json::from_str(&encoded) {
9729 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9730 Err(error) => {
9731 dlg.response_json_decode_error(&encoded, &error);
9732 return Err(common::Error::JsonDecodeError(
9733 encoded.to_string(),
9734 error,
9735 ));
9736 }
9737 }
9738 };
9739
9740 dlg.finished(true);
9741 return Ok(response);
9742 }
9743 }
9744 }
9745 }
9746
9747 ///
9748 /// Sets the *request* property to the given value.
9749 ///
9750 /// Even though the property as already been set when instantiating this call,
9751 /// we provide this method for API completeness.
9752 pub fn request(
9753 mut self,
9754 new_value: ComputeHeadCursorRequest,
9755 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
9756 self._request = new_value;
9757 self
9758 }
9759 /// Required. The topic for which we should compute the head cursor.
9760 ///
9761 /// Sets the *topic* path property to the given value.
9762 ///
9763 /// Even though the property as already been set when instantiating this call,
9764 /// we provide this method for API completeness.
9765 pub fn topic(
9766 mut self,
9767 new_value: &str,
9768 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
9769 self._topic = new_value.to_string();
9770 self
9771 }
9772 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9773 /// while executing the actual API request.
9774 ///
9775 /// ````text
9776 /// It should be used to handle progress information, and to implement a certain level of resilience.
9777 /// ````
9778 ///
9779 /// Sets the *delegate* property to the given value.
9780 pub fn delegate(
9781 mut self,
9782 new_value: &'a mut dyn common::Delegate,
9783 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
9784 self._delegate = Some(new_value);
9785 self
9786 }
9787
9788 /// Set any additional parameter of the query string used in the request.
9789 /// It should be used to set parameters which are not yet available through their own
9790 /// setters.
9791 ///
9792 /// Please note that this method must not be used to set any of the known parameters
9793 /// which have their own setter method. If done anyway, the request will fail.
9794 ///
9795 /// # Additional Parameters
9796 ///
9797 /// * *$.xgafv* (query-string) - V1 error format.
9798 /// * *access_token* (query-string) - OAuth access token.
9799 /// * *alt* (query-string) - Data format for response.
9800 /// * *callback* (query-string) - JSONP
9801 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9802 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9803 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9804 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9805 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9806 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9807 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9808 pub fn param<T>(
9809 mut self,
9810 name: T,
9811 value: T,
9812 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9813 where
9814 T: AsRef<str>,
9815 {
9816 self._additional_params
9817 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9818 self
9819 }
9820
9821 /// Identifies the authorization scope for the method you are building.
9822 ///
9823 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9824 /// [`Scope::CloudPlatform`].
9825 ///
9826 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9827 /// tokens for more than one scope.
9828 ///
9829 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9830 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9831 /// sufficient, a read-write scope will do as well.
9832 pub fn add_scope<St>(
9833 mut self,
9834 scope: St,
9835 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9836 where
9837 St: AsRef<str>,
9838 {
9839 self._scopes.insert(String::from(scope.as_ref()));
9840 self
9841 }
9842 /// Identifies the authorization scope(s) for the method you are building.
9843 ///
9844 /// See [`Self::add_scope()`] for details.
9845 pub fn add_scopes<I, St>(
9846 mut self,
9847 scopes: I,
9848 ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9849 where
9850 I: IntoIterator<Item = St>,
9851 St: AsRef<str>,
9852 {
9853 self._scopes
9854 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9855 self
9856 }
9857
9858 /// Removes all scopes, and no default scope will be used either.
9859 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9860 /// for details).
9861 pub fn clear_scopes(mut self) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
9862 self._scopes.clear();
9863 self
9864 }
9865}
9866
9867/// Compute statistics about a range of messages in a given topic and partition.
9868///
9869/// A builder for the *projects.locations.topics.computeMessageStats* method supported by a *topicStat* resource.
9870/// It is not used directly, but through a [`TopicStatMethods`] instance.
9871///
9872/// # Example
9873///
9874/// Instantiate a resource method builder
9875///
9876/// ```test_harness,no_run
9877/// # extern crate hyper;
9878/// # extern crate hyper_rustls;
9879/// # extern crate google_pubsublite1 as pubsublite1;
9880/// use pubsublite1::api::ComputeMessageStatsRequest;
9881/// # async fn dox() {
9882/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9883///
9884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9886/// # secret,
9887/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9888/// # ).build().await.unwrap();
9889///
9890/// # let client = hyper_util::client::legacy::Client::builder(
9891/// # hyper_util::rt::TokioExecutor::new()
9892/// # )
9893/// # .build(
9894/// # hyper_rustls::HttpsConnectorBuilder::new()
9895/// # .with_native_roots()
9896/// # .unwrap()
9897/// # .https_or_http()
9898/// # .enable_http1()
9899/// # .build()
9900/// # );
9901/// # let mut hub = PubsubLite::new(client, auth);
9902/// // As the method needs a request, you would usually fill it with the desired information
9903/// // into the respective structure. Some of the parts shown here might not be applicable !
9904/// // Values shown here are possibly random and not representative !
9905/// let mut req = ComputeMessageStatsRequest::default();
9906///
9907/// // You can configure optional parameters by calling the respective setters at will, and
9908/// // execute the final call using `doit()`.
9909/// // Values shown here are possibly random and not representative !
9910/// let result = hub.topic_stats().projects_locations_topics_compute_message_stats(req, "topic")
9911/// .doit().await;
9912/// # }
9913/// ```
9914pub struct TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
9915where
9916 C: 'a,
9917{
9918 hub: &'a PubsubLite<C>,
9919 _request: ComputeMessageStatsRequest,
9920 _topic: String,
9921 _delegate: Option<&'a mut dyn common::Delegate>,
9922 _additional_params: HashMap<String, String>,
9923 _scopes: BTreeSet<String>,
9924}
9925
9926impl<'a, C> common::CallBuilder for TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {}
9927
9928impl<'a, C> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
9929where
9930 C: common::Connector,
9931{
9932 /// Perform the operation you have build so far.
9933 pub async fn doit(mut self) -> common::Result<(common::Response, ComputeMessageStatsResponse)> {
9934 use std::borrow::Cow;
9935 use std::io::{Read, Seek};
9936
9937 use common::{url::Params, ToParts};
9938 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9939
9940 let mut dd = common::DefaultDelegate;
9941 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9942 dlg.begin(common::MethodInfo {
9943 id: "pubsublite.topicStats.projects.locations.topics.computeMessageStats",
9944 http_method: hyper::Method::POST,
9945 });
9946
9947 for &field in ["alt", "topic"].iter() {
9948 if self._additional_params.contains_key(field) {
9949 dlg.finished(false);
9950 return Err(common::Error::FieldClash(field));
9951 }
9952 }
9953
9954 let mut params = Params::with_capacity(4 + self._additional_params.len());
9955 params.push("topic", self._topic);
9956
9957 params.extend(self._additional_params.iter());
9958
9959 params.push("alt", "json");
9960 let mut url = self.hub._base_url.clone() + "v1/topicStats/{+topic}:computeMessageStats";
9961 if self._scopes.is_empty() {
9962 self._scopes
9963 .insert(Scope::CloudPlatform.as_ref().to_string());
9964 }
9965
9966 #[allow(clippy::single_element_loop)]
9967 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
9968 url = params.uri_replacement(url, param_name, find_this, true);
9969 }
9970 {
9971 let to_remove = ["topic"];
9972 params.remove_params(&to_remove);
9973 }
9974
9975 let url = params.parse_with_url(&url);
9976
9977 let mut json_mime_type = mime::APPLICATION_JSON;
9978 let mut request_value_reader = {
9979 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9980 common::remove_json_null_values(&mut value);
9981 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9982 serde_json::to_writer(&mut dst, &value).unwrap();
9983 dst
9984 };
9985 let request_size = request_value_reader
9986 .seek(std::io::SeekFrom::End(0))
9987 .unwrap();
9988 request_value_reader
9989 .seek(std::io::SeekFrom::Start(0))
9990 .unwrap();
9991
9992 loop {
9993 let token = match self
9994 .hub
9995 .auth
9996 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9997 .await
9998 {
9999 Ok(token) => token,
10000 Err(e) => match dlg.token(e) {
10001 Ok(token) => token,
10002 Err(e) => {
10003 dlg.finished(false);
10004 return Err(common::Error::MissingToken(e));
10005 }
10006 },
10007 };
10008 request_value_reader
10009 .seek(std::io::SeekFrom::Start(0))
10010 .unwrap();
10011 let mut req_result = {
10012 let client = &self.hub.client;
10013 dlg.pre_request();
10014 let mut req_builder = hyper::Request::builder()
10015 .method(hyper::Method::POST)
10016 .uri(url.as_str())
10017 .header(USER_AGENT, self.hub._user_agent.clone());
10018
10019 if let Some(token) = token.as_ref() {
10020 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10021 }
10022
10023 let request = req_builder
10024 .header(CONTENT_TYPE, json_mime_type.to_string())
10025 .header(CONTENT_LENGTH, request_size as u64)
10026 .body(common::to_body(
10027 request_value_reader.get_ref().clone().into(),
10028 ));
10029
10030 client.request(request.unwrap()).await
10031 };
10032
10033 match req_result {
10034 Err(err) => {
10035 if let common::Retry::After(d) = dlg.http_error(&err) {
10036 sleep(d).await;
10037 continue;
10038 }
10039 dlg.finished(false);
10040 return Err(common::Error::HttpError(err));
10041 }
10042 Ok(res) => {
10043 let (mut parts, body) = res.into_parts();
10044 let mut body = common::Body::new(body);
10045 if !parts.status.is_success() {
10046 let bytes = common::to_bytes(body).await.unwrap_or_default();
10047 let error = serde_json::from_str(&common::to_string(&bytes));
10048 let response = common::to_response(parts, bytes.into());
10049
10050 if let common::Retry::After(d) =
10051 dlg.http_failure(&response, error.as_ref().ok())
10052 {
10053 sleep(d).await;
10054 continue;
10055 }
10056
10057 dlg.finished(false);
10058
10059 return Err(match error {
10060 Ok(value) => common::Error::BadRequest(value),
10061 _ => common::Error::Failure(response),
10062 });
10063 }
10064 let response = {
10065 let bytes = common::to_bytes(body).await.unwrap_or_default();
10066 let encoded = common::to_string(&bytes);
10067 match serde_json::from_str(&encoded) {
10068 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10069 Err(error) => {
10070 dlg.response_json_decode_error(&encoded, &error);
10071 return Err(common::Error::JsonDecodeError(
10072 encoded.to_string(),
10073 error,
10074 ));
10075 }
10076 }
10077 };
10078
10079 dlg.finished(true);
10080 return Ok(response);
10081 }
10082 }
10083 }
10084 }
10085
10086 ///
10087 /// Sets the *request* property to the given value.
10088 ///
10089 /// Even though the property as already been set when instantiating this call,
10090 /// we provide this method for API completeness.
10091 pub fn request(
10092 mut self,
10093 new_value: ComputeMessageStatsRequest,
10094 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10095 self._request = new_value;
10096 self
10097 }
10098 /// Required. The topic for which we should compute message stats.
10099 ///
10100 /// Sets the *topic* path property to the given value.
10101 ///
10102 /// Even though the property as already been set when instantiating this call,
10103 /// we provide this method for API completeness.
10104 pub fn topic(
10105 mut self,
10106 new_value: &str,
10107 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10108 self._topic = new_value.to_string();
10109 self
10110 }
10111 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10112 /// while executing the actual API request.
10113 ///
10114 /// ````text
10115 /// It should be used to handle progress information, and to implement a certain level of resilience.
10116 /// ````
10117 ///
10118 /// Sets the *delegate* property to the given value.
10119 pub fn delegate(
10120 mut self,
10121 new_value: &'a mut dyn common::Delegate,
10122 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10123 self._delegate = Some(new_value);
10124 self
10125 }
10126
10127 /// Set any additional parameter of the query string used in the request.
10128 /// It should be used to set parameters which are not yet available through their own
10129 /// setters.
10130 ///
10131 /// Please note that this method must not be used to set any of the known parameters
10132 /// which have their own setter method. If done anyway, the request will fail.
10133 ///
10134 /// # Additional Parameters
10135 ///
10136 /// * *$.xgafv* (query-string) - V1 error format.
10137 /// * *access_token* (query-string) - OAuth access token.
10138 /// * *alt* (query-string) - Data format for response.
10139 /// * *callback* (query-string) - JSONP
10140 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10141 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10142 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10143 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10144 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10145 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10146 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10147 pub fn param<T>(
10148 mut self,
10149 name: T,
10150 value: T,
10151 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10152 where
10153 T: AsRef<str>,
10154 {
10155 self._additional_params
10156 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10157 self
10158 }
10159
10160 /// Identifies the authorization scope for the method you are building.
10161 ///
10162 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10163 /// [`Scope::CloudPlatform`].
10164 ///
10165 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10166 /// tokens for more than one scope.
10167 ///
10168 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10169 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10170 /// sufficient, a read-write scope will do as well.
10171 pub fn add_scope<St>(
10172 mut self,
10173 scope: St,
10174 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10175 where
10176 St: AsRef<str>,
10177 {
10178 self._scopes.insert(String::from(scope.as_ref()));
10179 self
10180 }
10181 /// Identifies the authorization scope(s) for the method you are building.
10182 ///
10183 /// See [`Self::add_scope()`] for details.
10184 pub fn add_scopes<I, St>(
10185 mut self,
10186 scopes: I,
10187 ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10188 where
10189 I: IntoIterator<Item = St>,
10190 St: AsRef<str>,
10191 {
10192 self._scopes
10193 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10194 self
10195 }
10196
10197 /// Removes all scopes, and no default scope will be used either.
10198 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10199 /// for details).
10200 pub fn clear_scopes(mut self) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10201 self._scopes.clear();
10202 self
10203 }
10204}
10205
10206/// Compute the corresponding cursor for a publish or event time in a topic partition.
10207///
10208/// A builder for the *projects.locations.topics.computeTimeCursor* method supported by a *topicStat* resource.
10209/// It is not used directly, but through a [`TopicStatMethods`] instance.
10210///
10211/// # Example
10212///
10213/// Instantiate a resource method builder
10214///
10215/// ```test_harness,no_run
10216/// # extern crate hyper;
10217/// # extern crate hyper_rustls;
10218/// # extern crate google_pubsublite1 as pubsublite1;
10219/// use pubsublite1::api::ComputeTimeCursorRequest;
10220/// # async fn dox() {
10221/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10222///
10223/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10225/// # secret,
10226/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10227/// # ).build().await.unwrap();
10228///
10229/// # let client = hyper_util::client::legacy::Client::builder(
10230/// # hyper_util::rt::TokioExecutor::new()
10231/// # )
10232/// # .build(
10233/// # hyper_rustls::HttpsConnectorBuilder::new()
10234/// # .with_native_roots()
10235/// # .unwrap()
10236/// # .https_or_http()
10237/// # .enable_http1()
10238/// # .build()
10239/// # );
10240/// # let mut hub = PubsubLite::new(client, auth);
10241/// // As the method needs a request, you would usually fill it with the desired information
10242/// // into the respective structure. Some of the parts shown here might not be applicable !
10243/// // Values shown here are possibly random and not representative !
10244/// let mut req = ComputeTimeCursorRequest::default();
10245///
10246/// // You can configure optional parameters by calling the respective setters at will, and
10247/// // execute the final call using `doit()`.
10248/// // Values shown here are possibly random and not representative !
10249/// let result = hub.topic_stats().projects_locations_topics_compute_time_cursor(req, "topic")
10250/// .doit().await;
10251/// # }
10252/// ```
10253pub struct TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10254where
10255 C: 'a,
10256{
10257 hub: &'a PubsubLite<C>,
10258 _request: ComputeTimeCursorRequest,
10259 _topic: String,
10260 _delegate: Option<&'a mut dyn common::Delegate>,
10261 _additional_params: HashMap<String, String>,
10262 _scopes: BTreeSet<String>,
10263}
10264
10265impl<'a, C> common::CallBuilder for TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {}
10266
10267impl<'a, C> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10268where
10269 C: common::Connector,
10270{
10271 /// Perform the operation you have build so far.
10272 pub async fn doit(mut self) -> common::Result<(common::Response, ComputeTimeCursorResponse)> {
10273 use std::borrow::Cow;
10274 use std::io::{Read, Seek};
10275
10276 use common::{url::Params, ToParts};
10277 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10278
10279 let mut dd = common::DefaultDelegate;
10280 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10281 dlg.begin(common::MethodInfo {
10282 id: "pubsublite.topicStats.projects.locations.topics.computeTimeCursor",
10283 http_method: hyper::Method::POST,
10284 });
10285
10286 for &field in ["alt", "topic"].iter() {
10287 if self._additional_params.contains_key(field) {
10288 dlg.finished(false);
10289 return Err(common::Error::FieldClash(field));
10290 }
10291 }
10292
10293 let mut params = Params::with_capacity(4 + self._additional_params.len());
10294 params.push("topic", self._topic);
10295
10296 params.extend(self._additional_params.iter());
10297
10298 params.push("alt", "json");
10299 let mut url = self.hub._base_url.clone() + "v1/topicStats/{+topic}:computeTimeCursor";
10300 if self._scopes.is_empty() {
10301 self._scopes
10302 .insert(Scope::CloudPlatform.as_ref().to_string());
10303 }
10304
10305 #[allow(clippy::single_element_loop)]
10306 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
10307 url = params.uri_replacement(url, param_name, find_this, true);
10308 }
10309 {
10310 let to_remove = ["topic"];
10311 params.remove_params(&to_remove);
10312 }
10313
10314 let url = params.parse_with_url(&url);
10315
10316 let mut json_mime_type = mime::APPLICATION_JSON;
10317 let mut request_value_reader = {
10318 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10319 common::remove_json_null_values(&mut value);
10320 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10321 serde_json::to_writer(&mut dst, &value).unwrap();
10322 dst
10323 };
10324 let request_size = request_value_reader
10325 .seek(std::io::SeekFrom::End(0))
10326 .unwrap();
10327 request_value_reader
10328 .seek(std::io::SeekFrom::Start(0))
10329 .unwrap();
10330
10331 loop {
10332 let token = match self
10333 .hub
10334 .auth
10335 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10336 .await
10337 {
10338 Ok(token) => token,
10339 Err(e) => match dlg.token(e) {
10340 Ok(token) => token,
10341 Err(e) => {
10342 dlg.finished(false);
10343 return Err(common::Error::MissingToken(e));
10344 }
10345 },
10346 };
10347 request_value_reader
10348 .seek(std::io::SeekFrom::Start(0))
10349 .unwrap();
10350 let mut req_result = {
10351 let client = &self.hub.client;
10352 dlg.pre_request();
10353 let mut req_builder = hyper::Request::builder()
10354 .method(hyper::Method::POST)
10355 .uri(url.as_str())
10356 .header(USER_AGENT, self.hub._user_agent.clone());
10357
10358 if let Some(token) = token.as_ref() {
10359 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10360 }
10361
10362 let request = req_builder
10363 .header(CONTENT_TYPE, json_mime_type.to_string())
10364 .header(CONTENT_LENGTH, request_size as u64)
10365 .body(common::to_body(
10366 request_value_reader.get_ref().clone().into(),
10367 ));
10368
10369 client.request(request.unwrap()).await
10370 };
10371
10372 match req_result {
10373 Err(err) => {
10374 if let common::Retry::After(d) = dlg.http_error(&err) {
10375 sleep(d).await;
10376 continue;
10377 }
10378 dlg.finished(false);
10379 return Err(common::Error::HttpError(err));
10380 }
10381 Ok(res) => {
10382 let (mut parts, body) = res.into_parts();
10383 let mut body = common::Body::new(body);
10384 if !parts.status.is_success() {
10385 let bytes = common::to_bytes(body).await.unwrap_or_default();
10386 let error = serde_json::from_str(&common::to_string(&bytes));
10387 let response = common::to_response(parts, bytes.into());
10388
10389 if let common::Retry::After(d) =
10390 dlg.http_failure(&response, error.as_ref().ok())
10391 {
10392 sleep(d).await;
10393 continue;
10394 }
10395
10396 dlg.finished(false);
10397
10398 return Err(match error {
10399 Ok(value) => common::Error::BadRequest(value),
10400 _ => common::Error::Failure(response),
10401 });
10402 }
10403 let response = {
10404 let bytes = common::to_bytes(body).await.unwrap_or_default();
10405 let encoded = common::to_string(&bytes);
10406 match serde_json::from_str(&encoded) {
10407 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10408 Err(error) => {
10409 dlg.response_json_decode_error(&encoded, &error);
10410 return Err(common::Error::JsonDecodeError(
10411 encoded.to_string(),
10412 error,
10413 ));
10414 }
10415 }
10416 };
10417
10418 dlg.finished(true);
10419 return Ok(response);
10420 }
10421 }
10422 }
10423 }
10424
10425 ///
10426 /// Sets the *request* property to the given value.
10427 ///
10428 /// Even though the property as already been set when instantiating this call,
10429 /// we provide this method for API completeness.
10430 pub fn request(
10431 mut self,
10432 new_value: ComputeTimeCursorRequest,
10433 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10434 self._request = new_value;
10435 self
10436 }
10437 /// Required. The topic for which we should compute the cursor.
10438 ///
10439 /// Sets the *topic* path property to the given value.
10440 ///
10441 /// Even though the property as already been set when instantiating this call,
10442 /// we provide this method for API completeness.
10443 pub fn topic(
10444 mut self,
10445 new_value: &str,
10446 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10447 self._topic = new_value.to_string();
10448 self
10449 }
10450 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10451 /// while executing the actual API request.
10452 ///
10453 /// ````text
10454 /// It should be used to handle progress information, and to implement a certain level of resilience.
10455 /// ````
10456 ///
10457 /// Sets the *delegate* property to the given value.
10458 pub fn delegate(
10459 mut self,
10460 new_value: &'a mut dyn common::Delegate,
10461 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10462 self._delegate = Some(new_value);
10463 self
10464 }
10465
10466 /// Set any additional parameter of the query string used in the request.
10467 /// It should be used to set parameters which are not yet available through their own
10468 /// setters.
10469 ///
10470 /// Please note that this method must not be used to set any of the known parameters
10471 /// which have their own setter method. If done anyway, the request will fail.
10472 ///
10473 /// # Additional Parameters
10474 ///
10475 /// * *$.xgafv* (query-string) - V1 error format.
10476 /// * *access_token* (query-string) - OAuth access token.
10477 /// * *alt* (query-string) - Data format for response.
10478 /// * *callback* (query-string) - JSONP
10479 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10480 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10481 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10482 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10483 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10484 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10485 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10486 pub fn param<T>(
10487 mut self,
10488 name: T,
10489 value: T,
10490 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10491 where
10492 T: AsRef<str>,
10493 {
10494 self._additional_params
10495 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10496 self
10497 }
10498
10499 /// Identifies the authorization scope for the method you are building.
10500 ///
10501 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10502 /// [`Scope::CloudPlatform`].
10503 ///
10504 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10505 /// tokens for more than one scope.
10506 ///
10507 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10508 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10509 /// sufficient, a read-write scope will do as well.
10510 pub fn add_scope<St>(
10511 mut self,
10512 scope: St,
10513 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10514 where
10515 St: AsRef<str>,
10516 {
10517 self._scopes.insert(String::from(scope.as_ref()));
10518 self
10519 }
10520 /// Identifies the authorization scope(s) for the method you are building.
10521 ///
10522 /// See [`Self::add_scope()`] for details.
10523 pub fn add_scopes<I, St>(
10524 mut self,
10525 scopes: I,
10526 ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10527 where
10528 I: IntoIterator<Item = St>,
10529 St: AsRef<str>,
10530 {
10531 self._scopes
10532 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10533 self
10534 }
10535
10536 /// Removes all scopes, and no default scope will be used either.
10537 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10538 /// for details).
10539 pub fn clear_scopes(mut self) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10540 self._scopes.clear();
10541 self
10542 }
10543}