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 connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = PubsubLite::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = CancelOperationRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.admin().projects_locations_operations_cancel(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct PubsubLite<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for PubsubLite<C> {}
130
131impl<'a, C> PubsubLite<C> {
132    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> PubsubLite<C> {
133        PubsubLite {
134            client,
135            auth: Box::new(auth),
136            _user_agent: "google-api-rust-client/7.0.0".to_string(),
137            _base_url: "https://pubsublite.googleapis.com/".to_string(),
138            _root_url: "https://pubsublite.googleapis.com/".to_string(),
139        }
140    }
141
142    pub fn admin(&'a self) -> AdminMethods<'a, C> {
143        AdminMethods { hub: self }
144    }
145    pub fn cursor(&'a self) -> CursorMethods<'a, C> {
146        CursorMethods { hub: self }
147    }
148    pub fn topic_stats(&'a self) -> TopicStatMethods<'a, C> {
149        TopicStatMethods { hub: self }
150    }
151
152    /// Set the user-agent header field to use in all requests to the server.
153    /// It defaults to `google-api-rust-client/7.0.0`.
154    ///
155    /// Returns the previously set user-agent.
156    pub fn user_agent(&mut self, agent_name: String) -> String {
157        std::mem::replace(&mut self._user_agent, agent_name)
158    }
159
160    /// Set the base url to use in all requests to the server.
161    /// It defaults to `https://pubsublite.googleapis.com/`.
162    ///
163    /// Returns the previously set base url.
164    pub fn base_url(&mut self, new_base_url: String) -> String {
165        std::mem::replace(&mut self._base_url, new_base_url)
166    }
167
168    /// Set the root url to use in all requests to the server.
169    /// It defaults to `https://pubsublite.googleapis.com/`.
170    ///
171    /// Returns the previously set root url.
172    pub fn root_url(&mut self, new_root_url: String) -> String {
173        std::mem::replace(&mut self._root_url, new_root_url)
174    }
175}
176
177// ############
178// SCHEMAS ###
179// ##########
180/// The request message for Operations.CancelOperation.
181///
182/// # Activities
183///
184/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
185/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
186///
187/// * [projects locations operations cancel admin](AdminProjectLocationOperationCancelCall) (request)
188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
189#[serde_with::serde_as]
190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
191pub struct CancelOperationRequest {
192    _never_set: Option<bool>,
193}
194
195impl common::RequestValue for CancelOperationRequest {}
196
197/// The throughput capacity configuration for each partition.
198///
199/// This type is not used in any activity, and only used as *part* of another schema.
200///
201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
202#[serde_with::serde_as]
203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
204pub struct Capacity {
205    /// Publish throughput capacity per partition in MiB/s. Must be >= 4 and <= 16.
206    #[serde(rename = "publishMibPerSec")]
207    pub publish_mib_per_sec: Option<i32>,
208    /// Subscribe throughput capacity per partition in MiB/s. Must be >= 4 and <= 32.
209    #[serde(rename = "subscribeMibPerSec")]
210    pub subscribe_mib_per_sec: Option<i32>,
211}
212
213impl common::Part for Capacity {}
214
215/// Request for CommitCursor.
216///
217/// # Activities
218///
219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
221///
222/// * [projects locations subscriptions commit cursor cursor](CursorProjectLocationSubscriptionCommitCursorCall) (request)
223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
224#[serde_with::serde_as]
225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
226pub struct CommitCursorRequest {
227    /// The new value for the committed cursor.
228    pub cursor: Option<Cursor>,
229    /// The partition for which to update the cursor. Partitions are zero indexed, so `partition` must be in the range [0, topic.num_partitions).
230    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
231    pub partition: Option<i64>,
232}
233
234impl common::RequestValue for CommitCursorRequest {}
235
236/// Response for CommitCursor.
237///
238/// # Activities
239///
240/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
241/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
242///
243/// * [projects locations subscriptions commit cursor cursor](CursorProjectLocationSubscriptionCommitCursorCall) (response)
244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
245#[serde_with::serde_as]
246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
247pub struct CommitCursorResponse {
248    _never_set: Option<bool>,
249}
250
251impl common::ResponseResult for CommitCursorResponse {}
252
253/// Compute the current head cursor for a partition.
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [projects locations topics compute head cursor topic stats](TopicStatProjectLocationTopicComputeHeadCursorCall) (request)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct ComputeHeadCursorRequest {
265    /// Required. The partition for which we should compute the head cursor.
266    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
267    pub partition: Option<i64>,
268}
269
270impl common::RequestValue for ComputeHeadCursorRequest {}
271
272/// Response containing the head cursor for the requested topic and partition.
273///
274/// # Activities
275///
276/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
277/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
278///
279/// * [projects locations topics compute head cursor topic stats](TopicStatProjectLocationTopicComputeHeadCursorCall) (response)
280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
281#[serde_with::serde_as]
282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
283pub struct ComputeHeadCursorResponse {
284    /// The head cursor.
285    #[serde(rename = "headCursor")]
286    pub head_cursor: Option<Cursor>,
287}
288
289impl common::ResponseResult for ComputeHeadCursorResponse {}
290
291/// Compute statistics about a range of messages in a given topic and partition.
292///
293/// # Activities
294///
295/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
296/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
297///
298/// * [projects locations topics compute message stats topic stats](TopicStatProjectLocationTopicComputeMessageStatCall) (request)
299#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
300#[serde_with::serde_as]
301#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
302pub struct ComputeMessageStatsRequest {
303    /// 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.
304    #[serde(rename = "endCursor")]
305    pub end_cursor: Option<Cursor>,
306    /// Required. The partition for which we should compute message stats.
307    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
308    pub partition: Option<i64>,
309    /// The inclusive start of the range.
310    #[serde(rename = "startCursor")]
311    pub start_cursor: Option<Cursor>,
312}
313
314impl common::RequestValue for ComputeMessageStatsRequest {}
315
316/// Response containing stats for messages in the requested topic and partition.
317///
318/// # Activities
319///
320/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
321/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
322///
323/// * [projects locations topics compute message stats topic stats](TopicStatProjectLocationTopicComputeMessageStatCall) (response)
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct ComputeMessageStatsResponse {
328    /// The number of quota bytes accounted to these messages.
329    #[serde(rename = "messageBytes")]
330    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
331    pub message_bytes: Option<i64>,
332    /// The count of messages.
333    #[serde(rename = "messageCount")]
334    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
335    pub message_count: Option<i64>,
336    /// 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.
337    #[serde(rename = "minimumEventTime")]
338    pub minimum_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
339    /// 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.
340    #[serde(rename = "minimumPublishTime")]
341    pub minimum_publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
342}
343
344impl common::ResponseResult for ComputeMessageStatsResponse {}
345
346/// Compute the corresponding cursor for a publish or event time in a topic partition.
347///
348/// # Activities
349///
350/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
351/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
352///
353/// * [projects locations topics compute time cursor topic stats](TopicStatProjectLocationTopicComputeTimeCursorCall) (request)
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct ComputeTimeCursorRequest {
358    /// Required. The partition for which we should compute the cursor.
359    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
360    pub partition: Option<i64>,
361    /// Required. The target publish or event time. Specifying a future time will return an unset cursor.
362    pub target: Option<TimeTarget>,
363}
364
365impl common::RequestValue for ComputeTimeCursorRequest {}
366
367/// Response containing the cursor corresponding to a publish or event time in a topic partition.
368///
369/// # Activities
370///
371/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
372/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
373///
374/// * [projects locations topics compute time cursor topic stats](TopicStatProjectLocationTopicComputeTimeCursorCall) (response)
375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
376#[serde_with::serde_as]
377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
378pub struct ComputeTimeCursorResponse {
379    /// 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).
380    pub cursor: Option<Cursor>,
381}
382
383impl common::ResponseResult for ComputeTimeCursorResponse {}
384
385/// A cursor that describes the position of a message within a topic partition.
386///
387/// This type is not used in any activity, and only used as *part* of another schema.
388///
389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
390#[serde_with::serde_as]
391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
392pub struct Cursor {
393    /// The offset of a message within a topic partition. Must be greater than or equal 0.
394    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
395    pub offset: Option<i64>,
396}
397
398impl common::Part for Cursor {}
399
400/// The settings for a subscription's message delivery.
401///
402/// This type is not used in any activity, and only used as *part* of another schema.
403///
404#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
405#[serde_with::serde_as]
406#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
407pub struct DeliveryConfig {
408    /// The DeliveryRequirement for this subscription.
409    #[serde(rename = "deliveryRequirement")]
410    pub delivery_requirement: Option<String>,
411}
412
413impl common::Part for DeliveryConfig {}
414
415/// 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); }
416///
417/// # Activities
418///
419/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
420/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
421///
422/// * [projects locations operations cancel admin](AdminProjectLocationOperationCancelCall) (response)
423/// * [projects locations operations delete admin](AdminProjectLocationOperationDeleteCall) (response)
424/// * [projects locations reservations delete admin](AdminProjectLocationReservationDeleteCall) (response)
425/// * [projects locations subscriptions delete admin](AdminProjectLocationSubscriptionDeleteCall) (response)
426/// * [projects locations topics delete admin](AdminProjectLocationTopicDeleteCall) (response)
427#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
428#[serde_with::serde_as]
429#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
430pub struct Empty {
431    _never_set: Option<bool>,
432}
433
434impl common::ResponseResult for Empty {}
435
436/// Configuration for a Pub/Sub Lite subscription that writes messages to a destination. User subscriber clients must not connect to this subscription.
437///
438/// This type is not used in any activity, and only used as *part* of another schema.
439///
440#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
441#[serde_with::serde_as]
442#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
443pub struct ExportConfig {
444    /// Output only. The current state of the export, which may be different to the desired state due to errors. This field is output only.
445    #[serde(rename = "currentState")]
446    pub current_state: Option<String>,
447    /// 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.
448    #[serde(rename = "deadLetterTopic")]
449    pub dead_letter_topic: Option<String>,
450    /// The desired state of this export. Setting this to values other than `ACTIVE` and `PAUSED` will result in an error.
451    #[serde(rename = "desiredState")]
452    pub desired_state: Option<String>,
453    /// Messages are automatically written from the Pub/Sub Lite topic associated with this subscription to a Pub/Sub topic.
454    #[serde(rename = "pubsubConfig")]
455    pub pubsub_config: Option<PubSubConfig>,
456}
457
458impl common::Part for ExportConfig {}
459
460/// The response message for Operations.ListOperations.
461///
462/// # Activities
463///
464/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
465/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
466///
467/// * [projects locations operations list admin](AdminProjectLocationOperationListCall) (response)
468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
469#[serde_with::serde_as]
470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
471pub struct ListOperationsResponse {
472    /// The standard List next-page token.
473    #[serde(rename = "nextPageToken")]
474    pub next_page_token: Option<String>,
475    /// A list of operations that matches the specified filter in the request.
476    pub operations: Option<Vec<Operation>>,
477    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
478    pub unreachable: Option<Vec<String>>,
479}
480
481impl common::ResponseResult for ListOperationsResponse {}
482
483/// Response for ListPartitionCursors
484///
485/// # Activities
486///
487/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
488/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
489///
490/// * [projects locations subscriptions cursors list cursor](CursorProjectLocationSubscriptionCursorListCall) (response)
491#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
492#[serde_with::serde_as]
493#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
494pub struct ListPartitionCursorsResponse {
495    /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
496    #[serde(rename = "nextPageToken")]
497    pub next_page_token: Option<String>,
498    /// The partition cursors from this request.
499    #[serde(rename = "partitionCursors")]
500    pub partition_cursors: Option<Vec<PartitionCursor>>,
501}
502
503impl common::ResponseResult for ListPartitionCursorsResponse {}
504
505/// Response for ListReservationTopics.
506///
507/// # Activities
508///
509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
511///
512/// * [projects locations reservations topics list admin](AdminProjectLocationReservationTopicListCall) (response)
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct ListReservationTopicsResponse {
517    /// 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.
518    #[serde(rename = "nextPageToken")]
519    pub next_page_token: Option<String>,
520    /// The names of topics attached to the reservation. The order of the topics is unspecified.
521    pub topics: Option<Vec<String>>,
522}
523
524impl common::ResponseResult for ListReservationTopicsResponse {}
525
526/// Response for ListReservations.
527///
528/// # Activities
529///
530/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
531/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
532///
533/// * [projects locations reservations list admin](AdminProjectLocationReservationListCall) (response)
534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
535#[serde_with::serde_as]
536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
537pub struct ListReservationsResponse {
538    /// 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.
539    #[serde(rename = "nextPageToken")]
540    pub next_page_token: Option<String>,
541    /// The list of reservation in the requested parent. The order of the reservations is unspecified.
542    pub reservations: Option<Vec<Reservation>>,
543}
544
545impl common::ResponseResult for ListReservationsResponse {}
546
547/// Response for ListSubscriptions.
548///
549/// # Activities
550///
551/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
552/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
553///
554/// * [projects locations subscriptions list admin](AdminProjectLocationSubscriptionListCall) (response)
555#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
556#[serde_with::serde_as]
557#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
558pub struct ListSubscriptionsResponse {
559    /// 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.
560    #[serde(rename = "nextPageToken")]
561    pub next_page_token: Option<String>,
562    /// The list of subscriptions in the requested parent. The order of the subscriptions is unspecified.
563    pub subscriptions: Option<Vec<Subscription>>,
564}
565
566impl common::ResponseResult for ListSubscriptionsResponse {}
567
568/// Response for ListTopicSubscriptions.
569///
570/// # Activities
571///
572/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
573/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
574///
575/// * [projects locations topics subscriptions list admin](AdminProjectLocationTopicSubscriptionListCall) (response)
576#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
577#[serde_with::serde_as]
578#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
579pub struct ListTopicSubscriptionsResponse {
580    /// 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.
581    #[serde(rename = "nextPageToken")]
582    pub next_page_token: Option<String>,
583    /// The names of subscriptions attached to the topic. The order of the subscriptions is unspecified.
584    pub subscriptions: Option<Vec<String>>,
585}
586
587impl common::ResponseResult for ListTopicSubscriptionsResponse {}
588
589/// Response for ListTopics.
590///
591/// # Activities
592///
593/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
594/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
595///
596/// * [projects locations topics list admin](AdminProjectLocationTopicListCall) (response)
597#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
598#[serde_with::serde_as]
599#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
600pub struct ListTopicsResponse {
601    /// 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.
602    #[serde(rename = "nextPageToken")]
603    pub next_page_token: Option<String>,
604    /// The list of topic in the requested parent. The order of the topics is unspecified.
605    pub topics: Option<Vec<Topic>>,
606}
607
608impl common::ResponseResult for ListTopicsResponse {}
609
610/// This resource represents a long-running operation that is the result of a network API call.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [projects locations operations get admin](AdminProjectLocationOperationGetCall) (response)
618/// * [projects locations subscriptions seek admin](AdminProjectLocationSubscriptionSeekCall) (response)
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct Operation {
623    /// 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.
624    pub done: Option<bool>,
625    /// The error result of the operation in case of failure or cancellation.
626    pub error: Option<Status>,
627    /// 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.
628    pub metadata: Option<HashMap<String, serde_json::Value>>,
629    /// 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}`.
630    pub name: Option<String>,
631    /// 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`.
632    pub response: Option<HashMap<String, serde_json::Value>>,
633}
634
635impl common::ResponseResult for Operation {}
636
637/// The settings for a topic's partitions.
638///
639/// This type is not used in any activity, and only used as *part* of another schema.
640///
641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
642#[serde_with::serde_as]
643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
644pub struct PartitionConfig {
645    /// The capacity configuration.
646    pub capacity: Option<Capacity>,
647    /// 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
648    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
649    pub count: Option<i64>,
650    /// 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].
651    pub scale: Option<i32>,
652}
653
654impl common::Part for PartitionConfig {}
655
656/// A pair of a Cursor and the partition it is for.
657///
658/// This type is not used in any activity, and only used as *part* of another schema.
659///
660#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
661#[serde_with::serde_as]
662#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
663pub struct PartitionCursor {
664    /// The value of the cursor.
665    pub cursor: Option<Cursor>,
666    /// The partition this is for.
667    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
668    pub partition: Option<i64>,
669}
670
671impl common::Part for PartitionCursor {}
672
673/// Configuration for exporting to a Pub/Sub topic.
674///
675/// This type is not used in any activity, and only used as *part* of another schema.
676///
677#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
678#[serde_with::serde_as]
679#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
680pub struct PubSubConfig {
681    /// The name of the Pub/Sub topic. Structured like: projects/{project_number}/topics/{topic_id}. The topic may be changed.
682    pub topic: Option<String>,
683}
684
685impl common::Part for PubSubConfig {}
686
687/// Metadata about a reservation resource.
688///
689/// # Activities
690///
691/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
692/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
693///
694/// * [projects locations reservations create admin](AdminProjectLocationReservationCreateCall) (request|response)
695/// * [projects locations reservations get admin](AdminProjectLocationReservationGetCall) (response)
696/// * [projects locations reservations patch admin](AdminProjectLocationReservationPatchCall) (request|response)
697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
698#[serde_with::serde_as]
699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
700pub struct Reservation {
701    /// The name of the reservation. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
702    pub name: Option<String>,
703    /// 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.
704    #[serde(rename = "throughputCapacity")]
705    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
706    pub throughput_capacity: Option<i64>,
707}
708
709impl common::RequestValue for Reservation {}
710impl common::ResponseResult for Reservation {}
711
712/// The settings for this topic's Reservation usage.
713///
714/// This type is not used in any activity, and only used as *part* of another schema.
715///
716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
717#[serde_with::serde_as]
718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
719pub struct ReservationConfig {
720    /// The Reservation to use for this topic's throughput capacity. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
721    #[serde(rename = "throughputReservation")]
722    pub throughput_reservation: Option<String>,
723}
724
725impl common::Part for ReservationConfig {}
726
727/// The settings for a topic's message retention.
728///
729/// This type is not used in any activity, and only used as *part* of another schema.
730///
731#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
732#[serde_with::serde_as]
733#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
734pub struct RetentionConfig {
735    /// 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`.
736    #[serde(rename = "perPartitionBytes")]
737    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
738    pub per_partition_bytes: Option<i64>,
739    /// 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`.
740    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
741    pub period: Option<chrono::Duration>,
742}
743
744impl common::Part for RetentionConfig {}
745
746/// Request for SeekSubscription.
747///
748/// # Activities
749///
750/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
751/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
752///
753/// * [projects locations subscriptions seek admin](AdminProjectLocationSubscriptionSeekCall) (request)
754#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
755#[serde_with::serde_as]
756#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
757pub struct SeekSubscriptionRequest {
758    /// Seek to a named position with respect to the message backlog.
759    #[serde(rename = "namedTarget")]
760    pub named_target: Option<String>,
761    /// 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.
762    #[serde(rename = "timeTarget")]
763    pub time_target: Option<TimeTarget>,
764}
765
766impl common::RequestValue for SeekSubscriptionRequest {}
767
768/// 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).
769///
770/// This type is not used in any activity, and only used as *part* of another schema.
771///
772#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
773#[serde_with::serde_as]
774#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
775pub struct Status {
776    /// The status code, which should be an enum value of google.rpc.Code.
777    pub code: Option<i32>,
778    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
779    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
780    /// 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.
781    pub message: Option<String>,
782}
783
784impl common::Part for Status {}
785
786/// Metadata about a subscription resource.
787///
788/// # Activities
789///
790/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
791/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
792///
793/// * [projects locations subscriptions create admin](AdminProjectLocationSubscriptionCreateCall) (request|response)
794/// * [projects locations subscriptions get admin](AdminProjectLocationSubscriptionGetCall) (response)
795/// * [projects locations subscriptions patch admin](AdminProjectLocationSubscriptionPatchCall) (request|response)
796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
797#[serde_with::serde_as]
798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
799pub struct Subscription {
800    /// The settings for this subscription's message delivery.
801    #[serde(rename = "deliveryConfig")]
802    pub delivery_config: Option<DeliveryConfig>,
803    /// If present, messages are automatically written from the Pub/Sub Lite topic associated with this subscription to a destination.
804    #[serde(rename = "exportConfig")]
805    pub export_config: Option<ExportConfig>,
806    /// The name of the subscription. Structured like: projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
807    pub name: Option<String>,
808    /// The name of the topic this subscription is attached to. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
809    pub topic: Option<String>,
810}
811
812impl common::RequestValue for Subscription {}
813impl common::ResponseResult for Subscription {}
814
815/// A target publish or event time. Can be used for seeking to or retrieving the corresponding cursor.
816///
817/// This type is not used in any activity, and only used as *part* of another schema.
818///
819#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
820#[serde_with::serde_as]
821#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
822pub struct TimeTarget {
823    /// 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.
824    #[serde(rename = "eventTime")]
825    pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
826    /// 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`.
827    #[serde(rename = "publishTime")]
828    pub publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
829}
830
831impl common::Part for TimeTarget {}
832
833/// Metadata about a topic resource.
834///
835/// # Activities
836///
837/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
838/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
839///
840/// * [projects locations topics create admin](AdminProjectLocationTopicCreateCall) (request|response)
841/// * [projects locations topics get admin](AdminProjectLocationTopicGetCall) (response)
842/// * [projects locations topics patch admin](AdminProjectLocationTopicPatchCall) (request|response)
843#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
844#[serde_with::serde_as]
845#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
846pub struct Topic {
847    /// The name of the topic. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
848    pub name: Option<String>,
849    /// The settings for this topic's partitions.
850    #[serde(rename = "partitionConfig")]
851    pub partition_config: Option<PartitionConfig>,
852    /// The settings for this topic's Reservation usage.
853    #[serde(rename = "reservationConfig")]
854    pub reservation_config: Option<ReservationConfig>,
855    /// The settings for this topic's message retention.
856    #[serde(rename = "retentionConfig")]
857    pub retention_config: Option<RetentionConfig>,
858}
859
860impl common::RequestValue for Topic {}
861impl common::ResponseResult for Topic {}
862
863/// Response for GetTopicPartitions.
864///
865/// # Activities
866///
867/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
868/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
869///
870/// * [projects locations topics get partitions admin](AdminProjectLocationTopicGetPartitionCall) (response)
871#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
872#[serde_with::serde_as]
873#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
874pub struct TopicPartitions {
875    /// The number of partitions in the topic.
876    #[serde(rename = "partitionCount")]
877    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
878    pub partition_count: Option<i64>,
879}
880
881impl common::ResponseResult for TopicPartitions {}
882
883// ###################
884// MethodBuilders ###
885// #################
886
887/// A builder providing access to all methods supported on *admin* resources.
888/// It is not used directly, but through the [`PubsubLite`] hub.
889///
890/// # Example
891///
892/// Instantiate a resource builder
893///
894/// ```test_harness,no_run
895/// extern crate hyper;
896/// extern crate hyper_rustls;
897/// extern crate google_pubsublite1 as pubsublite1;
898///
899/// # async fn dox() {
900/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
901///
902/// let secret: yup_oauth2::ApplicationSecret = Default::default();
903/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
904///     .with_native_roots()
905///     .unwrap()
906///     .https_only()
907///     .enable_http2()
908///     .build();
909///
910/// let executor = hyper_util::rt::TokioExecutor::new();
911/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
912///     secret,
913///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
914///     yup_oauth2::client::CustomHyperClientBuilder::from(
915///         hyper_util::client::legacy::Client::builder(executor).build(connector),
916///     ),
917/// ).build().await.unwrap();
918///
919/// let client = hyper_util::client::legacy::Client::builder(
920///     hyper_util::rt::TokioExecutor::new()
921/// )
922/// .build(
923///     hyper_rustls::HttpsConnectorBuilder::new()
924///         .with_native_roots()
925///         .unwrap()
926///         .https_or_http()
927///         .enable_http2()
928///         .build()
929/// );
930/// let mut hub = PubsubLite::new(client, auth);
931/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
932/// // 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(...)`
933/// // to build up your call.
934/// let rb = hub.admin();
935/// # }
936/// ```
937pub struct AdminMethods<'a, C>
938where
939    C: 'a,
940{
941    hub: &'a PubsubLite<C>,
942}
943
944impl<'a, C> common::MethodsBuilder for AdminMethods<'a, C> {}
945
946impl<'a, C> AdminMethods<'a, C> {
947    /// Create a builder to help you perform the following task:
948    ///
949    /// 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`.
950    ///
951    /// # Arguments
952    ///
953    /// * `request` - No description provided.
954    /// * `name` - The name of the operation resource to be cancelled.
955    pub fn projects_locations_operations_cancel(
956        &self,
957        request: CancelOperationRequest,
958        name: &str,
959    ) -> AdminProjectLocationOperationCancelCall<'a, C> {
960        AdminProjectLocationOperationCancelCall {
961            hub: self.hub,
962            _request: request,
963            _name: name.to_string(),
964            _delegate: Default::default(),
965            _additional_params: Default::default(),
966            _scopes: Default::default(),
967        }
968    }
969
970    /// Create a builder to help you perform the following task:
971    ///
972    /// 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`.
973    ///
974    /// # Arguments
975    ///
976    /// * `name` - The name of the operation resource to be deleted.
977    pub fn projects_locations_operations_delete(
978        &self,
979        name: &str,
980    ) -> AdminProjectLocationOperationDeleteCall<'a, C> {
981        AdminProjectLocationOperationDeleteCall {
982            hub: self.hub,
983            _name: name.to_string(),
984            _delegate: Default::default(),
985            _additional_params: Default::default(),
986            _scopes: Default::default(),
987        }
988    }
989
990    /// Create a builder to help you perform the following task:
991    ///
992    /// 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.
993    ///
994    /// # Arguments
995    ///
996    /// * `name` - The name of the operation resource.
997    pub fn projects_locations_operations_get(
998        &self,
999        name: &str,
1000    ) -> AdminProjectLocationOperationGetCall<'a, C> {
1001        AdminProjectLocationOperationGetCall {
1002            hub: self.hub,
1003            _name: name.to_string(),
1004            _delegate: Default::default(),
1005            _additional_params: Default::default(),
1006            _scopes: Default::default(),
1007        }
1008    }
1009
1010    /// Create a builder to help you perform the following task:
1011    ///
1012    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1013    ///
1014    /// # Arguments
1015    ///
1016    /// * `name` - The name of the operation's parent resource.
1017    pub fn projects_locations_operations_list(
1018        &self,
1019        name: &str,
1020    ) -> AdminProjectLocationOperationListCall<'a, C> {
1021        AdminProjectLocationOperationListCall {
1022            hub: self.hub,
1023            _name: name.to_string(),
1024            _return_partial_success: Default::default(),
1025            _page_token: Default::default(),
1026            _page_size: Default::default(),
1027            _filter: Default::default(),
1028            _delegate: Default::default(),
1029            _additional_params: Default::default(),
1030            _scopes: Default::default(),
1031        }
1032    }
1033
1034    /// Create a builder to help you perform the following task:
1035    ///
1036    /// Lists the topics attached to the specified reservation.
1037    ///
1038    /// # Arguments
1039    ///
1040    /// * `name` - Required. The name of the reservation whose topics to list. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1041    pub fn projects_locations_reservations_topics_list(
1042        &self,
1043        name: &str,
1044    ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
1045        AdminProjectLocationReservationTopicListCall {
1046            hub: self.hub,
1047            _name: name.to_string(),
1048            _page_token: Default::default(),
1049            _page_size: Default::default(),
1050            _delegate: Default::default(),
1051            _additional_params: Default::default(),
1052            _scopes: Default::default(),
1053        }
1054    }
1055
1056    /// Create a builder to help you perform the following task:
1057    ///
1058    /// Creates a new reservation.
1059    ///
1060    /// # Arguments
1061    ///
1062    /// * `request` - No description provided.
1063    /// * `parent` - Required. The parent location in which to create the reservation. Structured like `projects/{project_number}/locations/{location}`.
1064    pub fn projects_locations_reservations_create(
1065        &self,
1066        request: Reservation,
1067        parent: &str,
1068    ) -> AdminProjectLocationReservationCreateCall<'a, C> {
1069        AdminProjectLocationReservationCreateCall {
1070            hub: self.hub,
1071            _request: request,
1072            _parent: parent.to_string(),
1073            _reservation_id: Default::default(),
1074            _delegate: Default::default(),
1075            _additional_params: Default::default(),
1076            _scopes: Default::default(),
1077        }
1078    }
1079
1080    /// Create a builder to help you perform the following task:
1081    ///
1082    /// Deletes the specified reservation.
1083    ///
1084    /// # Arguments
1085    ///
1086    /// * `name` - Required. The name of the reservation to delete. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1087    pub fn projects_locations_reservations_delete(
1088        &self,
1089        name: &str,
1090    ) -> AdminProjectLocationReservationDeleteCall<'a, C> {
1091        AdminProjectLocationReservationDeleteCall {
1092            hub: self.hub,
1093            _name: name.to_string(),
1094            _delegate: Default::default(),
1095            _additional_params: Default::default(),
1096            _scopes: Default::default(),
1097        }
1098    }
1099
1100    /// Create a builder to help you perform the following task:
1101    ///
1102    /// Returns the reservation configuration.
1103    ///
1104    /// # Arguments
1105    ///
1106    /// * `name` - Required. The name of the reservation whose configuration to return. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1107    pub fn projects_locations_reservations_get(
1108        &self,
1109        name: &str,
1110    ) -> AdminProjectLocationReservationGetCall<'a, C> {
1111        AdminProjectLocationReservationGetCall {
1112            hub: self.hub,
1113            _name: name.to_string(),
1114            _delegate: Default::default(),
1115            _additional_params: Default::default(),
1116            _scopes: Default::default(),
1117        }
1118    }
1119
1120    /// Create a builder to help you perform the following task:
1121    ///
1122    /// Returns the list of reservations for the given project.
1123    ///
1124    /// # Arguments
1125    ///
1126    /// * `parent` - Required. The parent whose reservations are to be listed. Structured like `projects/{project_number}/locations/{location}`.
1127    pub fn projects_locations_reservations_list(
1128        &self,
1129        parent: &str,
1130    ) -> AdminProjectLocationReservationListCall<'a, C> {
1131        AdminProjectLocationReservationListCall {
1132            hub: self.hub,
1133            _parent: parent.to_string(),
1134            _page_token: Default::default(),
1135            _page_size: Default::default(),
1136            _delegate: Default::default(),
1137            _additional_params: Default::default(),
1138            _scopes: Default::default(),
1139        }
1140    }
1141
1142    /// Create a builder to help you perform the following task:
1143    ///
1144    /// Updates properties of the specified reservation.
1145    ///
1146    /// # Arguments
1147    ///
1148    /// * `request` - No description provided.
1149    /// * `name` - The name of the reservation. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
1150    pub fn projects_locations_reservations_patch(
1151        &self,
1152        request: Reservation,
1153        name: &str,
1154    ) -> AdminProjectLocationReservationPatchCall<'a, C> {
1155        AdminProjectLocationReservationPatchCall {
1156            hub: self.hub,
1157            _request: request,
1158            _name: name.to_string(),
1159            _update_mask: 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    /// Creates a new subscription.
1169    ///
1170    /// # Arguments
1171    ///
1172    /// * `request` - No description provided.
1173    /// * `parent` - Required. The parent location in which to create the subscription. Structured like `projects/{project_number}/locations/{location}`.
1174    pub fn projects_locations_subscriptions_create(
1175        &self,
1176        request: Subscription,
1177        parent: &str,
1178    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
1179        AdminProjectLocationSubscriptionCreateCall {
1180            hub: self.hub,
1181            _request: request,
1182            _parent: parent.to_string(),
1183            _subscription_id: Default::default(),
1184            _skip_backlog: Default::default(),
1185            _delegate: Default::default(),
1186            _additional_params: Default::default(),
1187            _scopes: Default::default(),
1188        }
1189    }
1190
1191    /// Create a builder to help you perform the following task:
1192    ///
1193    /// Deletes the specified subscription.
1194    ///
1195    /// # Arguments
1196    ///
1197    /// * `name` - Required. The name of the subscription to delete.
1198    pub fn projects_locations_subscriptions_delete(
1199        &self,
1200        name: &str,
1201    ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
1202        AdminProjectLocationSubscriptionDeleteCall {
1203            hub: self.hub,
1204            _name: name.to_string(),
1205            _delegate: Default::default(),
1206            _additional_params: Default::default(),
1207            _scopes: Default::default(),
1208        }
1209    }
1210
1211    /// Create a builder to help you perform the following task:
1212    ///
1213    /// Returns the subscription configuration.
1214    ///
1215    /// # Arguments
1216    ///
1217    /// * `name` - Required. The name of the subscription whose configuration to return.
1218    pub fn projects_locations_subscriptions_get(
1219        &self,
1220        name: &str,
1221    ) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
1222        AdminProjectLocationSubscriptionGetCall {
1223            hub: self.hub,
1224            _name: name.to_string(),
1225            _delegate: Default::default(),
1226            _additional_params: Default::default(),
1227            _scopes: Default::default(),
1228        }
1229    }
1230
1231    /// Create a builder to help you perform the following task:
1232    ///
1233    /// Returns the list of subscriptions for the given project.
1234    ///
1235    /// # Arguments
1236    ///
1237    /// * `parent` - Required. The parent whose subscriptions are to be listed. Structured like `projects/{project_number}/locations/{location}`.
1238    pub fn projects_locations_subscriptions_list(
1239        &self,
1240        parent: &str,
1241    ) -> AdminProjectLocationSubscriptionListCall<'a, C> {
1242        AdminProjectLocationSubscriptionListCall {
1243            hub: self.hub,
1244            _parent: parent.to_string(),
1245            _page_token: Default::default(),
1246            _page_size: Default::default(),
1247            _delegate: Default::default(),
1248            _additional_params: Default::default(),
1249            _scopes: Default::default(),
1250        }
1251    }
1252
1253    /// Create a builder to help you perform the following task:
1254    ///
1255    /// Updates properties of the specified subscription.
1256    ///
1257    /// # Arguments
1258    ///
1259    /// * `request` - No description provided.
1260    /// * `name` - The name of the subscription. Structured like: projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
1261    pub fn projects_locations_subscriptions_patch(
1262        &self,
1263        request: Subscription,
1264        name: &str,
1265    ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
1266        AdminProjectLocationSubscriptionPatchCall {
1267            hub: self.hub,
1268            _request: request,
1269            _name: name.to_string(),
1270            _update_mask: Default::default(),
1271            _delegate: Default::default(),
1272            _additional_params: Default::default(),
1273            _scopes: Default::default(),
1274        }
1275    }
1276
1277    /// Create a builder to help you perform the following task:
1278    ///
1279    /// 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.
1280    ///
1281    /// # Arguments
1282    ///
1283    /// * `request` - No description provided.
1284    /// * `name` - Required. The name of the subscription to seek.
1285    pub fn projects_locations_subscriptions_seek(
1286        &self,
1287        request: SeekSubscriptionRequest,
1288        name: &str,
1289    ) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
1290        AdminProjectLocationSubscriptionSeekCall {
1291            hub: self.hub,
1292            _request: request,
1293            _name: name.to_string(),
1294            _delegate: Default::default(),
1295            _additional_params: Default::default(),
1296            _scopes: Default::default(),
1297        }
1298    }
1299
1300    /// Create a builder to help you perform the following task:
1301    ///
1302    /// Lists the subscriptions attached to the specified topic.
1303    ///
1304    /// # Arguments
1305    ///
1306    /// * `name` - Required. The name of the topic whose subscriptions to list.
1307    pub fn projects_locations_topics_subscriptions_list(
1308        &self,
1309        name: &str,
1310    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
1311        AdminProjectLocationTopicSubscriptionListCall {
1312            hub: self.hub,
1313            _name: name.to_string(),
1314            _page_token: Default::default(),
1315            _page_size: Default::default(),
1316            _delegate: Default::default(),
1317            _additional_params: Default::default(),
1318            _scopes: Default::default(),
1319        }
1320    }
1321
1322    /// Create a builder to help you perform the following task:
1323    ///
1324    /// Creates a new topic.
1325    ///
1326    /// # Arguments
1327    ///
1328    /// * `request` - No description provided.
1329    /// * `parent` - Required. The parent location in which to create the topic. Structured like `projects/{project_number}/locations/{location}`.
1330    pub fn projects_locations_topics_create(
1331        &self,
1332        request: Topic,
1333        parent: &str,
1334    ) -> AdminProjectLocationTopicCreateCall<'a, C> {
1335        AdminProjectLocationTopicCreateCall {
1336            hub: self.hub,
1337            _request: request,
1338            _parent: parent.to_string(),
1339            _topic_id: Default::default(),
1340            _delegate: Default::default(),
1341            _additional_params: Default::default(),
1342            _scopes: Default::default(),
1343        }
1344    }
1345
1346    /// Create a builder to help you perform the following task:
1347    ///
1348    /// Deletes the specified topic.
1349    ///
1350    /// # Arguments
1351    ///
1352    /// * `name` - Required. The name of the topic to delete.
1353    pub fn projects_locations_topics_delete(
1354        &self,
1355        name: &str,
1356    ) -> AdminProjectLocationTopicDeleteCall<'a, C> {
1357        AdminProjectLocationTopicDeleteCall {
1358            hub: self.hub,
1359            _name: name.to_string(),
1360            _delegate: Default::default(),
1361            _additional_params: Default::default(),
1362            _scopes: Default::default(),
1363        }
1364    }
1365
1366    /// Create a builder to help you perform the following task:
1367    ///
1368    /// Returns the topic configuration.
1369    ///
1370    /// # Arguments
1371    ///
1372    /// * `name` - Required. The name of the topic whose configuration to return.
1373    pub fn projects_locations_topics_get(
1374        &self,
1375        name: &str,
1376    ) -> AdminProjectLocationTopicGetCall<'a, C> {
1377        AdminProjectLocationTopicGetCall {
1378            hub: self.hub,
1379            _name: name.to_string(),
1380            _delegate: Default::default(),
1381            _additional_params: Default::default(),
1382            _scopes: Default::default(),
1383        }
1384    }
1385
1386    /// Create a builder to help you perform the following task:
1387    ///
1388    /// Returns the partition information for the requested topic.
1389    ///
1390    /// # Arguments
1391    ///
1392    /// * `name` - Required. The topic whose partition information to return.
1393    pub fn projects_locations_topics_get_partitions(
1394        &self,
1395        name: &str,
1396    ) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
1397        AdminProjectLocationTopicGetPartitionCall {
1398            hub: self.hub,
1399            _name: name.to_string(),
1400            _delegate: Default::default(),
1401            _additional_params: Default::default(),
1402            _scopes: Default::default(),
1403        }
1404    }
1405
1406    /// Create a builder to help you perform the following task:
1407    ///
1408    /// Returns the list of topics for the given project.
1409    ///
1410    /// # Arguments
1411    ///
1412    /// * `parent` - Required. The parent whose topics are to be listed. Structured like `projects/{project_number}/locations/{location}`.
1413    pub fn projects_locations_topics_list(
1414        &self,
1415        parent: &str,
1416    ) -> AdminProjectLocationTopicListCall<'a, C> {
1417        AdminProjectLocationTopicListCall {
1418            hub: self.hub,
1419            _parent: parent.to_string(),
1420            _page_token: Default::default(),
1421            _page_size: Default::default(),
1422            _delegate: Default::default(),
1423            _additional_params: Default::default(),
1424            _scopes: Default::default(),
1425        }
1426    }
1427
1428    /// Create a builder to help you perform the following task:
1429    ///
1430    /// Updates properties of the specified topic.
1431    ///
1432    /// # Arguments
1433    ///
1434    /// * `request` - No description provided.
1435    /// * `name` - The name of the topic. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
1436    pub fn projects_locations_topics_patch(
1437        &self,
1438        request: Topic,
1439        name: &str,
1440    ) -> AdminProjectLocationTopicPatchCall<'a, C> {
1441        AdminProjectLocationTopicPatchCall {
1442            hub: self.hub,
1443            _request: request,
1444            _name: name.to_string(),
1445            _update_mask: Default::default(),
1446            _delegate: Default::default(),
1447            _additional_params: Default::default(),
1448            _scopes: Default::default(),
1449        }
1450    }
1451}
1452
1453/// A builder providing access to all methods supported on *cursor* resources.
1454/// It is not used directly, but through the [`PubsubLite`] hub.
1455///
1456/// # Example
1457///
1458/// Instantiate a resource builder
1459///
1460/// ```test_harness,no_run
1461/// extern crate hyper;
1462/// extern crate hyper_rustls;
1463/// extern crate google_pubsublite1 as pubsublite1;
1464///
1465/// # async fn dox() {
1466/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1467///
1468/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1469/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1470///     .with_native_roots()
1471///     .unwrap()
1472///     .https_only()
1473///     .enable_http2()
1474///     .build();
1475///
1476/// let executor = hyper_util::rt::TokioExecutor::new();
1477/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1478///     secret,
1479///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1480///     yup_oauth2::client::CustomHyperClientBuilder::from(
1481///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1482///     ),
1483/// ).build().await.unwrap();
1484///
1485/// let client = hyper_util::client::legacy::Client::builder(
1486///     hyper_util::rt::TokioExecutor::new()
1487/// )
1488/// .build(
1489///     hyper_rustls::HttpsConnectorBuilder::new()
1490///         .with_native_roots()
1491///         .unwrap()
1492///         .https_or_http()
1493///         .enable_http2()
1494///         .build()
1495/// );
1496/// let mut hub = PubsubLite::new(client, auth);
1497/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1498/// // like `projects_locations_subscriptions_commit_cursor(...)` and `projects_locations_subscriptions_cursors_list(...)`
1499/// // to build up your call.
1500/// let rb = hub.cursor();
1501/// # }
1502/// ```
1503pub struct CursorMethods<'a, C>
1504where
1505    C: 'a,
1506{
1507    hub: &'a PubsubLite<C>,
1508}
1509
1510impl<'a, C> common::MethodsBuilder for CursorMethods<'a, C> {}
1511
1512impl<'a, C> CursorMethods<'a, C> {
1513    /// Create a builder to help you perform the following task:
1514    ///
1515    /// Returns all committed cursor information for a subscription.
1516    ///
1517    /// # Arguments
1518    ///
1519    /// * `parent` - Required. The subscription for which to retrieve cursors. Structured like `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
1520    pub fn projects_locations_subscriptions_cursors_list(
1521        &self,
1522        parent: &str,
1523    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
1524        CursorProjectLocationSubscriptionCursorListCall {
1525            hub: self.hub,
1526            _parent: parent.to_string(),
1527            _page_token: Default::default(),
1528            _page_size: Default::default(),
1529            _delegate: Default::default(),
1530            _additional_params: Default::default(),
1531            _scopes: Default::default(),
1532        }
1533    }
1534
1535    /// Create a builder to help you perform the following task:
1536    ///
1537    /// Updates the committed cursor.
1538    ///
1539    /// # Arguments
1540    ///
1541    /// * `request` - No description provided.
1542    /// * `subscription` - The subscription for which to update the cursor.
1543    pub fn projects_locations_subscriptions_commit_cursor(
1544        &self,
1545        request: CommitCursorRequest,
1546        subscription: &str,
1547    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
1548        CursorProjectLocationSubscriptionCommitCursorCall {
1549            hub: self.hub,
1550            _request: request,
1551            _subscription: subscription.to_string(),
1552            _delegate: Default::default(),
1553            _additional_params: Default::default(),
1554            _scopes: Default::default(),
1555        }
1556    }
1557}
1558
1559/// A builder providing access to all methods supported on *topicStat* resources.
1560/// It is not used directly, but through the [`PubsubLite`] hub.
1561///
1562/// # Example
1563///
1564/// Instantiate a resource builder
1565///
1566/// ```test_harness,no_run
1567/// extern crate hyper;
1568/// extern crate hyper_rustls;
1569/// extern crate google_pubsublite1 as pubsublite1;
1570///
1571/// # async fn dox() {
1572/// use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1573///
1574/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1575/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1576///     .with_native_roots()
1577///     .unwrap()
1578///     .https_only()
1579///     .enable_http2()
1580///     .build();
1581///
1582/// let executor = hyper_util::rt::TokioExecutor::new();
1583/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1584///     secret,
1585///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1586///     yup_oauth2::client::CustomHyperClientBuilder::from(
1587///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1588///     ),
1589/// ).build().await.unwrap();
1590///
1591/// let client = hyper_util::client::legacy::Client::builder(
1592///     hyper_util::rt::TokioExecutor::new()
1593/// )
1594/// .build(
1595///     hyper_rustls::HttpsConnectorBuilder::new()
1596///         .with_native_roots()
1597///         .unwrap()
1598///         .https_or_http()
1599///         .enable_http2()
1600///         .build()
1601/// );
1602/// let mut hub = PubsubLite::new(client, auth);
1603/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1604/// // like `projects_locations_topics_compute_head_cursor(...)`, `projects_locations_topics_compute_message_stats(...)` and `projects_locations_topics_compute_time_cursor(...)`
1605/// // to build up your call.
1606/// let rb = hub.topic_stats();
1607/// # }
1608/// ```
1609pub struct TopicStatMethods<'a, C>
1610where
1611    C: 'a,
1612{
1613    hub: &'a PubsubLite<C>,
1614}
1615
1616impl<'a, C> common::MethodsBuilder for TopicStatMethods<'a, C> {}
1617
1618impl<'a, C> TopicStatMethods<'a, C> {
1619    /// Create a builder to help you perform the following task:
1620    ///
1621    /// 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.
1622    ///
1623    /// # Arguments
1624    ///
1625    /// * `request` - No description provided.
1626    /// * `topic` - Required. The topic for which we should compute the head cursor.
1627    pub fn projects_locations_topics_compute_head_cursor(
1628        &self,
1629        request: ComputeHeadCursorRequest,
1630        topic: &str,
1631    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
1632        TopicStatProjectLocationTopicComputeHeadCursorCall {
1633            hub: self.hub,
1634            _request: request,
1635            _topic: topic.to_string(),
1636            _delegate: Default::default(),
1637            _additional_params: Default::default(),
1638            _scopes: Default::default(),
1639        }
1640    }
1641
1642    /// Create a builder to help you perform the following task:
1643    ///
1644    /// Compute statistics about a range of messages in a given topic and partition.
1645    ///
1646    /// # Arguments
1647    ///
1648    /// * `request` - No description provided.
1649    /// * `topic` - Required. The topic for which we should compute message stats.
1650    pub fn projects_locations_topics_compute_message_stats(
1651        &self,
1652        request: ComputeMessageStatsRequest,
1653        topic: &str,
1654    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
1655        TopicStatProjectLocationTopicComputeMessageStatCall {
1656            hub: self.hub,
1657            _request: request,
1658            _topic: topic.to_string(),
1659            _delegate: Default::default(),
1660            _additional_params: Default::default(),
1661            _scopes: Default::default(),
1662        }
1663    }
1664
1665    /// Create a builder to help you perform the following task:
1666    ///
1667    /// Compute the corresponding cursor for a publish or event time in a topic partition.
1668    ///
1669    /// # Arguments
1670    ///
1671    /// * `request` - No description provided.
1672    /// * `topic` - Required. The topic for which we should compute the cursor.
1673    pub fn projects_locations_topics_compute_time_cursor(
1674        &self,
1675        request: ComputeTimeCursorRequest,
1676        topic: &str,
1677    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
1678        TopicStatProjectLocationTopicComputeTimeCursorCall {
1679            hub: self.hub,
1680            _request: request,
1681            _topic: topic.to_string(),
1682            _delegate: Default::default(),
1683            _additional_params: Default::default(),
1684            _scopes: Default::default(),
1685        }
1686    }
1687}
1688
1689// ###################
1690// CallBuilders   ###
1691// #################
1692
1693/// 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`.
1694///
1695/// A builder for the *projects.locations.operations.cancel* method supported by a *admin* resource.
1696/// It is not used directly, but through a [`AdminMethods`] instance.
1697///
1698/// # Example
1699///
1700/// Instantiate a resource method builder
1701///
1702/// ```test_harness,no_run
1703/// # extern crate hyper;
1704/// # extern crate hyper_rustls;
1705/// # extern crate google_pubsublite1 as pubsublite1;
1706/// use pubsublite1::api::CancelOperationRequest;
1707/// # async fn dox() {
1708/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1709///
1710/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1711/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1712/// #     .with_native_roots()
1713/// #     .unwrap()
1714/// #     .https_only()
1715/// #     .enable_http2()
1716/// #     .build();
1717///
1718/// # let executor = hyper_util::rt::TokioExecutor::new();
1719/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1720/// #     secret,
1721/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1722/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1723/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1724/// #     ),
1725/// # ).build().await.unwrap();
1726///
1727/// # let client = hyper_util::client::legacy::Client::builder(
1728/// #     hyper_util::rt::TokioExecutor::new()
1729/// # )
1730/// # .build(
1731/// #     hyper_rustls::HttpsConnectorBuilder::new()
1732/// #         .with_native_roots()
1733/// #         .unwrap()
1734/// #         .https_or_http()
1735/// #         .enable_http2()
1736/// #         .build()
1737/// # );
1738/// # let mut hub = PubsubLite::new(client, auth);
1739/// // As the method needs a request, you would usually fill it with the desired information
1740/// // into the respective structure. Some of the parts shown here might not be applicable !
1741/// // Values shown here are possibly random and not representative !
1742/// let mut req = CancelOperationRequest::default();
1743///
1744/// // You can configure optional parameters by calling the respective setters at will, and
1745/// // execute the final call using `doit()`.
1746/// // Values shown here are possibly random and not representative !
1747/// let result = hub.admin().projects_locations_operations_cancel(req, "name")
1748///              .doit().await;
1749/// # }
1750/// ```
1751pub struct AdminProjectLocationOperationCancelCall<'a, C>
1752where
1753    C: 'a,
1754{
1755    hub: &'a PubsubLite<C>,
1756    _request: CancelOperationRequest,
1757    _name: String,
1758    _delegate: Option<&'a mut dyn common::Delegate>,
1759    _additional_params: HashMap<String, String>,
1760    _scopes: BTreeSet<String>,
1761}
1762
1763impl<'a, C> common::CallBuilder for AdminProjectLocationOperationCancelCall<'a, C> {}
1764
1765impl<'a, C> AdminProjectLocationOperationCancelCall<'a, C>
1766where
1767    C: common::Connector,
1768{
1769    /// Perform the operation you have build so far.
1770    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1771        use std::borrow::Cow;
1772        use std::io::{Read, Seek};
1773
1774        use common::{url::Params, ToParts};
1775        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1776
1777        let mut dd = common::DefaultDelegate;
1778        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1779        dlg.begin(common::MethodInfo {
1780            id: "pubsublite.admin.projects.locations.operations.cancel",
1781            http_method: hyper::Method::POST,
1782        });
1783
1784        for &field in ["alt", "name"].iter() {
1785            if self._additional_params.contains_key(field) {
1786                dlg.finished(false);
1787                return Err(common::Error::FieldClash(field));
1788            }
1789        }
1790
1791        let mut params = Params::with_capacity(4 + self._additional_params.len());
1792        params.push("name", self._name);
1793
1794        params.extend(self._additional_params.iter());
1795
1796        params.push("alt", "json");
1797        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}:cancel";
1798        if self._scopes.is_empty() {
1799            self._scopes
1800                .insert(Scope::CloudPlatform.as_ref().to_string());
1801        }
1802
1803        #[allow(clippy::single_element_loop)]
1804        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1805            url = params.uri_replacement(url, param_name, find_this, true);
1806        }
1807        {
1808            let to_remove = ["name"];
1809            params.remove_params(&to_remove);
1810        }
1811
1812        let url = params.parse_with_url(&url);
1813
1814        let mut json_mime_type = mime::APPLICATION_JSON;
1815        let mut request_value_reader = {
1816            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1817            common::remove_json_null_values(&mut value);
1818            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1819            serde_json::to_writer(&mut dst, &value).unwrap();
1820            dst
1821        };
1822        let request_size = request_value_reader
1823            .seek(std::io::SeekFrom::End(0))
1824            .unwrap();
1825        request_value_reader
1826            .seek(std::io::SeekFrom::Start(0))
1827            .unwrap();
1828
1829        loop {
1830            let token = match self
1831                .hub
1832                .auth
1833                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1834                .await
1835            {
1836                Ok(token) => token,
1837                Err(e) => match dlg.token(e) {
1838                    Ok(token) => token,
1839                    Err(e) => {
1840                        dlg.finished(false);
1841                        return Err(common::Error::MissingToken(e));
1842                    }
1843                },
1844            };
1845            request_value_reader
1846                .seek(std::io::SeekFrom::Start(0))
1847                .unwrap();
1848            let mut req_result = {
1849                let client = &self.hub.client;
1850                dlg.pre_request();
1851                let mut req_builder = hyper::Request::builder()
1852                    .method(hyper::Method::POST)
1853                    .uri(url.as_str())
1854                    .header(USER_AGENT, self.hub._user_agent.clone());
1855
1856                if let Some(token) = token.as_ref() {
1857                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1858                }
1859
1860                let request = req_builder
1861                    .header(CONTENT_TYPE, json_mime_type.to_string())
1862                    .header(CONTENT_LENGTH, request_size as u64)
1863                    .body(common::to_body(
1864                        request_value_reader.get_ref().clone().into(),
1865                    ));
1866
1867                client.request(request.unwrap()).await
1868            };
1869
1870            match req_result {
1871                Err(err) => {
1872                    if let common::Retry::After(d) = dlg.http_error(&err) {
1873                        sleep(d).await;
1874                        continue;
1875                    }
1876                    dlg.finished(false);
1877                    return Err(common::Error::HttpError(err));
1878                }
1879                Ok(res) => {
1880                    let (mut parts, body) = res.into_parts();
1881                    let mut body = common::Body::new(body);
1882                    if !parts.status.is_success() {
1883                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1884                        let error = serde_json::from_str(&common::to_string(&bytes));
1885                        let response = common::to_response(parts, bytes.into());
1886
1887                        if let common::Retry::After(d) =
1888                            dlg.http_failure(&response, error.as_ref().ok())
1889                        {
1890                            sleep(d).await;
1891                            continue;
1892                        }
1893
1894                        dlg.finished(false);
1895
1896                        return Err(match error {
1897                            Ok(value) => common::Error::BadRequest(value),
1898                            _ => common::Error::Failure(response),
1899                        });
1900                    }
1901                    let response = {
1902                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1903                        let encoded = common::to_string(&bytes);
1904                        match serde_json::from_str(&encoded) {
1905                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1906                            Err(error) => {
1907                                dlg.response_json_decode_error(&encoded, &error);
1908                                return Err(common::Error::JsonDecodeError(
1909                                    encoded.to_string(),
1910                                    error,
1911                                ));
1912                            }
1913                        }
1914                    };
1915
1916                    dlg.finished(true);
1917                    return Ok(response);
1918                }
1919            }
1920        }
1921    }
1922
1923    ///
1924    /// Sets the *request* property to the given value.
1925    ///
1926    /// Even though the property as already been set when instantiating this call,
1927    /// we provide this method for API completeness.
1928    pub fn request(
1929        mut self,
1930        new_value: CancelOperationRequest,
1931    ) -> AdminProjectLocationOperationCancelCall<'a, C> {
1932        self._request = new_value;
1933        self
1934    }
1935    /// The name of the operation resource to be cancelled.
1936    ///
1937    /// Sets the *name* path property to the given value.
1938    ///
1939    /// Even though the property as already been set when instantiating this call,
1940    /// we provide this method for API completeness.
1941    pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationCancelCall<'a, C> {
1942        self._name = new_value.to_string();
1943        self
1944    }
1945    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1946    /// while executing the actual API request.
1947    ///
1948    /// ````text
1949    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1950    /// ````
1951    ///
1952    /// Sets the *delegate* property to the given value.
1953    pub fn delegate(
1954        mut self,
1955        new_value: &'a mut dyn common::Delegate,
1956    ) -> AdminProjectLocationOperationCancelCall<'a, C> {
1957        self._delegate = Some(new_value);
1958        self
1959    }
1960
1961    /// Set any additional parameter of the query string used in the request.
1962    /// It should be used to set parameters which are not yet available through their own
1963    /// setters.
1964    ///
1965    /// Please note that this method must not be used to set any of the known parameters
1966    /// which have their own setter method. If done anyway, the request will fail.
1967    ///
1968    /// # Additional Parameters
1969    ///
1970    /// * *$.xgafv* (query-string) - V1 error format.
1971    /// * *access_token* (query-string) - OAuth access token.
1972    /// * *alt* (query-string) - Data format for response.
1973    /// * *callback* (query-string) - JSONP
1974    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1975    /// * *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.
1976    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1977    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1978    /// * *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.
1979    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1980    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1981    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationCancelCall<'a, C>
1982    where
1983        T: AsRef<str>,
1984    {
1985        self._additional_params
1986            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1987        self
1988    }
1989
1990    /// Identifies the authorization scope for the method you are building.
1991    ///
1992    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1993    /// [`Scope::CloudPlatform`].
1994    ///
1995    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1996    /// tokens for more than one scope.
1997    ///
1998    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1999    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2000    /// sufficient, a read-write scope will do as well.
2001    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationCancelCall<'a, C>
2002    where
2003        St: AsRef<str>,
2004    {
2005        self._scopes.insert(String::from(scope.as_ref()));
2006        self
2007    }
2008    /// Identifies the authorization scope(s) for the method you are building.
2009    ///
2010    /// See [`Self::add_scope()`] for details.
2011    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationCancelCall<'a, C>
2012    where
2013        I: IntoIterator<Item = St>,
2014        St: AsRef<str>,
2015    {
2016        self._scopes
2017            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2018        self
2019    }
2020
2021    /// Removes all scopes, and no default scope will be used either.
2022    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2023    /// for details).
2024    pub fn clear_scopes(mut self) -> AdminProjectLocationOperationCancelCall<'a, C> {
2025        self._scopes.clear();
2026        self
2027    }
2028}
2029
2030/// 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`.
2031///
2032/// A builder for the *projects.locations.operations.delete* method supported by a *admin* resource.
2033/// It is not used directly, but through a [`AdminMethods`] instance.
2034///
2035/// # Example
2036///
2037/// Instantiate a resource method builder
2038///
2039/// ```test_harness,no_run
2040/// # extern crate hyper;
2041/// # extern crate hyper_rustls;
2042/// # extern crate google_pubsublite1 as pubsublite1;
2043/// # async fn dox() {
2044/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2045///
2046/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2047/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2048/// #     .with_native_roots()
2049/// #     .unwrap()
2050/// #     .https_only()
2051/// #     .enable_http2()
2052/// #     .build();
2053///
2054/// # let executor = hyper_util::rt::TokioExecutor::new();
2055/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2056/// #     secret,
2057/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2058/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2059/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2060/// #     ),
2061/// # ).build().await.unwrap();
2062///
2063/// # let client = hyper_util::client::legacy::Client::builder(
2064/// #     hyper_util::rt::TokioExecutor::new()
2065/// # )
2066/// # .build(
2067/// #     hyper_rustls::HttpsConnectorBuilder::new()
2068/// #         .with_native_roots()
2069/// #         .unwrap()
2070/// #         .https_or_http()
2071/// #         .enable_http2()
2072/// #         .build()
2073/// # );
2074/// # let mut hub = PubsubLite::new(client, auth);
2075/// // You can configure optional parameters by calling the respective setters at will, and
2076/// // execute the final call using `doit()`.
2077/// // Values shown here are possibly random and not representative !
2078/// let result = hub.admin().projects_locations_operations_delete("name")
2079///              .doit().await;
2080/// # }
2081/// ```
2082pub struct AdminProjectLocationOperationDeleteCall<'a, C>
2083where
2084    C: 'a,
2085{
2086    hub: &'a PubsubLite<C>,
2087    _name: String,
2088    _delegate: Option<&'a mut dyn common::Delegate>,
2089    _additional_params: HashMap<String, String>,
2090    _scopes: BTreeSet<String>,
2091}
2092
2093impl<'a, C> common::CallBuilder for AdminProjectLocationOperationDeleteCall<'a, C> {}
2094
2095impl<'a, C> AdminProjectLocationOperationDeleteCall<'a, C>
2096where
2097    C: common::Connector,
2098{
2099    /// Perform the operation you have build so far.
2100    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2101        use std::borrow::Cow;
2102        use std::io::{Read, Seek};
2103
2104        use common::{url::Params, ToParts};
2105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2106
2107        let mut dd = common::DefaultDelegate;
2108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2109        dlg.begin(common::MethodInfo {
2110            id: "pubsublite.admin.projects.locations.operations.delete",
2111            http_method: hyper::Method::DELETE,
2112        });
2113
2114        for &field in ["alt", "name"].iter() {
2115            if self._additional_params.contains_key(field) {
2116                dlg.finished(false);
2117                return Err(common::Error::FieldClash(field));
2118            }
2119        }
2120
2121        let mut params = Params::with_capacity(3 + self._additional_params.len());
2122        params.push("name", self._name);
2123
2124        params.extend(self._additional_params.iter());
2125
2126        params.push("alt", "json");
2127        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
2128        if self._scopes.is_empty() {
2129            self._scopes
2130                .insert(Scope::CloudPlatform.as_ref().to_string());
2131        }
2132
2133        #[allow(clippy::single_element_loop)]
2134        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2135            url = params.uri_replacement(url, param_name, find_this, true);
2136        }
2137        {
2138            let to_remove = ["name"];
2139            params.remove_params(&to_remove);
2140        }
2141
2142        let url = params.parse_with_url(&url);
2143
2144        loop {
2145            let token = match self
2146                .hub
2147                .auth
2148                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2149                .await
2150            {
2151                Ok(token) => token,
2152                Err(e) => match dlg.token(e) {
2153                    Ok(token) => token,
2154                    Err(e) => {
2155                        dlg.finished(false);
2156                        return Err(common::Error::MissingToken(e));
2157                    }
2158                },
2159            };
2160            let mut req_result = {
2161                let client = &self.hub.client;
2162                dlg.pre_request();
2163                let mut req_builder = hyper::Request::builder()
2164                    .method(hyper::Method::DELETE)
2165                    .uri(url.as_str())
2166                    .header(USER_AGENT, self.hub._user_agent.clone());
2167
2168                if let Some(token) = token.as_ref() {
2169                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2170                }
2171
2172                let request = req_builder
2173                    .header(CONTENT_LENGTH, 0_u64)
2174                    .body(common::to_body::<String>(None));
2175
2176                client.request(request.unwrap()).await
2177            };
2178
2179            match req_result {
2180                Err(err) => {
2181                    if let common::Retry::After(d) = dlg.http_error(&err) {
2182                        sleep(d).await;
2183                        continue;
2184                    }
2185                    dlg.finished(false);
2186                    return Err(common::Error::HttpError(err));
2187                }
2188                Ok(res) => {
2189                    let (mut parts, body) = res.into_parts();
2190                    let mut body = common::Body::new(body);
2191                    if !parts.status.is_success() {
2192                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2193                        let error = serde_json::from_str(&common::to_string(&bytes));
2194                        let response = common::to_response(parts, bytes.into());
2195
2196                        if let common::Retry::After(d) =
2197                            dlg.http_failure(&response, error.as_ref().ok())
2198                        {
2199                            sleep(d).await;
2200                            continue;
2201                        }
2202
2203                        dlg.finished(false);
2204
2205                        return Err(match error {
2206                            Ok(value) => common::Error::BadRequest(value),
2207                            _ => common::Error::Failure(response),
2208                        });
2209                    }
2210                    let response = {
2211                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2212                        let encoded = common::to_string(&bytes);
2213                        match serde_json::from_str(&encoded) {
2214                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2215                            Err(error) => {
2216                                dlg.response_json_decode_error(&encoded, &error);
2217                                return Err(common::Error::JsonDecodeError(
2218                                    encoded.to_string(),
2219                                    error,
2220                                ));
2221                            }
2222                        }
2223                    };
2224
2225                    dlg.finished(true);
2226                    return Ok(response);
2227                }
2228            }
2229        }
2230    }
2231
2232    /// The name of the operation resource to be deleted.
2233    ///
2234    /// Sets the *name* path property to the given value.
2235    ///
2236    /// Even though the property as already been set when instantiating this call,
2237    /// we provide this method for API completeness.
2238    pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationDeleteCall<'a, C> {
2239        self._name = new_value.to_string();
2240        self
2241    }
2242    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2243    /// while executing the actual API request.
2244    ///
2245    /// ````text
2246    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2247    /// ````
2248    ///
2249    /// Sets the *delegate* property to the given value.
2250    pub fn delegate(
2251        mut self,
2252        new_value: &'a mut dyn common::Delegate,
2253    ) -> AdminProjectLocationOperationDeleteCall<'a, C> {
2254        self._delegate = Some(new_value);
2255        self
2256    }
2257
2258    /// Set any additional parameter of the query string used in the request.
2259    /// It should be used to set parameters which are not yet available through their own
2260    /// setters.
2261    ///
2262    /// Please note that this method must not be used to set any of the known parameters
2263    /// which have their own setter method. If done anyway, the request will fail.
2264    ///
2265    /// # Additional Parameters
2266    ///
2267    /// * *$.xgafv* (query-string) - V1 error format.
2268    /// * *access_token* (query-string) - OAuth access token.
2269    /// * *alt* (query-string) - Data format for response.
2270    /// * *callback* (query-string) - JSONP
2271    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2272    /// * *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.
2273    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2274    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2275    /// * *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.
2276    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2277    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2278    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationDeleteCall<'a, C>
2279    where
2280        T: AsRef<str>,
2281    {
2282        self._additional_params
2283            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2284        self
2285    }
2286
2287    /// Identifies the authorization scope for the method you are building.
2288    ///
2289    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2290    /// [`Scope::CloudPlatform`].
2291    ///
2292    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2293    /// tokens for more than one scope.
2294    ///
2295    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2296    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2297    /// sufficient, a read-write scope will do as well.
2298    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationDeleteCall<'a, C>
2299    where
2300        St: AsRef<str>,
2301    {
2302        self._scopes.insert(String::from(scope.as_ref()));
2303        self
2304    }
2305    /// Identifies the authorization scope(s) for the method you are building.
2306    ///
2307    /// See [`Self::add_scope()`] for details.
2308    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationDeleteCall<'a, C>
2309    where
2310        I: IntoIterator<Item = St>,
2311        St: AsRef<str>,
2312    {
2313        self._scopes
2314            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2315        self
2316    }
2317
2318    /// Removes all scopes, and no default scope will be used either.
2319    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2320    /// for details).
2321    pub fn clear_scopes(mut self) -> AdminProjectLocationOperationDeleteCall<'a, C> {
2322        self._scopes.clear();
2323        self
2324    }
2325}
2326
2327/// 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.
2328///
2329/// A builder for the *projects.locations.operations.get* method supported by a *admin* resource.
2330/// It is not used directly, but through a [`AdminMethods`] instance.
2331///
2332/// # Example
2333///
2334/// Instantiate a resource method builder
2335///
2336/// ```test_harness,no_run
2337/// # extern crate hyper;
2338/// # extern crate hyper_rustls;
2339/// # extern crate google_pubsublite1 as pubsublite1;
2340/// # async fn dox() {
2341/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2342///
2343/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2344/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2345/// #     .with_native_roots()
2346/// #     .unwrap()
2347/// #     .https_only()
2348/// #     .enable_http2()
2349/// #     .build();
2350///
2351/// # let executor = hyper_util::rt::TokioExecutor::new();
2352/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2353/// #     secret,
2354/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2355/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2356/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2357/// #     ),
2358/// # ).build().await.unwrap();
2359///
2360/// # let client = hyper_util::client::legacy::Client::builder(
2361/// #     hyper_util::rt::TokioExecutor::new()
2362/// # )
2363/// # .build(
2364/// #     hyper_rustls::HttpsConnectorBuilder::new()
2365/// #         .with_native_roots()
2366/// #         .unwrap()
2367/// #         .https_or_http()
2368/// #         .enable_http2()
2369/// #         .build()
2370/// # );
2371/// # let mut hub = PubsubLite::new(client, auth);
2372/// // You can configure optional parameters by calling the respective setters at will, and
2373/// // execute the final call using `doit()`.
2374/// // Values shown here are possibly random and not representative !
2375/// let result = hub.admin().projects_locations_operations_get("name")
2376///              .doit().await;
2377/// # }
2378/// ```
2379pub struct AdminProjectLocationOperationGetCall<'a, C>
2380where
2381    C: 'a,
2382{
2383    hub: &'a PubsubLite<C>,
2384    _name: String,
2385    _delegate: Option<&'a mut dyn common::Delegate>,
2386    _additional_params: HashMap<String, String>,
2387    _scopes: BTreeSet<String>,
2388}
2389
2390impl<'a, C> common::CallBuilder for AdminProjectLocationOperationGetCall<'a, C> {}
2391
2392impl<'a, C> AdminProjectLocationOperationGetCall<'a, C>
2393where
2394    C: common::Connector,
2395{
2396    /// Perform the operation you have build so far.
2397    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2398        use std::borrow::Cow;
2399        use std::io::{Read, Seek};
2400
2401        use common::{url::Params, ToParts};
2402        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2403
2404        let mut dd = common::DefaultDelegate;
2405        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2406        dlg.begin(common::MethodInfo {
2407            id: "pubsublite.admin.projects.locations.operations.get",
2408            http_method: hyper::Method::GET,
2409        });
2410
2411        for &field in ["alt", "name"].iter() {
2412            if self._additional_params.contains_key(field) {
2413                dlg.finished(false);
2414                return Err(common::Error::FieldClash(field));
2415            }
2416        }
2417
2418        let mut params = Params::with_capacity(3 + self._additional_params.len());
2419        params.push("name", self._name);
2420
2421        params.extend(self._additional_params.iter());
2422
2423        params.push("alt", "json");
2424        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
2425        if self._scopes.is_empty() {
2426            self._scopes
2427                .insert(Scope::CloudPlatform.as_ref().to_string());
2428        }
2429
2430        #[allow(clippy::single_element_loop)]
2431        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2432            url = params.uri_replacement(url, param_name, find_this, true);
2433        }
2434        {
2435            let to_remove = ["name"];
2436            params.remove_params(&to_remove);
2437        }
2438
2439        let url = params.parse_with_url(&url);
2440
2441        loop {
2442            let token = match self
2443                .hub
2444                .auth
2445                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2446                .await
2447            {
2448                Ok(token) => token,
2449                Err(e) => match dlg.token(e) {
2450                    Ok(token) => token,
2451                    Err(e) => {
2452                        dlg.finished(false);
2453                        return Err(common::Error::MissingToken(e));
2454                    }
2455                },
2456            };
2457            let mut req_result = {
2458                let client = &self.hub.client;
2459                dlg.pre_request();
2460                let mut req_builder = hyper::Request::builder()
2461                    .method(hyper::Method::GET)
2462                    .uri(url.as_str())
2463                    .header(USER_AGENT, self.hub._user_agent.clone());
2464
2465                if let Some(token) = token.as_ref() {
2466                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2467                }
2468
2469                let request = req_builder
2470                    .header(CONTENT_LENGTH, 0_u64)
2471                    .body(common::to_body::<String>(None));
2472
2473                client.request(request.unwrap()).await
2474            };
2475
2476            match req_result {
2477                Err(err) => {
2478                    if let common::Retry::After(d) = dlg.http_error(&err) {
2479                        sleep(d).await;
2480                        continue;
2481                    }
2482                    dlg.finished(false);
2483                    return Err(common::Error::HttpError(err));
2484                }
2485                Ok(res) => {
2486                    let (mut parts, body) = res.into_parts();
2487                    let mut body = common::Body::new(body);
2488                    if !parts.status.is_success() {
2489                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2490                        let error = serde_json::from_str(&common::to_string(&bytes));
2491                        let response = common::to_response(parts, bytes.into());
2492
2493                        if let common::Retry::After(d) =
2494                            dlg.http_failure(&response, error.as_ref().ok())
2495                        {
2496                            sleep(d).await;
2497                            continue;
2498                        }
2499
2500                        dlg.finished(false);
2501
2502                        return Err(match error {
2503                            Ok(value) => common::Error::BadRequest(value),
2504                            _ => common::Error::Failure(response),
2505                        });
2506                    }
2507                    let response = {
2508                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2509                        let encoded = common::to_string(&bytes);
2510                        match serde_json::from_str(&encoded) {
2511                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2512                            Err(error) => {
2513                                dlg.response_json_decode_error(&encoded, &error);
2514                                return Err(common::Error::JsonDecodeError(
2515                                    encoded.to_string(),
2516                                    error,
2517                                ));
2518                            }
2519                        }
2520                    };
2521
2522                    dlg.finished(true);
2523                    return Ok(response);
2524                }
2525            }
2526        }
2527    }
2528
2529    /// The name of the operation resource.
2530    ///
2531    /// Sets the *name* path property to the given value.
2532    ///
2533    /// Even though the property as already been set when instantiating this call,
2534    /// we provide this method for API completeness.
2535    pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationGetCall<'a, C> {
2536        self._name = new_value.to_string();
2537        self
2538    }
2539    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2540    /// while executing the actual API request.
2541    ///
2542    /// ````text
2543    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2544    /// ````
2545    ///
2546    /// Sets the *delegate* property to the given value.
2547    pub fn delegate(
2548        mut self,
2549        new_value: &'a mut dyn common::Delegate,
2550    ) -> AdminProjectLocationOperationGetCall<'a, C> {
2551        self._delegate = Some(new_value);
2552        self
2553    }
2554
2555    /// Set any additional parameter of the query string used in the request.
2556    /// It should be used to set parameters which are not yet available through their own
2557    /// setters.
2558    ///
2559    /// Please note that this method must not be used to set any of the known parameters
2560    /// which have their own setter method. If done anyway, the request will fail.
2561    ///
2562    /// # Additional Parameters
2563    ///
2564    /// * *$.xgafv* (query-string) - V1 error format.
2565    /// * *access_token* (query-string) - OAuth access token.
2566    /// * *alt* (query-string) - Data format for response.
2567    /// * *callback* (query-string) - JSONP
2568    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2569    /// * *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.
2570    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2571    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2572    /// * *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.
2573    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2574    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2575    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationGetCall<'a, C>
2576    where
2577        T: AsRef<str>,
2578    {
2579        self._additional_params
2580            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2581        self
2582    }
2583
2584    /// Identifies the authorization scope for the method you are building.
2585    ///
2586    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2587    /// [`Scope::CloudPlatform`].
2588    ///
2589    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2590    /// tokens for more than one scope.
2591    ///
2592    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2593    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2594    /// sufficient, a read-write scope will do as well.
2595    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationGetCall<'a, C>
2596    where
2597        St: AsRef<str>,
2598    {
2599        self._scopes.insert(String::from(scope.as_ref()));
2600        self
2601    }
2602    /// Identifies the authorization scope(s) for the method you are building.
2603    ///
2604    /// See [`Self::add_scope()`] for details.
2605    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationGetCall<'a, C>
2606    where
2607        I: IntoIterator<Item = St>,
2608        St: AsRef<str>,
2609    {
2610        self._scopes
2611            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2612        self
2613    }
2614
2615    /// Removes all scopes, and no default scope will be used either.
2616    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2617    /// for details).
2618    pub fn clear_scopes(mut self) -> AdminProjectLocationOperationGetCall<'a, C> {
2619        self._scopes.clear();
2620        self
2621    }
2622}
2623
2624/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2625///
2626/// A builder for the *projects.locations.operations.list* method supported by a *admin* resource.
2627/// It is not used directly, but through a [`AdminMethods`] instance.
2628///
2629/// # Example
2630///
2631/// Instantiate a resource method builder
2632///
2633/// ```test_harness,no_run
2634/// # extern crate hyper;
2635/// # extern crate hyper_rustls;
2636/// # extern crate google_pubsublite1 as pubsublite1;
2637/// # async fn dox() {
2638/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2639///
2640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2641/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2642/// #     .with_native_roots()
2643/// #     .unwrap()
2644/// #     .https_only()
2645/// #     .enable_http2()
2646/// #     .build();
2647///
2648/// # let executor = hyper_util::rt::TokioExecutor::new();
2649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2650/// #     secret,
2651/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2652/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2653/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2654/// #     ),
2655/// # ).build().await.unwrap();
2656///
2657/// # let client = hyper_util::client::legacy::Client::builder(
2658/// #     hyper_util::rt::TokioExecutor::new()
2659/// # )
2660/// # .build(
2661/// #     hyper_rustls::HttpsConnectorBuilder::new()
2662/// #         .with_native_roots()
2663/// #         .unwrap()
2664/// #         .https_or_http()
2665/// #         .enable_http2()
2666/// #         .build()
2667/// # );
2668/// # let mut hub = PubsubLite::new(client, auth);
2669/// // You can configure optional parameters by calling the respective setters at will, and
2670/// // execute the final call using `doit()`.
2671/// // Values shown here are possibly random and not representative !
2672/// let result = hub.admin().projects_locations_operations_list("name")
2673///              .return_partial_success(false)
2674///              .page_token("amet.")
2675///              .page_size(-59)
2676///              .filter("amet.")
2677///              .doit().await;
2678/// # }
2679/// ```
2680pub struct AdminProjectLocationOperationListCall<'a, C>
2681where
2682    C: 'a,
2683{
2684    hub: &'a PubsubLite<C>,
2685    _name: String,
2686    _return_partial_success: Option<bool>,
2687    _page_token: Option<String>,
2688    _page_size: Option<i32>,
2689    _filter: Option<String>,
2690    _delegate: Option<&'a mut dyn common::Delegate>,
2691    _additional_params: HashMap<String, String>,
2692    _scopes: BTreeSet<String>,
2693}
2694
2695impl<'a, C> common::CallBuilder for AdminProjectLocationOperationListCall<'a, C> {}
2696
2697impl<'a, C> AdminProjectLocationOperationListCall<'a, C>
2698where
2699    C: common::Connector,
2700{
2701    /// Perform the operation you have build so far.
2702    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
2703        use std::borrow::Cow;
2704        use std::io::{Read, Seek};
2705
2706        use common::{url::Params, ToParts};
2707        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2708
2709        let mut dd = common::DefaultDelegate;
2710        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2711        dlg.begin(common::MethodInfo {
2712            id: "pubsublite.admin.projects.locations.operations.list",
2713            http_method: hyper::Method::GET,
2714        });
2715
2716        for &field in [
2717            "alt",
2718            "name",
2719            "returnPartialSuccess",
2720            "pageToken",
2721            "pageSize",
2722            "filter",
2723        ]
2724        .iter()
2725        {
2726            if self._additional_params.contains_key(field) {
2727                dlg.finished(false);
2728                return Err(common::Error::FieldClash(field));
2729            }
2730        }
2731
2732        let mut params = Params::with_capacity(7 + self._additional_params.len());
2733        params.push("name", self._name);
2734        if let Some(value) = self._return_partial_success.as_ref() {
2735            params.push("returnPartialSuccess", value.to_string());
2736        }
2737        if let Some(value) = self._page_token.as_ref() {
2738            params.push("pageToken", value);
2739        }
2740        if let Some(value) = self._page_size.as_ref() {
2741            params.push("pageSize", value.to_string());
2742        }
2743        if let Some(value) = self._filter.as_ref() {
2744            params.push("filter", value);
2745        }
2746
2747        params.extend(self._additional_params.iter());
2748
2749        params.push("alt", "json");
2750        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/operations";
2751        if self._scopes.is_empty() {
2752            self._scopes
2753                .insert(Scope::CloudPlatform.as_ref().to_string());
2754        }
2755
2756        #[allow(clippy::single_element_loop)]
2757        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2758            url = params.uri_replacement(url, param_name, find_this, true);
2759        }
2760        {
2761            let to_remove = ["name"];
2762            params.remove_params(&to_remove);
2763        }
2764
2765        let url = params.parse_with_url(&url);
2766
2767        loop {
2768            let token = match self
2769                .hub
2770                .auth
2771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2772                .await
2773            {
2774                Ok(token) => token,
2775                Err(e) => match dlg.token(e) {
2776                    Ok(token) => token,
2777                    Err(e) => {
2778                        dlg.finished(false);
2779                        return Err(common::Error::MissingToken(e));
2780                    }
2781                },
2782            };
2783            let mut req_result = {
2784                let client = &self.hub.client;
2785                dlg.pre_request();
2786                let mut req_builder = hyper::Request::builder()
2787                    .method(hyper::Method::GET)
2788                    .uri(url.as_str())
2789                    .header(USER_AGENT, self.hub._user_agent.clone());
2790
2791                if let Some(token) = token.as_ref() {
2792                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2793                }
2794
2795                let request = req_builder
2796                    .header(CONTENT_LENGTH, 0_u64)
2797                    .body(common::to_body::<String>(None));
2798
2799                client.request(request.unwrap()).await
2800            };
2801
2802            match req_result {
2803                Err(err) => {
2804                    if let common::Retry::After(d) = dlg.http_error(&err) {
2805                        sleep(d).await;
2806                        continue;
2807                    }
2808                    dlg.finished(false);
2809                    return Err(common::Error::HttpError(err));
2810                }
2811                Ok(res) => {
2812                    let (mut parts, body) = res.into_parts();
2813                    let mut body = common::Body::new(body);
2814                    if !parts.status.is_success() {
2815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2816                        let error = serde_json::from_str(&common::to_string(&bytes));
2817                        let response = common::to_response(parts, bytes.into());
2818
2819                        if let common::Retry::After(d) =
2820                            dlg.http_failure(&response, error.as_ref().ok())
2821                        {
2822                            sleep(d).await;
2823                            continue;
2824                        }
2825
2826                        dlg.finished(false);
2827
2828                        return Err(match error {
2829                            Ok(value) => common::Error::BadRequest(value),
2830                            _ => common::Error::Failure(response),
2831                        });
2832                    }
2833                    let response = {
2834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2835                        let encoded = common::to_string(&bytes);
2836                        match serde_json::from_str(&encoded) {
2837                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2838                            Err(error) => {
2839                                dlg.response_json_decode_error(&encoded, &error);
2840                                return Err(common::Error::JsonDecodeError(
2841                                    encoded.to_string(),
2842                                    error,
2843                                ));
2844                            }
2845                        }
2846                    };
2847
2848                    dlg.finished(true);
2849                    return Ok(response);
2850                }
2851            }
2852        }
2853    }
2854
2855    /// The name of the operation's parent resource.
2856    ///
2857    /// Sets the *name* path property to the given value.
2858    ///
2859    /// Even though the property as already been set when instantiating this call,
2860    /// we provide this method for API completeness.
2861    pub fn name(mut self, new_value: &str) -> AdminProjectLocationOperationListCall<'a, C> {
2862        self._name = new_value.to_string();
2863        self
2864    }
2865    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
2866    ///
2867    /// Sets the *return partial success* query property to the given value.
2868    pub fn return_partial_success(
2869        mut self,
2870        new_value: bool,
2871    ) -> AdminProjectLocationOperationListCall<'a, C> {
2872        self._return_partial_success = Some(new_value);
2873        self
2874    }
2875    /// The standard list page token.
2876    ///
2877    /// Sets the *page token* query property to the given value.
2878    pub fn page_token(mut self, new_value: &str) -> AdminProjectLocationOperationListCall<'a, C> {
2879        self._page_token = Some(new_value.to_string());
2880        self
2881    }
2882    /// The standard list page size.
2883    ///
2884    /// Sets the *page size* query property to the given value.
2885    pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationOperationListCall<'a, C> {
2886        self._page_size = Some(new_value);
2887        self
2888    }
2889    /// The standard list filter.
2890    ///
2891    /// Sets the *filter* query property to the given value.
2892    pub fn filter(mut self, new_value: &str) -> AdminProjectLocationOperationListCall<'a, C> {
2893        self._filter = Some(new_value.to_string());
2894        self
2895    }
2896    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2897    /// while executing the actual API request.
2898    ///
2899    /// ````text
2900    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2901    /// ````
2902    ///
2903    /// Sets the *delegate* property to the given value.
2904    pub fn delegate(
2905        mut self,
2906        new_value: &'a mut dyn common::Delegate,
2907    ) -> AdminProjectLocationOperationListCall<'a, C> {
2908        self._delegate = Some(new_value);
2909        self
2910    }
2911
2912    /// Set any additional parameter of the query string used in the request.
2913    /// It should be used to set parameters which are not yet available through their own
2914    /// setters.
2915    ///
2916    /// Please note that this method must not be used to set any of the known parameters
2917    /// which have their own setter method. If done anyway, the request will fail.
2918    ///
2919    /// # Additional Parameters
2920    ///
2921    /// * *$.xgafv* (query-string) - V1 error format.
2922    /// * *access_token* (query-string) - OAuth access token.
2923    /// * *alt* (query-string) - Data format for response.
2924    /// * *callback* (query-string) - JSONP
2925    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2926    /// * *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.
2927    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2928    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2929    /// * *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.
2930    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2931    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2932    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationOperationListCall<'a, C>
2933    where
2934        T: AsRef<str>,
2935    {
2936        self._additional_params
2937            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2938        self
2939    }
2940
2941    /// Identifies the authorization scope for the method you are building.
2942    ///
2943    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2944    /// [`Scope::CloudPlatform`].
2945    ///
2946    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2947    /// tokens for more than one scope.
2948    ///
2949    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2950    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2951    /// sufficient, a read-write scope will do as well.
2952    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationOperationListCall<'a, C>
2953    where
2954        St: AsRef<str>,
2955    {
2956        self._scopes.insert(String::from(scope.as_ref()));
2957        self
2958    }
2959    /// Identifies the authorization scope(s) for the method you are building.
2960    ///
2961    /// See [`Self::add_scope()`] for details.
2962    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationOperationListCall<'a, C>
2963    where
2964        I: IntoIterator<Item = St>,
2965        St: AsRef<str>,
2966    {
2967        self._scopes
2968            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2969        self
2970    }
2971
2972    /// Removes all scopes, and no default scope will be used either.
2973    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2974    /// for details).
2975    pub fn clear_scopes(mut self) -> AdminProjectLocationOperationListCall<'a, C> {
2976        self._scopes.clear();
2977        self
2978    }
2979}
2980
2981/// Lists the topics attached to the specified reservation.
2982///
2983/// A builder for the *projects.locations.reservations.topics.list* method supported by a *admin* resource.
2984/// It is not used directly, but through a [`AdminMethods`] instance.
2985///
2986/// # Example
2987///
2988/// Instantiate a resource method builder
2989///
2990/// ```test_harness,no_run
2991/// # extern crate hyper;
2992/// # extern crate hyper_rustls;
2993/// # extern crate google_pubsublite1 as pubsublite1;
2994/// # async fn dox() {
2995/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2996///
2997/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2998/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2999/// #     .with_native_roots()
3000/// #     .unwrap()
3001/// #     .https_only()
3002/// #     .enable_http2()
3003/// #     .build();
3004///
3005/// # let executor = hyper_util::rt::TokioExecutor::new();
3006/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3007/// #     secret,
3008/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3009/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3010/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3011/// #     ),
3012/// # ).build().await.unwrap();
3013///
3014/// # let client = hyper_util::client::legacy::Client::builder(
3015/// #     hyper_util::rt::TokioExecutor::new()
3016/// # )
3017/// # .build(
3018/// #     hyper_rustls::HttpsConnectorBuilder::new()
3019/// #         .with_native_roots()
3020/// #         .unwrap()
3021/// #         .https_or_http()
3022/// #         .enable_http2()
3023/// #         .build()
3024/// # );
3025/// # let mut hub = PubsubLite::new(client, auth);
3026/// // You can configure optional parameters by calling the respective setters at will, and
3027/// // execute the final call using `doit()`.
3028/// // Values shown here are possibly random and not representative !
3029/// let result = hub.admin().projects_locations_reservations_topics_list("name")
3030///              .page_token("ipsum")
3031///              .page_size(-62)
3032///              .doit().await;
3033/// # }
3034/// ```
3035pub struct AdminProjectLocationReservationTopicListCall<'a, C>
3036where
3037    C: 'a,
3038{
3039    hub: &'a PubsubLite<C>,
3040    _name: String,
3041    _page_token: Option<String>,
3042    _page_size: Option<i32>,
3043    _delegate: Option<&'a mut dyn common::Delegate>,
3044    _additional_params: HashMap<String, String>,
3045    _scopes: BTreeSet<String>,
3046}
3047
3048impl<'a, C> common::CallBuilder for AdminProjectLocationReservationTopicListCall<'a, C> {}
3049
3050impl<'a, C> AdminProjectLocationReservationTopicListCall<'a, C>
3051where
3052    C: common::Connector,
3053{
3054    /// Perform the operation you have build so far.
3055    pub async fn doit(
3056        mut self,
3057    ) -> common::Result<(common::Response, ListReservationTopicsResponse)> {
3058        use std::borrow::Cow;
3059        use std::io::{Read, Seek};
3060
3061        use common::{url::Params, ToParts};
3062        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3063
3064        let mut dd = common::DefaultDelegate;
3065        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3066        dlg.begin(common::MethodInfo {
3067            id: "pubsublite.admin.projects.locations.reservations.topics.list",
3068            http_method: hyper::Method::GET,
3069        });
3070
3071        for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
3072            if self._additional_params.contains_key(field) {
3073                dlg.finished(false);
3074                return Err(common::Error::FieldClash(field));
3075            }
3076        }
3077
3078        let mut params = Params::with_capacity(5 + self._additional_params.len());
3079        params.push("name", self._name);
3080        if let Some(value) = self._page_token.as_ref() {
3081            params.push("pageToken", value);
3082        }
3083        if let Some(value) = self._page_size.as_ref() {
3084            params.push("pageSize", value.to_string());
3085        }
3086
3087        params.extend(self._additional_params.iter());
3088
3089        params.push("alt", "json");
3090        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/topics";
3091        if self._scopes.is_empty() {
3092            self._scopes
3093                .insert(Scope::CloudPlatform.as_ref().to_string());
3094        }
3095
3096        #[allow(clippy::single_element_loop)]
3097        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3098            url = params.uri_replacement(url, param_name, find_this, true);
3099        }
3100        {
3101            let to_remove = ["name"];
3102            params.remove_params(&to_remove);
3103        }
3104
3105        let url = params.parse_with_url(&url);
3106
3107        loop {
3108            let token = match self
3109                .hub
3110                .auth
3111                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3112                .await
3113            {
3114                Ok(token) => token,
3115                Err(e) => match dlg.token(e) {
3116                    Ok(token) => token,
3117                    Err(e) => {
3118                        dlg.finished(false);
3119                        return Err(common::Error::MissingToken(e));
3120                    }
3121                },
3122            };
3123            let mut req_result = {
3124                let client = &self.hub.client;
3125                dlg.pre_request();
3126                let mut req_builder = hyper::Request::builder()
3127                    .method(hyper::Method::GET)
3128                    .uri(url.as_str())
3129                    .header(USER_AGENT, self.hub._user_agent.clone());
3130
3131                if let Some(token) = token.as_ref() {
3132                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3133                }
3134
3135                let request = req_builder
3136                    .header(CONTENT_LENGTH, 0_u64)
3137                    .body(common::to_body::<String>(None));
3138
3139                client.request(request.unwrap()).await
3140            };
3141
3142            match req_result {
3143                Err(err) => {
3144                    if let common::Retry::After(d) = dlg.http_error(&err) {
3145                        sleep(d).await;
3146                        continue;
3147                    }
3148                    dlg.finished(false);
3149                    return Err(common::Error::HttpError(err));
3150                }
3151                Ok(res) => {
3152                    let (mut parts, body) = res.into_parts();
3153                    let mut body = common::Body::new(body);
3154                    if !parts.status.is_success() {
3155                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3156                        let error = serde_json::from_str(&common::to_string(&bytes));
3157                        let response = common::to_response(parts, bytes.into());
3158
3159                        if let common::Retry::After(d) =
3160                            dlg.http_failure(&response, error.as_ref().ok())
3161                        {
3162                            sleep(d).await;
3163                            continue;
3164                        }
3165
3166                        dlg.finished(false);
3167
3168                        return Err(match error {
3169                            Ok(value) => common::Error::BadRequest(value),
3170                            _ => common::Error::Failure(response),
3171                        });
3172                    }
3173                    let response = {
3174                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3175                        let encoded = common::to_string(&bytes);
3176                        match serde_json::from_str(&encoded) {
3177                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3178                            Err(error) => {
3179                                dlg.response_json_decode_error(&encoded, &error);
3180                                return Err(common::Error::JsonDecodeError(
3181                                    encoded.to_string(),
3182                                    error,
3183                                ));
3184                            }
3185                        }
3186                    };
3187
3188                    dlg.finished(true);
3189                    return Ok(response);
3190                }
3191            }
3192        }
3193    }
3194
3195    /// Required. The name of the reservation whose topics to list. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
3196    ///
3197    /// Sets the *name* path property to the given value.
3198    ///
3199    /// Even though the property as already been set when instantiating this call,
3200    /// we provide this method for API completeness.
3201    pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3202        self._name = new_value.to_string();
3203        self
3204    }
3205    /// 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.
3206    ///
3207    /// Sets the *page token* query property to the given value.
3208    pub fn page_token(
3209        mut self,
3210        new_value: &str,
3211    ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3212        self._page_token = Some(new_value.to_string());
3213        self
3214    }
3215    /// 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.
3216    ///
3217    /// Sets the *page size* query property to the given value.
3218    pub fn page_size(
3219        mut self,
3220        new_value: i32,
3221    ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3222        self._page_size = Some(new_value);
3223        self
3224    }
3225    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3226    /// while executing the actual API request.
3227    ///
3228    /// ````text
3229    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3230    /// ````
3231    ///
3232    /// Sets the *delegate* property to the given value.
3233    pub fn delegate(
3234        mut self,
3235        new_value: &'a mut dyn common::Delegate,
3236    ) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3237        self._delegate = Some(new_value);
3238        self
3239    }
3240
3241    /// Set any additional parameter of the query string used in the request.
3242    /// It should be used to set parameters which are not yet available through their own
3243    /// setters.
3244    ///
3245    /// Please note that this method must not be used to set any of the known parameters
3246    /// which have their own setter method. If done anyway, the request will fail.
3247    ///
3248    /// # Additional Parameters
3249    ///
3250    /// * *$.xgafv* (query-string) - V1 error format.
3251    /// * *access_token* (query-string) - OAuth access token.
3252    /// * *alt* (query-string) - Data format for response.
3253    /// * *callback* (query-string) - JSONP
3254    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3255    /// * *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.
3256    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3257    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3258    /// * *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.
3259    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3260    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3261    pub fn param<T>(
3262        mut self,
3263        name: T,
3264        value: T,
3265    ) -> AdminProjectLocationReservationTopicListCall<'a, C>
3266    where
3267        T: AsRef<str>,
3268    {
3269        self._additional_params
3270            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3271        self
3272    }
3273
3274    /// Identifies the authorization scope for the method you are building.
3275    ///
3276    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3277    /// [`Scope::CloudPlatform`].
3278    ///
3279    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3280    /// tokens for more than one scope.
3281    ///
3282    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3283    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3284    /// sufficient, a read-write scope will do as well.
3285    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationTopicListCall<'a, C>
3286    where
3287        St: AsRef<str>,
3288    {
3289        self._scopes.insert(String::from(scope.as_ref()));
3290        self
3291    }
3292    /// Identifies the authorization scope(s) for the method you are building.
3293    ///
3294    /// See [`Self::add_scope()`] for details.
3295    pub fn add_scopes<I, St>(
3296        mut self,
3297        scopes: I,
3298    ) -> AdminProjectLocationReservationTopicListCall<'a, C>
3299    where
3300        I: IntoIterator<Item = St>,
3301        St: AsRef<str>,
3302    {
3303        self._scopes
3304            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3305        self
3306    }
3307
3308    /// Removes all scopes, and no default scope will be used either.
3309    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3310    /// for details).
3311    pub fn clear_scopes(mut self) -> AdminProjectLocationReservationTopicListCall<'a, C> {
3312        self._scopes.clear();
3313        self
3314    }
3315}
3316
3317/// Creates a new reservation.
3318///
3319/// A builder for the *projects.locations.reservations.create* method supported by a *admin* resource.
3320/// It is not used directly, but through a [`AdminMethods`] instance.
3321///
3322/// # Example
3323///
3324/// Instantiate a resource method builder
3325///
3326/// ```test_harness,no_run
3327/// # extern crate hyper;
3328/// # extern crate hyper_rustls;
3329/// # extern crate google_pubsublite1 as pubsublite1;
3330/// use pubsublite1::api::Reservation;
3331/// # async fn dox() {
3332/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3333///
3334/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3335/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3336/// #     .with_native_roots()
3337/// #     .unwrap()
3338/// #     .https_only()
3339/// #     .enable_http2()
3340/// #     .build();
3341///
3342/// # let executor = hyper_util::rt::TokioExecutor::new();
3343/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3344/// #     secret,
3345/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3346/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3347/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3348/// #     ),
3349/// # ).build().await.unwrap();
3350///
3351/// # let client = hyper_util::client::legacy::Client::builder(
3352/// #     hyper_util::rt::TokioExecutor::new()
3353/// # )
3354/// # .build(
3355/// #     hyper_rustls::HttpsConnectorBuilder::new()
3356/// #         .with_native_roots()
3357/// #         .unwrap()
3358/// #         .https_or_http()
3359/// #         .enable_http2()
3360/// #         .build()
3361/// # );
3362/// # let mut hub = PubsubLite::new(client, auth);
3363/// // As the method needs a request, you would usually fill it with the desired information
3364/// // into the respective structure. Some of the parts shown here might not be applicable !
3365/// // Values shown here are possibly random and not representative !
3366/// let mut req = Reservation::default();
3367///
3368/// // You can configure optional parameters by calling the respective setters at will, and
3369/// // execute the final call using `doit()`.
3370/// // Values shown here are possibly random and not representative !
3371/// let result = hub.admin().projects_locations_reservations_create(req, "parent")
3372///              .reservation_id("gubergren")
3373///              .doit().await;
3374/// # }
3375/// ```
3376pub struct AdminProjectLocationReservationCreateCall<'a, C>
3377where
3378    C: 'a,
3379{
3380    hub: &'a PubsubLite<C>,
3381    _request: Reservation,
3382    _parent: String,
3383    _reservation_id: Option<String>,
3384    _delegate: Option<&'a mut dyn common::Delegate>,
3385    _additional_params: HashMap<String, String>,
3386    _scopes: BTreeSet<String>,
3387}
3388
3389impl<'a, C> common::CallBuilder for AdminProjectLocationReservationCreateCall<'a, C> {}
3390
3391impl<'a, C> AdminProjectLocationReservationCreateCall<'a, C>
3392where
3393    C: common::Connector,
3394{
3395    /// Perform the operation you have build so far.
3396    pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
3397        use std::borrow::Cow;
3398        use std::io::{Read, Seek};
3399
3400        use common::{url::Params, ToParts};
3401        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3402
3403        let mut dd = common::DefaultDelegate;
3404        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3405        dlg.begin(common::MethodInfo {
3406            id: "pubsublite.admin.projects.locations.reservations.create",
3407            http_method: hyper::Method::POST,
3408        });
3409
3410        for &field in ["alt", "parent", "reservationId"].iter() {
3411            if self._additional_params.contains_key(field) {
3412                dlg.finished(false);
3413                return Err(common::Error::FieldClash(field));
3414            }
3415        }
3416
3417        let mut params = Params::with_capacity(5 + self._additional_params.len());
3418        params.push("parent", self._parent);
3419        if let Some(value) = self._reservation_id.as_ref() {
3420            params.push("reservationId", value);
3421        }
3422
3423        params.extend(self._additional_params.iter());
3424
3425        params.push("alt", "json");
3426        let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/reservations";
3427        if self._scopes.is_empty() {
3428            self._scopes
3429                .insert(Scope::CloudPlatform.as_ref().to_string());
3430        }
3431
3432        #[allow(clippy::single_element_loop)]
3433        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3434            url = params.uri_replacement(url, param_name, find_this, true);
3435        }
3436        {
3437            let to_remove = ["parent"];
3438            params.remove_params(&to_remove);
3439        }
3440
3441        let url = params.parse_with_url(&url);
3442
3443        let mut json_mime_type = mime::APPLICATION_JSON;
3444        let mut request_value_reader = {
3445            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3446            common::remove_json_null_values(&mut value);
3447            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3448            serde_json::to_writer(&mut dst, &value).unwrap();
3449            dst
3450        };
3451        let request_size = request_value_reader
3452            .seek(std::io::SeekFrom::End(0))
3453            .unwrap();
3454        request_value_reader
3455            .seek(std::io::SeekFrom::Start(0))
3456            .unwrap();
3457
3458        loop {
3459            let token = match self
3460                .hub
3461                .auth
3462                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3463                .await
3464            {
3465                Ok(token) => token,
3466                Err(e) => match dlg.token(e) {
3467                    Ok(token) => token,
3468                    Err(e) => {
3469                        dlg.finished(false);
3470                        return Err(common::Error::MissingToken(e));
3471                    }
3472                },
3473            };
3474            request_value_reader
3475                .seek(std::io::SeekFrom::Start(0))
3476                .unwrap();
3477            let mut req_result = {
3478                let client = &self.hub.client;
3479                dlg.pre_request();
3480                let mut req_builder = hyper::Request::builder()
3481                    .method(hyper::Method::POST)
3482                    .uri(url.as_str())
3483                    .header(USER_AGENT, self.hub._user_agent.clone());
3484
3485                if let Some(token) = token.as_ref() {
3486                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3487                }
3488
3489                let request = req_builder
3490                    .header(CONTENT_TYPE, json_mime_type.to_string())
3491                    .header(CONTENT_LENGTH, request_size as u64)
3492                    .body(common::to_body(
3493                        request_value_reader.get_ref().clone().into(),
3494                    ));
3495
3496                client.request(request.unwrap()).await
3497            };
3498
3499            match req_result {
3500                Err(err) => {
3501                    if let common::Retry::After(d) = dlg.http_error(&err) {
3502                        sleep(d).await;
3503                        continue;
3504                    }
3505                    dlg.finished(false);
3506                    return Err(common::Error::HttpError(err));
3507                }
3508                Ok(res) => {
3509                    let (mut parts, body) = res.into_parts();
3510                    let mut body = common::Body::new(body);
3511                    if !parts.status.is_success() {
3512                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3513                        let error = serde_json::from_str(&common::to_string(&bytes));
3514                        let response = common::to_response(parts, bytes.into());
3515
3516                        if let common::Retry::After(d) =
3517                            dlg.http_failure(&response, error.as_ref().ok())
3518                        {
3519                            sleep(d).await;
3520                            continue;
3521                        }
3522
3523                        dlg.finished(false);
3524
3525                        return Err(match error {
3526                            Ok(value) => common::Error::BadRequest(value),
3527                            _ => common::Error::Failure(response),
3528                        });
3529                    }
3530                    let response = {
3531                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3532                        let encoded = common::to_string(&bytes);
3533                        match serde_json::from_str(&encoded) {
3534                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3535                            Err(error) => {
3536                                dlg.response_json_decode_error(&encoded, &error);
3537                                return Err(common::Error::JsonDecodeError(
3538                                    encoded.to_string(),
3539                                    error,
3540                                ));
3541                            }
3542                        }
3543                    };
3544
3545                    dlg.finished(true);
3546                    return Ok(response);
3547                }
3548            }
3549        }
3550    }
3551
3552    ///
3553    /// Sets the *request* property to the given value.
3554    ///
3555    /// Even though the property as already been set when instantiating this call,
3556    /// we provide this method for API completeness.
3557    pub fn request(
3558        mut self,
3559        new_value: Reservation,
3560    ) -> AdminProjectLocationReservationCreateCall<'a, C> {
3561        self._request = new_value;
3562        self
3563    }
3564    /// Required. The parent location in which to create the reservation. Structured like `projects/{project_number}/locations/{location}`.
3565    ///
3566    /// Sets the *parent* path property to the given value.
3567    ///
3568    /// Even though the property as already been set when instantiating this call,
3569    /// we provide this method for API completeness.
3570    pub fn parent(mut self, new_value: &str) -> AdminProjectLocationReservationCreateCall<'a, C> {
3571        self._parent = new_value.to_string();
3572        self
3573    }
3574    /// 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`.
3575    ///
3576    /// Sets the *reservation id* query property to the given value.
3577    pub fn reservation_id(
3578        mut self,
3579        new_value: &str,
3580    ) -> AdminProjectLocationReservationCreateCall<'a, C> {
3581        self._reservation_id = Some(new_value.to_string());
3582        self
3583    }
3584    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3585    /// while executing the actual API request.
3586    ///
3587    /// ````text
3588    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3589    /// ````
3590    ///
3591    /// Sets the *delegate* property to the given value.
3592    pub fn delegate(
3593        mut self,
3594        new_value: &'a mut dyn common::Delegate,
3595    ) -> AdminProjectLocationReservationCreateCall<'a, C> {
3596        self._delegate = Some(new_value);
3597        self
3598    }
3599
3600    /// Set any additional parameter of the query string used in the request.
3601    /// It should be used to set parameters which are not yet available through their own
3602    /// setters.
3603    ///
3604    /// Please note that this method must not be used to set any of the known parameters
3605    /// which have their own setter method. If done anyway, the request will fail.
3606    ///
3607    /// # Additional Parameters
3608    ///
3609    /// * *$.xgafv* (query-string) - V1 error format.
3610    /// * *access_token* (query-string) - OAuth access token.
3611    /// * *alt* (query-string) - Data format for response.
3612    /// * *callback* (query-string) - JSONP
3613    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3614    /// * *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.
3615    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3616    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3617    /// * *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.
3618    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3619    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3620    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationCreateCall<'a, C>
3621    where
3622        T: AsRef<str>,
3623    {
3624        self._additional_params
3625            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3626        self
3627    }
3628
3629    /// Identifies the authorization scope for the method you are building.
3630    ///
3631    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3632    /// [`Scope::CloudPlatform`].
3633    ///
3634    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3635    /// tokens for more than one scope.
3636    ///
3637    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3638    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3639    /// sufficient, a read-write scope will do as well.
3640    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationCreateCall<'a, C>
3641    where
3642        St: AsRef<str>,
3643    {
3644        self._scopes.insert(String::from(scope.as_ref()));
3645        self
3646    }
3647    /// Identifies the authorization scope(s) for the method you are building.
3648    ///
3649    /// See [`Self::add_scope()`] for details.
3650    pub fn add_scopes<I, St>(
3651        mut self,
3652        scopes: I,
3653    ) -> AdminProjectLocationReservationCreateCall<'a, C>
3654    where
3655        I: IntoIterator<Item = St>,
3656        St: AsRef<str>,
3657    {
3658        self._scopes
3659            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3660        self
3661    }
3662
3663    /// Removes all scopes, and no default scope will be used either.
3664    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3665    /// for details).
3666    pub fn clear_scopes(mut self) -> AdminProjectLocationReservationCreateCall<'a, C> {
3667        self._scopes.clear();
3668        self
3669    }
3670}
3671
3672/// Deletes the specified reservation.
3673///
3674/// A builder for the *projects.locations.reservations.delete* method supported by a *admin* resource.
3675/// It is not used directly, but through a [`AdminMethods`] instance.
3676///
3677/// # Example
3678///
3679/// Instantiate a resource method builder
3680///
3681/// ```test_harness,no_run
3682/// # extern crate hyper;
3683/// # extern crate hyper_rustls;
3684/// # extern crate google_pubsublite1 as pubsublite1;
3685/// # async fn dox() {
3686/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3687///
3688/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3689/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3690/// #     .with_native_roots()
3691/// #     .unwrap()
3692/// #     .https_only()
3693/// #     .enable_http2()
3694/// #     .build();
3695///
3696/// # let executor = hyper_util::rt::TokioExecutor::new();
3697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3698/// #     secret,
3699/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3700/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3701/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3702/// #     ),
3703/// # ).build().await.unwrap();
3704///
3705/// # let client = hyper_util::client::legacy::Client::builder(
3706/// #     hyper_util::rt::TokioExecutor::new()
3707/// # )
3708/// # .build(
3709/// #     hyper_rustls::HttpsConnectorBuilder::new()
3710/// #         .with_native_roots()
3711/// #         .unwrap()
3712/// #         .https_or_http()
3713/// #         .enable_http2()
3714/// #         .build()
3715/// # );
3716/// # let mut hub = PubsubLite::new(client, auth);
3717/// // You can configure optional parameters by calling the respective setters at will, and
3718/// // execute the final call using `doit()`.
3719/// // Values shown here are possibly random and not representative !
3720/// let result = hub.admin().projects_locations_reservations_delete("name")
3721///              .doit().await;
3722/// # }
3723/// ```
3724pub struct AdminProjectLocationReservationDeleteCall<'a, C>
3725where
3726    C: 'a,
3727{
3728    hub: &'a PubsubLite<C>,
3729    _name: String,
3730    _delegate: Option<&'a mut dyn common::Delegate>,
3731    _additional_params: HashMap<String, String>,
3732    _scopes: BTreeSet<String>,
3733}
3734
3735impl<'a, C> common::CallBuilder for AdminProjectLocationReservationDeleteCall<'a, C> {}
3736
3737impl<'a, C> AdminProjectLocationReservationDeleteCall<'a, C>
3738where
3739    C: common::Connector,
3740{
3741    /// Perform the operation you have build so far.
3742    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3743        use std::borrow::Cow;
3744        use std::io::{Read, Seek};
3745
3746        use common::{url::Params, ToParts};
3747        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3748
3749        let mut dd = common::DefaultDelegate;
3750        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3751        dlg.begin(common::MethodInfo {
3752            id: "pubsublite.admin.projects.locations.reservations.delete",
3753            http_method: hyper::Method::DELETE,
3754        });
3755
3756        for &field in ["alt", "name"].iter() {
3757            if self._additional_params.contains_key(field) {
3758                dlg.finished(false);
3759                return Err(common::Error::FieldClash(field));
3760            }
3761        }
3762
3763        let mut params = Params::with_capacity(3 + self._additional_params.len());
3764        params.push("name", self._name);
3765
3766        params.extend(self._additional_params.iter());
3767
3768        params.push("alt", "json");
3769        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
3770        if self._scopes.is_empty() {
3771            self._scopes
3772                .insert(Scope::CloudPlatform.as_ref().to_string());
3773        }
3774
3775        #[allow(clippy::single_element_loop)]
3776        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3777            url = params.uri_replacement(url, param_name, find_this, true);
3778        }
3779        {
3780            let to_remove = ["name"];
3781            params.remove_params(&to_remove);
3782        }
3783
3784        let url = params.parse_with_url(&url);
3785
3786        loop {
3787            let token = match self
3788                .hub
3789                .auth
3790                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3791                .await
3792            {
3793                Ok(token) => token,
3794                Err(e) => match dlg.token(e) {
3795                    Ok(token) => token,
3796                    Err(e) => {
3797                        dlg.finished(false);
3798                        return Err(common::Error::MissingToken(e));
3799                    }
3800                },
3801            };
3802            let mut req_result = {
3803                let client = &self.hub.client;
3804                dlg.pre_request();
3805                let mut req_builder = hyper::Request::builder()
3806                    .method(hyper::Method::DELETE)
3807                    .uri(url.as_str())
3808                    .header(USER_AGENT, self.hub._user_agent.clone());
3809
3810                if let Some(token) = token.as_ref() {
3811                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3812                }
3813
3814                let request = req_builder
3815                    .header(CONTENT_LENGTH, 0_u64)
3816                    .body(common::to_body::<String>(None));
3817
3818                client.request(request.unwrap()).await
3819            };
3820
3821            match req_result {
3822                Err(err) => {
3823                    if let common::Retry::After(d) = dlg.http_error(&err) {
3824                        sleep(d).await;
3825                        continue;
3826                    }
3827                    dlg.finished(false);
3828                    return Err(common::Error::HttpError(err));
3829                }
3830                Ok(res) => {
3831                    let (mut parts, body) = res.into_parts();
3832                    let mut body = common::Body::new(body);
3833                    if !parts.status.is_success() {
3834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3835                        let error = serde_json::from_str(&common::to_string(&bytes));
3836                        let response = common::to_response(parts, bytes.into());
3837
3838                        if let common::Retry::After(d) =
3839                            dlg.http_failure(&response, error.as_ref().ok())
3840                        {
3841                            sleep(d).await;
3842                            continue;
3843                        }
3844
3845                        dlg.finished(false);
3846
3847                        return Err(match error {
3848                            Ok(value) => common::Error::BadRequest(value),
3849                            _ => common::Error::Failure(response),
3850                        });
3851                    }
3852                    let response = {
3853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3854                        let encoded = common::to_string(&bytes);
3855                        match serde_json::from_str(&encoded) {
3856                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3857                            Err(error) => {
3858                                dlg.response_json_decode_error(&encoded, &error);
3859                                return Err(common::Error::JsonDecodeError(
3860                                    encoded.to_string(),
3861                                    error,
3862                                ));
3863                            }
3864                        }
3865                    };
3866
3867                    dlg.finished(true);
3868                    return Ok(response);
3869                }
3870            }
3871        }
3872    }
3873
3874    /// Required. The name of the reservation to delete. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
3875    ///
3876    /// Sets the *name* path property to the given value.
3877    ///
3878    /// Even though the property as already been set when instantiating this call,
3879    /// we provide this method for API completeness.
3880    pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationDeleteCall<'a, C> {
3881        self._name = new_value.to_string();
3882        self
3883    }
3884    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3885    /// while executing the actual API request.
3886    ///
3887    /// ````text
3888    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3889    /// ````
3890    ///
3891    /// Sets the *delegate* property to the given value.
3892    pub fn delegate(
3893        mut self,
3894        new_value: &'a mut dyn common::Delegate,
3895    ) -> AdminProjectLocationReservationDeleteCall<'a, C> {
3896        self._delegate = Some(new_value);
3897        self
3898    }
3899
3900    /// Set any additional parameter of the query string used in the request.
3901    /// It should be used to set parameters which are not yet available through their own
3902    /// setters.
3903    ///
3904    /// Please note that this method must not be used to set any of the known parameters
3905    /// which have their own setter method. If done anyway, the request will fail.
3906    ///
3907    /// # Additional Parameters
3908    ///
3909    /// * *$.xgafv* (query-string) - V1 error format.
3910    /// * *access_token* (query-string) - OAuth access token.
3911    /// * *alt* (query-string) - Data format for response.
3912    /// * *callback* (query-string) - JSONP
3913    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3914    /// * *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.
3915    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3916    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3917    /// * *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.
3918    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3919    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3920    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationDeleteCall<'a, C>
3921    where
3922        T: AsRef<str>,
3923    {
3924        self._additional_params
3925            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3926        self
3927    }
3928
3929    /// Identifies the authorization scope for the method you are building.
3930    ///
3931    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3932    /// [`Scope::CloudPlatform`].
3933    ///
3934    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3935    /// tokens for more than one scope.
3936    ///
3937    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3938    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3939    /// sufficient, a read-write scope will do as well.
3940    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationDeleteCall<'a, C>
3941    where
3942        St: AsRef<str>,
3943    {
3944        self._scopes.insert(String::from(scope.as_ref()));
3945        self
3946    }
3947    /// Identifies the authorization scope(s) for the method you are building.
3948    ///
3949    /// See [`Self::add_scope()`] for details.
3950    pub fn add_scopes<I, St>(
3951        mut self,
3952        scopes: I,
3953    ) -> AdminProjectLocationReservationDeleteCall<'a, C>
3954    where
3955        I: IntoIterator<Item = St>,
3956        St: AsRef<str>,
3957    {
3958        self._scopes
3959            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3960        self
3961    }
3962
3963    /// Removes all scopes, and no default scope will be used either.
3964    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3965    /// for details).
3966    pub fn clear_scopes(mut self) -> AdminProjectLocationReservationDeleteCall<'a, C> {
3967        self._scopes.clear();
3968        self
3969    }
3970}
3971
3972/// Returns the reservation configuration.
3973///
3974/// A builder for the *projects.locations.reservations.get* method supported by a *admin* resource.
3975/// It is not used directly, but through a [`AdminMethods`] instance.
3976///
3977/// # Example
3978///
3979/// Instantiate a resource method builder
3980///
3981/// ```test_harness,no_run
3982/// # extern crate hyper;
3983/// # extern crate hyper_rustls;
3984/// # extern crate google_pubsublite1 as pubsublite1;
3985/// # async fn dox() {
3986/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3987///
3988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3989/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3990/// #     .with_native_roots()
3991/// #     .unwrap()
3992/// #     .https_only()
3993/// #     .enable_http2()
3994/// #     .build();
3995///
3996/// # let executor = hyper_util::rt::TokioExecutor::new();
3997/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3998/// #     secret,
3999/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4000/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4001/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4002/// #     ),
4003/// # ).build().await.unwrap();
4004///
4005/// # let client = hyper_util::client::legacy::Client::builder(
4006/// #     hyper_util::rt::TokioExecutor::new()
4007/// # )
4008/// # .build(
4009/// #     hyper_rustls::HttpsConnectorBuilder::new()
4010/// #         .with_native_roots()
4011/// #         .unwrap()
4012/// #         .https_or_http()
4013/// #         .enable_http2()
4014/// #         .build()
4015/// # );
4016/// # let mut hub = PubsubLite::new(client, auth);
4017/// // You can configure optional parameters by calling the respective setters at will, and
4018/// // execute the final call using `doit()`.
4019/// // Values shown here are possibly random and not representative !
4020/// let result = hub.admin().projects_locations_reservations_get("name")
4021///              .doit().await;
4022/// # }
4023/// ```
4024pub struct AdminProjectLocationReservationGetCall<'a, C>
4025where
4026    C: 'a,
4027{
4028    hub: &'a PubsubLite<C>,
4029    _name: String,
4030    _delegate: Option<&'a mut dyn common::Delegate>,
4031    _additional_params: HashMap<String, String>,
4032    _scopes: BTreeSet<String>,
4033}
4034
4035impl<'a, C> common::CallBuilder for AdminProjectLocationReservationGetCall<'a, C> {}
4036
4037impl<'a, C> AdminProjectLocationReservationGetCall<'a, C>
4038where
4039    C: common::Connector,
4040{
4041    /// Perform the operation you have build so far.
4042    pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
4043        use std::borrow::Cow;
4044        use std::io::{Read, Seek};
4045
4046        use common::{url::Params, ToParts};
4047        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4048
4049        let mut dd = common::DefaultDelegate;
4050        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4051        dlg.begin(common::MethodInfo {
4052            id: "pubsublite.admin.projects.locations.reservations.get",
4053            http_method: hyper::Method::GET,
4054        });
4055
4056        for &field in ["alt", "name"].iter() {
4057            if self._additional_params.contains_key(field) {
4058                dlg.finished(false);
4059                return Err(common::Error::FieldClash(field));
4060            }
4061        }
4062
4063        let mut params = Params::with_capacity(3 + self._additional_params.len());
4064        params.push("name", self._name);
4065
4066        params.extend(self._additional_params.iter());
4067
4068        params.push("alt", "json");
4069        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
4070        if self._scopes.is_empty() {
4071            self._scopes
4072                .insert(Scope::CloudPlatform.as_ref().to_string());
4073        }
4074
4075        #[allow(clippy::single_element_loop)]
4076        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4077            url = params.uri_replacement(url, param_name, find_this, true);
4078        }
4079        {
4080            let to_remove = ["name"];
4081            params.remove_params(&to_remove);
4082        }
4083
4084        let url = params.parse_with_url(&url);
4085
4086        loop {
4087            let token = match self
4088                .hub
4089                .auth
4090                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4091                .await
4092            {
4093                Ok(token) => token,
4094                Err(e) => match dlg.token(e) {
4095                    Ok(token) => token,
4096                    Err(e) => {
4097                        dlg.finished(false);
4098                        return Err(common::Error::MissingToken(e));
4099                    }
4100                },
4101            };
4102            let mut req_result = {
4103                let client = &self.hub.client;
4104                dlg.pre_request();
4105                let mut req_builder = hyper::Request::builder()
4106                    .method(hyper::Method::GET)
4107                    .uri(url.as_str())
4108                    .header(USER_AGENT, self.hub._user_agent.clone());
4109
4110                if let Some(token) = token.as_ref() {
4111                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4112                }
4113
4114                let request = req_builder
4115                    .header(CONTENT_LENGTH, 0_u64)
4116                    .body(common::to_body::<String>(None));
4117
4118                client.request(request.unwrap()).await
4119            };
4120
4121            match req_result {
4122                Err(err) => {
4123                    if let common::Retry::After(d) = dlg.http_error(&err) {
4124                        sleep(d).await;
4125                        continue;
4126                    }
4127                    dlg.finished(false);
4128                    return Err(common::Error::HttpError(err));
4129                }
4130                Ok(res) => {
4131                    let (mut parts, body) = res.into_parts();
4132                    let mut body = common::Body::new(body);
4133                    if !parts.status.is_success() {
4134                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4135                        let error = serde_json::from_str(&common::to_string(&bytes));
4136                        let response = common::to_response(parts, bytes.into());
4137
4138                        if let common::Retry::After(d) =
4139                            dlg.http_failure(&response, error.as_ref().ok())
4140                        {
4141                            sleep(d).await;
4142                            continue;
4143                        }
4144
4145                        dlg.finished(false);
4146
4147                        return Err(match error {
4148                            Ok(value) => common::Error::BadRequest(value),
4149                            _ => common::Error::Failure(response),
4150                        });
4151                    }
4152                    let response = {
4153                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4154                        let encoded = common::to_string(&bytes);
4155                        match serde_json::from_str(&encoded) {
4156                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4157                            Err(error) => {
4158                                dlg.response_json_decode_error(&encoded, &error);
4159                                return Err(common::Error::JsonDecodeError(
4160                                    encoded.to_string(),
4161                                    error,
4162                                ));
4163                            }
4164                        }
4165                    };
4166
4167                    dlg.finished(true);
4168                    return Ok(response);
4169                }
4170            }
4171        }
4172    }
4173
4174    /// Required. The name of the reservation whose configuration to return. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
4175    ///
4176    /// Sets the *name* path property to the given value.
4177    ///
4178    /// Even though the property as already been set when instantiating this call,
4179    /// we provide this method for API completeness.
4180    pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationGetCall<'a, C> {
4181        self._name = new_value.to_string();
4182        self
4183    }
4184    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4185    /// while executing the actual API request.
4186    ///
4187    /// ````text
4188    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4189    /// ````
4190    ///
4191    /// Sets the *delegate* property to the given value.
4192    pub fn delegate(
4193        mut self,
4194        new_value: &'a mut dyn common::Delegate,
4195    ) -> AdminProjectLocationReservationGetCall<'a, C> {
4196        self._delegate = Some(new_value);
4197        self
4198    }
4199
4200    /// Set any additional parameter of the query string used in the request.
4201    /// It should be used to set parameters which are not yet available through their own
4202    /// setters.
4203    ///
4204    /// Please note that this method must not be used to set any of the known parameters
4205    /// which have their own setter method. If done anyway, the request will fail.
4206    ///
4207    /// # Additional Parameters
4208    ///
4209    /// * *$.xgafv* (query-string) - V1 error format.
4210    /// * *access_token* (query-string) - OAuth access token.
4211    /// * *alt* (query-string) - Data format for response.
4212    /// * *callback* (query-string) - JSONP
4213    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4214    /// * *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.
4215    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4216    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4217    /// * *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.
4218    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4219    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4220    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationGetCall<'a, C>
4221    where
4222        T: AsRef<str>,
4223    {
4224        self._additional_params
4225            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4226        self
4227    }
4228
4229    /// Identifies the authorization scope for the method you are building.
4230    ///
4231    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4232    /// [`Scope::CloudPlatform`].
4233    ///
4234    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4235    /// tokens for more than one scope.
4236    ///
4237    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4238    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4239    /// sufficient, a read-write scope will do as well.
4240    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationGetCall<'a, C>
4241    where
4242        St: AsRef<str>,
4243    {
4244        self._scopes.insert(String::from(scope.as_ref()));
4245        self
4246    }
4247    /// Identifies the authorization scope(s) for the method you are building.
4248    ///
4249    /// See [`Self::add_scope()`] for details.
4250    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationReservationGetCall<'a, C>
4251    where
4252        I: IntoIterator<Item = St>,
4253        St: AsRef<str>,
4254    {
4255        self._scopes
4256            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4257        self
4258    }
4259
4260    /// Removes all scopes, and no default scope will be used either.
4261    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4262    /// for details).
4263    pub fn clear_scopes(mut self) -> AdminProjectLocationReservationGetCall<'a, C> {
4264        self._scopes.clear();
4265        self
4266    }
4267}
4268
4269/// Returns the list of reservations for the given project.
4270///
4271/// A builder for the *projects.locations.reservations.list* method supported by a *admin* resource.
4272/// It is not used directly, but through a [`AdminMethods`] instance.
4273///
4274/// # Example
4275///
4276/// Instantiate a resource method builder
4277///
4278/// ```test_harness,no_run
4279/// # extern crate hyper;
4280/// # extern crate hyper_rustls;
4281/// # extern crate google_pubsublite1 as pubsublite1;
4282/// # async fn dox() {
4283/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4284///
4285/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4286/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4287/// #     .with_native_roots()
4288/// #     .unwrap()
4289/// #     .https_only()
4290/// #     .enable_http2()
4291/// #     .build();
4292///
4293/// # let executor = hyper_util::rt::TokioExecutor::new();
4294/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4295/// #     secret,
4296/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4297/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4298/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4299/// #     ),
4300/// # ).build().await.unwrap();
4301///
4302/// # let client = hyper_util::client::legacy::Client::builder(
4303/// #     hyper_util::rt::TokioExecutor::new()
4304/// # )
4305/// # .build(
4306/// #     hyper_rustls::HttpsConnectorBuilder::new()
4307/// #         .with_native_roots()
4308/// #         .unwrap()
4309/// #         .https_or_http()
4310/// #         .enable_http2()
4311/// #         .build()
4312/// # );
4313/// # let mut hub = PubsubLite::new(client, auth);
4314/// // You can configure optional parameters by calling the respective setters at will, and
4315/// // execute the final call using `doit()`.
4316/// // Values shown here are possibly random and not representative !
4317/// let result = hub.admin().projects_locations_reservations_list("parent")
4318///              .page_token("ipsum")
4319///              .page_size(-88)
4320///              .doit().await;
4321/// # }
4322/// ```
4323pub struct AdminProjectLocationReservationListCall<'a, C>
4324where
4325    C: 'a,
4326{
4327    hub: &'a PubsubLite<C>,
4328    _parent: String,
4329    _page_token: Option<String>,
4330    _page_size: Option<i32>,
4331    _delegate: Option<&'a mut dyn common::Delegate>,
4332    _additional_params: HashMap<String, String>,
4333    _scopes: BTreeSet<String>,
4334}
4335
4336impl<'a, C> common::CallBuilder for AdminProjectLocationReservationListCall<'a, C> {}
4337
4338impl<'a, C> AdminProjectLocationReservationListCall<'a, C>
4339where
4340    C: common::Connector,
4341{
4342    /// Perform the operation you have build so far.
4343    pub async fn doit(mut self) -> common::Result<(common::Response, ListReservationsResponse)> {
4344        use std::borrow::Cow;
4345        use std::io::{Read, Seek};
4346
4347        use common::{url::Params, ToParts};
4348        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4349
4350        let mut dd = common::DefaultDelegate;
4351        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4352        dlg.begin(common::MethodInfo {
4353            id: "pubsublite.admin.projects.locations.reservations.list",
4354            http_method: hyper::Method::GET,
4355        });
4356
4357        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4358            if self._additional_params.contains_key(field) {
4359                dlg.finished(false);
4360                return Err(common::Error::FieldClash(field));
4361            }
4362        }
4363
4364        let mut params = Params::with_capacity(5 + self._additional_params.len());
4365        params.push("parent", self._parent);
4366        if let Some(value) = self._page_token.as_ref() {
4367            params.push("pageToken", value);
4368        }
4369        if let Some(value) = self._page_size.as_ref() {
4370            params.push("pageSize", value.to_string());
4371        }
4372
4373        params.extend(self._additional_params.iter());
4374
4375        params.push("alt", "json");
4376        let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/reservations";
4377        if self._scopes.is_empty() {
4378            self._scopes
4379                .insert(Scope::CloudPlatform.as_ref().to_string());
4380        }
4381
4382        #[allow(clippy::single_element_loop)]
4383        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4384            url = params.uri_replacement(url, param_name, find_this, true);
4385        }
4386        {
4387            let to_remove = ["parent"];
4388            params.remove_params(&to_remove);
4389        }
4390
4391        let url = params.parse_with_url(&url);
4392
4393        loop {
4394            let token = match self
4395                .hub
4396                .auth
4397                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4398                .await
4399            {
4400                Ok(token) => token,
4401                Err(e) => match dlg.token(e) {
4402                    Ok(token) => token,
4403                    Err(e) => {
4404                        dlg.finished(false);
4405                        return Err(common::Error::MissingToken(e));
4406                    }
4407                },
4408            };
4409            let mut req_result = {
4410                let client = &self.hub.client;
4411                dlg.pre_request();
4412                let mut req_builder = hyper::Request::builder()
4413                    .method(hyper::Method::GET)
4414                    .uri(url.as_str())
4415                    .header(USER_AGENT, self.hub._user_agent.clone());
4416
4417                if let Some(token) = token.as_ref() {
4418                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4419                }
4420
4421                let request = req_builder
4422                    .header(CONTENT_LENGTH, 0_u64)
4423                    .body(common::to_body::<String>(None));
4424
4425                client.request(request.unwrap()).await
4426            };
4427
4428            match req_result {
4429                Err(err) => {
4430                    if let common::Retry::After(d) = dlg.http_error(&err) {
4431                        sleep(d).await;
4432                        continue;
4433                    }
4434                    dlg.finished(false);
4435                    return Err(common::Error::HttpError(err));
4436                }
4437                Ok(res) => {
4438                    let (mut parts, body) = res.into_parts();
4439                    let mut body = common::Body::new(body);
4440                    if !parts.status.is_success() {
4441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4442                        let error = serde_json::from_str(&common::to_string(&bytes));
4443                        let response = common::to_response(parts, bytes.into());
4444
4445                        if let common::Retry::After(d) =
4446                            dlg.http_failure(&response, error.as_ref().ok())
4447                        {
4448                            sleep(d).await;
4449                            continue;
4450                        }
4451
4452                        dlg.finished(false);
4453
4454                        return Err(match error {
4455                            Ok(value) => common::Error::BadRequest(value),
4456                            _ => common::Error::Failure(response),
4457                        });
4458                    }
4459                    let response = {
4460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4461                        let encoded = common::to_string(&bytes);
4462                        match serde_json::from_str(&encoded) {
4463                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4464                            Err(error) => {
4465                                dlg.response_json_decode_error(&encoded, &error);
4466                                return Err(common::Error::JsonDecodeError(
4467                                    encoded.to_string(),
4468                                    error,
4469                                ));
4470                            }
4471                        }
4472                    };
4473
4474                    dlg.finished(true);
4475                    return Ok(response);
4476                }
4477            }
4478        }
4479    }
4480
4481    /// Required. The parent whose reservations are to be listed. Structured like `projects/{project_number}/locations/{location}`.
4482    ///
4483    /// Sets the *parent* path property to the given value.
4484    ///
4485    /// Even though the property as already been set when instantiating this call,
4486    /// we provide this method for API completeness.
4487    pub fn parent(mut self, new_value: &str) -> AdminProjectLocationReservationListCall<'a, C> {
4488        self._parent = new_value.to_string();
4489        self
4490    }
4491    /// 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.
4492    ///
4493    /// Sets the *page token* query property to the given value.
4494    pub fn page_token(mut self, new_value: &str) -> AdminProjectLocationReservationListCall<'a, C> {
4495        self._page_token = Some(new_value.to_string());
4496        self
4497    }
4498    /// 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.
4499    ///
4500    /// Sets the *page size* query property to the given value.
4501    pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationReservationListCall<'a, C> {
4502        self._page_size = Some(new_value);
4503        self
4504    }
4505    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4506    /// while executing the actual API request.
4507    ///
4508    /// ````text
4509    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4510    /// ````
4511    ///
4512    /// Sets the *delegate* property to the given value.
4513    pub fn delegate(
4514        mut self,
4515        new_value: &'a mut dyn common::Delegate,
4516    ) -> AdminProjectLocationReservationListCall<'a, C> {
4517        self._delegate = Some(new_value);
4518        self
4519    }
4520
4521    /// Set any additional parameter of the query string used in the request.
4522    /// It should be used to set parameters which are not yet available through their own
4523    /// setters.
4524    ///
4525    /// Please note that this method must not be used to set any of the known parameters
4526    /// which have their own setter method. If done anyway, the request will fail.
4527    ///
4528    /// # Additional Parameters
4529    ///
4530    /// * *$.xgafv* (query-string) - V1 error format.
4531    /// * *access_token* (query-string) - OAuth access token.
4532    /// * *alt* (query-string) - Data format for response.
4533    /// * *callback* (query-string) - JSONP
4534    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4535    /// * *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.
4536    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4537    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4538    /// * *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.
4539    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4540    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4541    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationListCall<'a, C>
4542    where
4543        T: AsRef<str>,
4544    {
4545        self._additional_params
4546            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4547        self
4548    }
4549
4550    /// Identifies the authorization scope for the method you are building.
4551    ///
4552    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4553    /// [`Scope::CloudPlatform`].
4554    ///
4555    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4556    /// tokens for more than one scope.
4557    ///
4558    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4559    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4560    /// sufficient, a read-write scope will do as well.
4561    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationListCall<'a, C>
4562    where
4563        St: AsRef<str>,
4564    {
4565        self._scopes.insert(String::from(scope.as_ref()));
4566        self
4567    }
4568    /// Identifies the authorization scope(s) for the method you are building.
4569    ///
4570    /// See [`Self::add_scope()`] for details.
4571    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationReservationListCall<'a, C>
4572    where
4573        I: IntoIterator<Item = St>,
4574        St: AsRef<str>,
4575    {
4576        self._scopes
4577            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4578        self
4579    }
4580
4581    /// Removes all scopes, and no default scope will be used either.
4582    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4583    /// for details).
4584    pub fn clear_scopes(mut self) -> AdminProjectLocationReservationListCall<'a, C> {
4585        self._scopes.clear();
4586        self
4587    }
4588}
4589
4590/// Updates properties of the specified reservation.
4591///
4592/// A builder for the *projects.locations.reservations.patch* method supported by a *admin* resource.
4593/// It is not used directly, but through a [`AdminMethods`] instance.
4594///
4595/// # Example
4596///
4597/// Instantiate a resource method builder
4598///
4599/// ```test_harness,no_run
4600/// # extern crate hyper;
4601/// # extern crate hyper_rustls;
4602/// # extern crate google_pubsublite1 as pubsublite1;
4603/// use pubsublite1::api::Reservation;
4604/// # async fn dox() {
4605/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4606///
4607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4608/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4609/// #     .with_native_roots()
4610/// #     .unwrap()
4611/// #     .https_only()
4612/// #     .enable_http2()
4613/// #     .build();
4614///
4615/// # let executor = hyper_util::rt::TokioExecutor::new();
4616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4617/// #     secret,
4618/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4619/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4620/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4621/// #     ),
4622/// # ).build().await.unwrap();
4623///
4624/// # let client = hyper_util::client::legacy::Client::builder(
4625/// #     hyper_util::rt::TokioExecutor::new()
4626/// # )
4627/// # .build(
4628/// #     hyper_rustls::HttpsConnectorBuilder::new()
4629/// #         .with_native_roots()
4630/// #         .unwrap()
4631/// #         .https_or_http()
4632/// #         .enable_http2()
4633/// #         .build()
4634/// # );
4635/// # let mut hub = PubsubLite::new(client, auth);
4636/// // As the method needs a request, you would usually fill it with the desired information
4637/// // into the respective structure. Some of the parts shown here might not be applicable !
4638/// // Values shown here are possibly random and not representative !
4639/// let mut req = Reservation::default();
4640///
4641/// // You can configure optional parameters by calling the respective setters at will, and
4642/// // execute the final call using `doit()`.
4643/// // Values shown here are possibly random and not representative !
4644/// let result = hub.admin().projects_locations_reservations_patch(req, "name")
4645///              .update_mask(FieldMask::new::<&str>(&[]))
4646///              .doit().await;
4647/// # }
4648/// ```
4649pub struct AdminProjectLocationReservationPatchCall<'a, C>
4650where
4651    C: 'a,
4652{
4653    hub: &'a PubsubLite<C>,
4654    _request: Reservation,
4655    _name: String,
4656    _update_mask: Option<common::FieldMask>,
4657    _delegate: Option<&'a mut dyn common::Delegate>,
4658    _additional_params: HashMap<String, String>,
4659    _scopes: BTreeSet<String>,
4660}
4661
4662impl<'a, C> common::CallBuilder for AdminProjectLocationReservationPatchCall<'a, C> {}
4663
4664impl<'a, C> AdminProjectLocationReservationPatchCall<'a, C>
4665where
4666    C: common::Connector,
4667{
4668    /// Perform the operation you have build so far.
4669    pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
4670        use std::borrow::Cow;
4671        use std::io::{Read, Seek};
4672
4673        use common::{url::Params, ToParts};
4674        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4675
4676        let mut dd = common::DefaultDelegate;
4677        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4678        dlg.begin(common::MethodInfo {
4679            id: "pubsublite.admin.projects.locations.reservations.patch",
4680            http_method: hyper::Method::PATCH,
4681        });
4682
4683        for &field in ["alt", "name", "updateMask"].iter() {
4684            if self._additional_params.contains_key(field) {
4685                dlg.finished(false);
4686                return Err(common::Error::FieldClash(field));
4687            }
4688        }
4689
4690        let mut params = Params::with_capacity(5 + self._additional_params.len());
4691        params.push("name", self._name);
4692        if let Some(value) = self._update_mask.as_ref() {
4693            params.push("updateMask", value.to_string());
4694        }
4695
4696        params.extend(self._additional_params.iter());
4697
4698        params.push("alt", "json");
4699        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
4700        if self._scopes.is_empty() {
4701            self._scopes
4702                .insert(Scope::CloudPlatform.as_ref().to_string());
4703        }
4704
4705        #[allow(clippy::single_element_loop)]
4706        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4707            url = params.uri_replacement(url, param_name, find_this, true);
4708        }
4709        {
4710            let to_remove = ["name"];
4711            params.remove_params(&to_remove);
4712        }
4713
4714        let url = params.parse_with_url(&url);
4715
4716        let mut json_mime_type = mime::APPLICATION_JSON;
4717        let mut request_value_reader = {
4718            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4719            common::remove_json_null_values(&mut value);
4720            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4721            serde_json::to_writer(&mut dst, &value).unwrap();
4722            dst
4723        };
4724        let request_size = request_value_reader
4725            .seek(std::io::SeekFrom::End(0))
4726            .unwrap();
4727        request_value_reader
4728            .seek(std::io::SeekFrom::Start(0))
4729            .unwrap();
4730
4731        loop {
4732            let token = match self
4733                .hub
4734                .auth
4735                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4736                .await
4737            {
4738                Ok(token) => token,
4739                Err(e) => match dlg.token(e) {
4740                    Ok(token) => token,
4741                    Err(e) => {
4742                        dlg.finished(false);
4743                        return Err(common::Error::MissingToken(e));
4744                    }
4745                },
4746            };
4747            request_value_reader
4748                .seek(std::io::SeekFrom::Start(0))
4749                .unwrap();
4750            let mut req_result = {
4751                let client = &self.hub.client;
4752                dlg.pre_request();
4753                let mut req_builder = hyper::Request::builder()
4754                    .method(hyper::Method::PATCH)
4755                    .uri(url.as_str())
4756                    .header(USER_AGENT, self.hub._user_agent.clone());
4757
4758                if let Some(token) = token.as_ref() {
4759                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4760                }
4761
4762                let request = req_builder
4763                    .header(CONTENT_TYPE, json_mime_type.to_string())
4764                    .header(CONTENT_LENGTH, request_size as u64)
4765                    .body(common::to_body(
4766                        request_value_reader.get_ref().clone().into(),
4767                    ));
4768
4769                client.request(request.unwrap()).await
4770            };
4771
4772            match req_result {
4773                Err(err) => {
4774                    if let common::Retry::After(d) = dlg.http_error(&err) {
4775                        sleep(d).await;
4776                        continue;
4777                    }
4778                    dlg.finished(false);
4779                    return Err(common::Error::HttpError(err));
4780                }
4781                Ok(res) => {
4782                    let (mut parts, body) = res.into_parts();
4783                    let mut body = common::Body::new(body);
4784                    if !parts.status.is_success() {
4785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4786                        let error = serde_json::from_str(&common::to_string(&bytes));
4787                        let response = common::to_response(parts, bytes.into());
4788
4789                        if let common::Retry::After(d) =
4790                            dlg.http_failure(&response, error.as_ref().ok())
4791                        {
4792                            sleep(d).await;
4793                            continue;
4794                        }
4795
4796                        dlg.finished(false);
4797
4798                        return Err(match error {
4799                            Ok(value) => common::Error::BadRequest(value),
4800                            _ => common::Error::Failure(response),
4801                        });
4802                    }
4803                    let response = {
4804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4805                        let encoded = common::to_string(&bytes);
4806                        match serde_json::from_str(&encoded) {
4807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4808                            Err(error) => {
4809                                dlg.response_json_decode_error(&encoded, &error);
4810                                return Err(common::Error::JsonDecodeError(
4811                                    encoded.to_string(),
4812                                    error,
4813                                ));
4814                            }
4815                        }
4816                    };
4817
4818                    dlg.finished(true);
4819                    return Ok(response);
4820                }
4821            }
4822        }
4823    }
4824
4825    ///
4826    /// Sets the *request* property to the given value.
4827    ///
4828    /// Even though the property as already been set when instantiating this call,
4829    /// we provide this method for API completeness.
4830    pub fn request(
4831        mut self,
4832        new_value: Reservation,
4833    ) -> AdminProjectLocationReservationPatchCall<'a, C> {
4834        self._request = new_value;
4835        self
4836    }
4837    /// The name of the reservation. Structured like: projects/{project_number}/locations/{location}/reservations/{reservation_id}
4838    ///
4839    /// Sets the *name* path property to the given value.
4840    ///
4841    /// Even though the property as already been set when instantiating this call,
4842    /// we provide this method for API completeness.
4843    pub fn name(mut self, new_value: &str) -> AdminProjectLocationReservationPatchCall<'a, C> {
4844        self._name = new_value.to_string();
4845        self
4846    }
4847    /// Required. A mask specifying the reservation fields to change.
4848    ///
4849    /// Sets the *update mask* query property to the given value.
4850    pub fn update_mask(
4851        mut self,
4852        new_value: common::FieldMask,
4853    ) -> AdminProjectLocationReservationPatchCall<'a, C> {
4854        self._update_mask = Some(new_value);
4855        self
4856    }
4857    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4858    /// while executing the actual API request.
4859    ///
4860    /// ````text
4861    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4862    /// ````
4863    ///
4864    /// Sets the *delegate* property to the given value.
4865    pub fn delegate(
4866        mut self,
4867        new_value: &'a mut dyn common::Delegate,
4868    ) -> AdminProjectLocationReservationPatchCall<'a, C> {
4869        self._delegate = Some(new_value);
4870        self
4871    }
4872
4873    /// Set any additional parameter of the query string used in the request.
4874    /// It should be used to set parameters which are not yet available through their own
4875    /// setters.
4876    ///
4877    /// Please note that this method must not be used to set any of the known parameters
4878    /// which have their own setter method. If done anyway, the request will fail.
4879    ///
4880    /// # Additional Parameters
4881    ///
4882    /// * *$.xgafv* (query-string) - V1 error format.
4883    /// * *access_token* (query-string) - OAuth access token.
4884    /// * *alt* (query-string) - Data format for response.
4885    /// * *callback* (query-string) - JSONP
4886    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4887    /// * *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.
4888    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4889    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4890    /// * *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.
4891    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4892    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4893    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationReservationPatchCall<'a, C>
4894    where
4895        T: AsRef<str>,
4896    {
4897        self._additional_params
4898            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4899        self
4900    }
4901
4902    /// Identifies the authorization scope for the method you are building.
4903    ///
4904    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4905    /// [`Scope::CloudPlatform`].
4906    ///
4907    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4908    /// tokens for more than one scope.
4909    ///
4910    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4911    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4912    /// sufficient, a read-write scope will do as well.
4913    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationReservationPatchCall<'a, C>
4914    where
4915        St: AsRef<str>,
4916    {
4917        self._scopes.insert(String::from(scope.as_ref()));
4918        self
4919    }
4920    /// Identifies the authorization scope(s) for the method you are building.
4921    ///
4922    /// See [`Self::add_scope()`] for details.
4923    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationReservationPatchCall<'a, C>
4924    where
4925        I: IntoIterator<Item = St>,
4926        St: AsRef<str>,
4927    {
4928        self._scopes
4929            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4930        self
4931    }
4932
4933    /// Removes all scopes, and no default scope will be used either.
4934    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4935    /// for details).
4936    pub fn clear_scopes(mut self) -> AdminProjectLocationReservationPatchCall<'a, C> {
4937        self._scopes.clear();
4938        self
4939    }
4940}
4941
4942/// Creates a new subscription.
4943///
4944/// A builder for the *projects.locations.subscriptions.create* method supported by a *admin* resource.
4945/// It is not used directly, but through a [`AdminMethods`] instance.
4946///
4947/// # Example
4948///
4949/// Instantiate a resource method builder
4950///
4951/// ```test_harness,no_run
4952/// # extern crate hyper;
4953/// # extern crate hyper_rustls;
4954/// # extern crate google_pubsublite1 as pubsublite1;
4955/// use pubsublite1::api::Subscription;
4956/// # async fn dox() {
4957/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4958///
4959/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4960/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4961/// #     .with_native_roots()
4962/// #     .unwrap()
4963/// #     .https_only()
4964/// #     .enable_http2()
4965/// #     .build();
4966///
4967/// # let executor = hyper_util::rt::TokioExecutor::new();
4968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4969/// #     secret,
4970/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4971/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4972/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4973/// #     ),
4974/// # ).build().await.unwrap();
4975///
4976/// # let client = hyper_util::client::legacy::Client::builder(
4977/// #     hyper_util::rt::TokioExecutor::new()
4978/// # )
4979/// # .build(
4980/// #     hyper_rustls::HttpsConnectorBuilder::new()
4981/// #         .with_native_roots()
4982/// #         .unwrap()
4983/// #         .https_or_http()
4984/// #         .enable_http2()
4985/// #         .build()
4986/// # );
4987/// # let mut hub = PubsubLite::new(client, auth);
4988/// // As the method needs a request, you would usually fill it with the desired information
4989/// // into the respective structure. Some of the parts shown here might not be applicable !
4990/// // Values shown here are possibly random and not representative !
4991/// let mut req = Subscription::default();
4992///
4993/// // You can configure optional parameters by calling the respective setters at will, and
4994/// // execute the final call using `doit()`.
4995/// // Values shown here are possibly random and not representative !
4996/// let result = hub.admin().projects_locations_subscriptions_create(req, "parent")
4997///              .subscription_id("ipsum")
4998///              .skip_backlog(false)
4999///              .doit().await;
5000/// # }
5001/// ```
5002pub struct AdminProjectLocationSubscriptionCreateCall<'a, C>
5003where
5004    C: 'a,
5005{
5006    hub: &'a PubsubLite<C>,
5007    _request: Subscription,
5008    _parent: String,
5009    _subscription_id: Option<String>,
5010    _skip_backlog: Option<bool>,
5011    _delegate: Option<&'a mut dyn common::Delegate>,
5012    _additional_params: HashMap<String, String>,
5013    _scopes: BTreeSet<String>,
5014}
5015
5016impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionCreateCall<'a, C> {}
5017
5018impl<'a, C> AdminProjectLocationSubscriptionCreateCall<'a, C>
5019where
5020    C: common::Connector,
5021{
5022    /// Perform the operation you have build so far.
5023    pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
5024        use std::borrow::Cow;
5025        use std::io::{Read, Seek};
5026
5027        use common::{url::Params, ToParts};
5028        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5029
5030        let mut dd = common::DefaultDelegate;
5031        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5032        dlg.begin(common::MethodInfo {
5033            id: "pubsublite.admin.projects.locations.subscriptions.create",
5034            http_method: hyper::Method::POST,
5035        });
5036
5037        for &field in ["alt", "parent", "subscriptionId", "skipBacklog"].iter() {
5038            if self._additional_params.contains_key(field) {
5039                dlg.finished(false);
5040                return Err(common::Error::FieldClash(field));
5041            }
5042        }
5043
5044        let mut params = Params::with_capacity(6 + self._additional_params.len());
5045        params.push("parent", self._parent);
5046        if let Some(value) = self._subscription_id.as_ref() {
5047            params.push("subscriptionId", value);
5048        }
5049        if let Some(value) = self._skip_backlog.as_ref() {
5050            params.push("skipBacklog", value.to_string());
5051        }
5052
5053        params.extend(self._additional_params.iter());
5054
5055        params.push("alt", "json");
5056        let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/subscriptions";
5057        if self._scopes.is_empty() {
5058            self._scopes
5059                .insert(Scope::CloudPlatform.as_ref().to_string());
5060        }
5061
5062        #[allow(clippy::single_element_loop)]
5063        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5064            url = params.uri_replacement(url, param_name, find_this, true);
5065        }
5066        {
5067            let to_remove = ["parent"];
5068            params.remove_params(&to_remove);
5069        }
5070
5071        let url = params.parse_with_url(&url);
5072
5073        let mut json_mime_type = mime::APPLICATION_JSON;
5074        let mut request_value_reader = {
5075            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5076            common::remove_json_null_values(&mut value);
5077            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5078            serde_json::to_writer(&mut dst, &value).unwrap();
5079            dst
5080        };
5081        let request_size = request_value_reader
5082            .seek(std::io::SeekFrom::End(0))
5083            .unwrap();
5084        request_value_reader
5085            .seek(std::io::SeekFrom::Start(0))
5086            .unwrap();
5087
5088        loop {
5089            let token = match self
5090                .hub
5091                .auth
5092                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5093                .await
5094            {
5095                Ok(token) => token,
5096                Err(e) => match dlg.token(e) {
5097                    Ok(token) => token,
5098                    Err(e) => {
5099                        dlg.finished(false);
5100                        return Err(common::Error::MissingToken(e));
5101                    }
5102                },
5103            };
5104            request_value_reader
5105                .seek(std::io::SeekFrom::Start(0))
5106                .unwrap();
5107            let mut req_result = {
5108                let client = &self.hub.client;
5109                dlg.pre_request();
5110                let mut req_builder = hyper::Request::builder()
5111                    .method(hyper::Method::POST)
5112                    .uri(url.as_str())
5113                    .header(USER_AGENT, self.hub._user_agent.clone());
5114
5115                if let Some(token) = token.as_ref() {
5116                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5117                }
5118
5119                let request = req_builder
5120                    .header(CONTENT_TYPE, json_mime_type.to_string())
5121                    .header(CONTENT_LENGTH, request_size as u64)
5122                    .body(common::to_body(
5123                        request_value_reader.get_ref().clone().into(),
5124                    ));
5125
5126                client.request(request.unwrap()).await
5127            };
5128
5129            match req_result {
5130                Err(err) => {
5131                    if let common::Retry::After(d) = dlg.http_error(&err) {
5132                        sleep(d).await;
5133                        continue;
5134                    }
5135                    dlg.finished(false);
5136                    return Err(common::Error::HttpError(err));
5137                }
5138                Ok(res) => {
5139                    let (mut parts, body) = res.into_parts();
5140                    let mut body = common::Body::new(body);
5141                    if !parts.status.is_success() {
5142                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5143                        let error = serde_json::from_str(&common::to_string(&bytes));
5144                        let response = common::to_response(parts, bytes.into());
5145
5146                        if let common::Retry::After(d) =
5147                            dlg.http_failure(&response, error.as_ref().ok())
5148                        {
5149                            sleep(d).await;
5150                            continue;
5151                        }
5152
5153                        dlg.finished(false);
5154
5155                        return Err(match error {
5156                            Ok(value) => common::Error::BadRequest(value),
5157                            _ => common::Error::Failure(response),
5158                        });
5159                    }
5160                    let response = {
5161                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5162                        let encoded = common::to_string(&bytes);
5163                        match serde_json::from_str(&encoded) {
5164                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5165                            Err(error) => {
5166                                dlg.response_json_decode_error(&encoded, &error);
5167                                return Err(common::Error::JsonDecodeError(
5168                                    encoded.to_string(),
5169                                    error,
5170                                ));
5171                            }
5172                        }
5173                    };
5174
5175                    dlg.finished(true);
5176                    return Ok(response);
5177                }
5178            }
5179        }
5180    }
5181
5182    ///
5183    /// Sets the *request* property to the given value.
5184    ///
5185    /// Even though the property as already been set when instantiating this call,
5186    /// we provide this method for API completeness.
5187    pub fn request(
5188        mut self,
5189        new_value: Subscription,
5190    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5191        self._request = new_value;
5192        self
5193    }
5194    /// Required. The parent location in which to create the subscription. Structured like `projects/{project_number}/locations/{location}`.
5195    ///
5196    /// Sets the *parent* path property to the given value.
5197    ///
5198    /// Even though the property as already been set when instantiating this call,
5199    /// we provide this method for API completeness.
5200    pub fn parent(mut self, new_value: &str) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5201        self._parent = new_value.to_string();
5202        self
5203    }
5204    /// 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`.
5205    ///
5206    /// Sets the *subscription id* query property to the given value.
5207    pub fn subscription_id(
5208        mut self,
5209        new_value: &str,
5210    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5211        self._subscription_id = Some(new_value.to_string());
5212        self
5213    }
5214    /// 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.
5215    ///
5216    /// Sets the *skip backlog* query property to the given value.
5217    pub fn skip_backlog(
5218        mut self,
5219        new_value: bool,
5220    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5221        self._skip_backlog = Some(new_value);
5222        self
5223    }
5224    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5225    /// while executing the actual API request.
5226    ///
5227    /// ````text
5228    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5229    /// ````
5230    ///
5231    /// Sets the *delegate* property to the given value.
5232    pub fn delegate(
5233        mut self,
5234        new_value: &'a mut dyn common::Delegate,
5235    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5236        self._delegate = Some(new_value);
5237        self
5238    }
5239
5240    /// Set any additional parameter of the query string used in the request.
5241    /// It should be used to set parameters which are not yet available through their own
5242    /// setters.
5243    ///
5244    /// Please note that this method must not be used to set any of the known parameters
5245    /// which have their own setter method. If done anyway, the request will fail.
5246    ///
5247    /// # Additional Parameters
5248    ///
5249    /// * *$.xgafv* (query-string) - V1 error format.
5250    /// * *access_token* (query-string) - OAuth access token.
5251    /// * *alt* (query-string) - Data format for response.
5252    /// * *callback* (query-string) - JSONP
5253    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5254    /// * *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.
5255    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5256    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5257    /// * *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.
5258    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5259    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5260    pub fn param<T>(
5261        mut self,
5262        name: T,
5263        value: T,
5264    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C>
5265    where
5266        T: AsRef<str>,
5267    {
5268        self._additional_params
5269            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5270        self
5271    }
5272
5273    /// Identifies the authorization scope for the method you are building.
5274    ///
5275    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5276    /// [`Scope::CloudPlatform`].
5277    ///
5278    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5279    /// tokens for more than one scope.
5280    ///
5281    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5282    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5283    /// sufficient, a read-write scope will do as well.
5284    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionCreateCall<'a, C>
5285    where
5286        St: AsRef<str>,
5287    {
5288        self._scopes.insert(String::from(scope.as_ref()));
5289        self
5290    }
5291    /// Identifies the authorization scope(s) for the method you are building.
5292    ///
5293    /// See [`Self::add_scope()`] for details.
5294    pub fn add_scopes<I, St>(
5295        mut self,
5296        scopes: I,
5297    ) -> AdminProjectLocationSubscriptionCreateCall<'a, C>
5298    where
5299        I: IntoIterator<Item = St>,
5300        St: AsRef<str>,
5301    {
5302        self._scopes
5303            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5304        self
5305    }
5306
5307    /// Removes all scopes, and no default scope will be used either.
5308    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5309    /// for details).
5310    pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionCreateCall<'a, C> {
5311        self._scopes.clear();
5312        self
5313    }
5314}
5315
5316/// Deletes the specified subscription.
5317///
5318/// A builder for the *projects.locations.subscriptions.delete* method supported by a *admin* resource.
5319/// It is not used directly, but through a [`AdminMethods`] instance.
5320///
5321/// # Example
5322///
5323/// Instantiate a resource method builder
5324///
5325/// ```test_harness,no_run
5326/// # extern crate hyper;
5327/// # extern crate hyper_rustls;
5328/// # extern crate google_pubsublite1 as pubsublite1;
5329/// # async fn dox() {
5330/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5331///
5332/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5333/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5334/// #     .with_native_roots()
5335/// #     .unwrap()
5336/// #     .https_only()
5337/// #     .enable_http2()
5338/// #     .build();
5339///
5340/// # let executor = hyper_util::rt::TokioExecutor::new();
5341/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5342/// #     secret,
5343/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5344/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5345/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5346/// #     ),
5347/// # ).build().await.unwrap();
5348///
5349/// # let client = hyper_util::client::legacy::Client::builder(
5350/// #     hyper_util::rt::TokioExecutor::new()
5351/// # )
5352/// # .build(
5353/// #     hyper_rustls::HttpsConnectorBuilder::new()
5354/// #         .with_native_roots()
5355/// #         .unwrap()
5356/// #         .https_or_http()
5357/// #         .enable_http2()
5358/// #         .build()
5359/// # );
5360/// # let mut hub = PubsubLite::new(client, auth);
5361/// // You can configure optional parameters by calling the respective setters at will, and
5362/// // execute the final call using `doit()`.
5363/// // Values shown here are possibly random and not representative !
5364/// let result = hub.admin().projects_locations_subscriptions_delete("name")
5365///              .doit().await;
5366/// # }
5367/// ```
5368pub struct AdminProjectLocationSubscriptionDeleteCall<'a, C>
5369where
5370    C: 'a,
5371{
5372    hub: &'a PubsubLite<C>,
5373    _name: String,
5374    _delegate: Option<&'a mut dyn common::Delegate>,
5375    _additional_params: HashMap<String, String>,
5376    _scopes: BTreeSet<String>,
5377}
5378
5379impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionDeleteCall<'a, C> {}
5380
5381impl<'a, C> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5382where
5383    C: common::Connector,
5384{
5385    /// Perform the operation you have build so far.
5386    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5387        use std::borrow::Cow;
5388        use std::io::{Read, Seek};
5389
5390        use common::{url::Params, ToParts};
5391        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5392
5393        let mut dd = common::DefaultDelegate;
5394        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5395        dlg.begin(common::MethodInfo {
5396            id: "pubsublite.admin.projects.locations.subscriptions.delete",
5397            http_method: hyper::Method::DELETE,
5398        });
5399
5400        for &field in ["alt", "name"].iter() {
5401            if self._additional_params.contains_key(field) {
5402                dlg.finished(false);
5403                return Err(common::Error::FieldClash(field));
5404            }
5405        }
5406
5407        let mut params = Params::with_capacity(3 + self._additional_params.len());
5408        params.push("name", self._name);
5409
5410        params.extend(self._additional_params.iter());
5411
5412        params.push("alt", "json");
5413        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
5414        if self._scopes.is_empty() {
5415            self._scopes
5416                .insert(Scope::CloudPlatform.as_ref().to_string());
5417        }
5418
5419        #[allow(clippy::single_element_loop)]
5420        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5421            url = params.uri_replacement(url, param_name, find_this, true);
5422        }
5423        {
5424            let to_remove = ["name"];
5425            params.remove_params(&to_remove);
5426        }
5427
5428        let url = params.parse_with_url(&url);
5429
5430        loop {
5431            let token = match self
5432                .hub
5433                .auth
5434                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5435                .await
5436            {
5437                Ok(token) => token,
5438                Err(e) => match dlg.token(e) {
5439                    Ok(token) => token,
5440                    Err(e) => {
5441                        dlg.finished(false);
5442                        return Err(common::Error::MissingToken(e));
5443                    }
5444                },
5445            };
5446            let mut req_result = {
5447                let client = &self.hub.client;
5448                dlg.pre_request();
5449                let mut req_builder = hyper::Request::builder()
5450                    .method(hyper::Method::DELETE)
5451                    .uri(url.as_str())
5452                    .header(USER_AGENT, self.hub._user_agent.clone());
5453
5454                if let Some(token) = token.as_ref() {
5455                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5456                }
5457
5458                let request = req_builder
5459                    .header(CONTENT_LENGTH, 0_u64)
5460                    .body(common::to_body::<String>(None));
5461
5462                client.request(request.unwrap()).await
5463            };
5464
5465            match req_result {
5466                Err(err) => {
5467                    if let common::Retry::After(d) = dlg.http_error(&err) {
5468                        sleep(d).await;
5469                        continue;
5470                    }
5471                    dlg.finished(false);
5472                    return Err(common::Error::HttpError(err));
5473                }
5474                Ok(res) => {
5475                    let (mut parts, body) = res.into_parts();
5476                    let mut body = common::Body::new(body);
5477                    if !parts.status.is_success() {
5478                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5479                        let error = serde_json::from_str(&common::to_string(&bytes));
5480                        let response = common::to_response(parts, bytes.into());
5481
5482                        if let common::Retry::After(d) =
5483                            dlg.http_failure(&response, error.as_ref().ok())
5484                        {
5485                            sleep(d).await;
5486                            continue;
5487                        }
5488
5489                        dlg.finished(false);
5490
5491                        return Err(match error {
5492                            Ok(value) => common::Error::BadRequest(value),
5493                            _ => common::Error::Failure(response),
5494                        });
5495                    }
5496                    let response = {
5497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5498                        let encoded = common::to_string(&bytes);
5499                        match serde_json::from_str(&encoded) {
5500                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5501                            Err(error) => {
5502                                dlg.response_json_decode_error(&encoded, &error);
5503                                return Err(common::Error::JsonDecodeError(
5504                                    encoded.to_string(),
5505                                    error,
5506                                ));
5507                            }
5508                        }
5509                    };
5510
5511                    dlg.finished(true);
5512                    return Ok(response);
5513                }
5514            }
5515        }
5516    }
5517
5518    /// Required. The name of the subscription to delete.
5519    ///
5520    /// Sets the *name* path property to the given value.
5521    ///
5522    /// Even though the property as already been set when instantiating this call,
5523    /// we provide this method for API completeness.
5524    pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
5525        self._name = new_value.to_string();
5526        self
5527    }
5528    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5529    /// while executing the actual API request.
5530    ///
5531    /// ````text
5532    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5533    /// ````
5534    ///
5535    /// Sets the *delegate* property to the given value.
5536    pub fn delegate(
5537        mut self,
5538        new_value: &'a mut dyn common::Delegate,
5539    ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
5540        self._delegate = Some(new_value);
5541        self
5542    }
5543
5544    /// Set any additional parameter of the query string used in the request.
5545    /// It should be used to set parameters which are not yet available through their own
5546    /// setters.
5547    ///
5548    /// Please note that this method must not be used to set any of the known parameters
5549    /// which have their own setter method. If done anyway, the request will fail.
5550    ///
5551    /// # Additional Parameters
5552    ///
5553    /// * *$.xgafv* (query-string) - V1 error format.
5554    /// * *access_token* (query-string) - OAuth access token.
5555    /// * *alt* (query-string) - Data format for response.
5556    /// * *callback* (query-string) - JSONP
5557    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5558    /// * *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.
5559    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5560    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5561    /// * *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.
5562    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5563    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5564    pub fn param<T>(
5565        mut self,
5566        name: T,
5567        value: T,
5568    ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5569    where
5570        T: AsRef<str>,
5571    {
5572        self._additional_params
5573            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5574        self
5575    }
5576
5577    /// Identifies the authorization scope for the method you are building.
5578    ///
5579    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5580    /// [`Scope::CloudPlatform`].
5581    ///
5582    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5583    /// tokens for more than one scope.
5584    ///
5585    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5586    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5587    /// sufficient, a read-write scope will do as well.
5588    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5589    where
5590        St: AsRef<str>,
5591    {
5592        self._scopes.insert(String::from(scope.as_ref()));
5593        self
5594    }
5595    /// Identifies the authorization scope(s) for the method you are building.
5596    ///
5597    /// See [`Self::add_scope()`] for details.
5598    pub fn add_scopes<I, St>(
5599        mut self,
5600        scopes: I,
5601    ) -> AdminProjectLocationSubscriptionDeleteCall<'a, C>
5602    where
5603        I: IntoIterator<Item = St>,
5604        St: AsRef<str>,
5605    {
5606        self._scopes
5607            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5608        self
5609    }
5610
5611    /// Removes all scopes, and no default scope will be used either.
5612    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5613    /// for details).
5614    pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionDeleteCall<'a, C> {
5615        self._scopes.clear();
5616        self
5617    }
5618}
5619
5620/// Returns the subscription configuration.
5621///
5622/// A builder for the *projects.locations.subscriptions.get* method supported by a *admin* resource.
5623/// It is not used directly, but through a [`AdminMethods`] instance.
5624///
5625/// # Example
5626///
5627/// Instantiate a resource method builder
5628///
5629/// ```test_harness,no_run
5630/// # extern crate hyper;
5631/// # extern crate hyper_rustls;
5632/// # extern crate google_pubsublite1 as pubsublite1;
5633/// # async fn dox() {
5634/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5635///
5636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5637/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5638/// #     .with_native_roots()
5639/// #     .unwrap()
5640/// #     .https_only()
5641/// #     .enable_http2()
5642/// #     .build();
5643///
5644/// # let executor = hyper_util::rt::TokioExecutor::new();
5645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5646/// #     secret,
5647/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5648/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5649/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5650/// #     ),
5651/// # ).build().await.unwrap();
5652///
5653/// # let client = hyper_util::client::legacy::Client::builder(
5654/// #     hyper_util::rt::TokioExecutor::new()
5655/// # )
5656/// # .build(
5657/// #     hyper_rustls::HttpsConnectorBuilder::new()
5658/// #         .with_native_roots()
5659/// #         .unwrap()
5660/// #         .https_or_http()
5661/// #         .enable_http2()
5662/// #         .build()
5663/// # );
5664/// # let mut hub = PubsubLite::new(client, auth);
5665/// // You can configure optional parameters by calling the respective setters at will, and
5666/// // execute the final call using `doit()`.
5667/// // Values shown here are possibly random and not representative !
5668/// let result = hub.admin().projects_locations_subscriptions_get("name")
5669///              .doit().await;
5670/// # }
5671/// ```
5672pub struct AdminProjectLocationSubscriptionGetCall<'a, C>
5673where
5674    C: 'a,
5675{
5676    hub: &'a PubsubLite<C>,
5677    _name: String,
5678    _delegate: Option<&'a mut dyn common::Delegate>,
5679    _additional_params: HashMap<String, String>,
5680    _scopes: BTreeSet<String>,
5681}
5682
5683impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionGetCall<'a, C> {}
5684
5685impl<'a, C> AdminProjectLocationSubscriptionGetCall<'a, C>
5686where
5687    C: common::Connector,
5688{
5689    /// Perform the operation you have build so far.
5690    pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
5691        use std::borrow::Cow;
5692        use std::io::{Read, Seek};
5693
5694        use common::{url::Params, ToParts};
5695        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5696
5697        let mut dd = common::DefaultDelegate;
5698        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5699        dlg.begin(common::MethodInfo {
5700            id: "pubsublite.admin.projects.locations.subscriptions.get",
5701            http_method: hyper::Method::GET,
5702        });
5703
5704        for &field in ["alt", "name"].iter() {
5705            if self._additional_params.contains_key(field) {
5706                dlg.finished(false);
5707                return Err(common::Error::FieldClash(field));
5708            }
5709        }
5710
5711        let mut params = Params::with_capacity(3 + self._additional_params.len());
5712        params.push("name", self._name);
5713
5714        params.extend(self._additional_params.iter());
5715
5716        params.push("alt", "json");
5717        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
5718        if self._scopes.is_empty() {
5719            self._scopes
5720                .insert(Scope::CloudPlatform.as_ref().to_string());
5721        }
5722
5723        #[allow(clippy::single_element_loop)]
5724        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5725            url = params.uri_replacement(url, param_name, find_this, true);
5726        }
5727        {
5728            let to_remove = ["name"];
5729            params.remove_params(&to_remove);
5730        }
5731
5732        let url = params.parse_with_url(&url);
5733
5734        loop {
5735            let token = match self
5736                .hub
5737                .auth
5738                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5739                .await
5740            {
5741                Ok(token) => token,
5742                Err(e) => match dlg.token(e) {
5743                    Ok(token) => token,
5744                    Err(e) => {
5745                        dlg.finished(false);
5746                        return Err(common::Error::MissingToken(e));
5747                    }
5748                },
5749            };
5750            let mut req_result = {
5751                let client = &self.hub.client;
5752                dlg.pre_request();
5753                let mut req_builder = hyper::Request::builder()
5754                    .method(hyper::Method::GET)
5755                    .uri(url.as_str())
5756                    .header(USER_AGENT, self.hub._user_agent.clone());
5757
5758                if let Some(token) = token.as_ref() {
5759                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5760                }
5761
5762                let request = req_builder
5763                    .header(CONTENT_LENGTH, 0_u64)
5764                    .body(common::to_body::<String>(None));
5765
5766                client.request(request.unwrap()).await
5767            };
5768
5769            match req_result {
5770                Err(err) => {
5771                    if let common::Retry::After(d) = dlg.http_error(&err) {
5772                        sleep(d).await;
5773                        continue;
5774                    }
5775                    dlg.finished(false);
5776                    return Err(common::Error::HttpError(err));
5777                }
5778                Ok(res) => {
5779                    let (mut parts, body) = res.into_parts();
5780                    let mut body = common::Body::new(body);
5781                    if !parts.status.is_success() {
5782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5783                        let error = serde_json::from_str(&common::to_string(&bytes));
5784                        let response = common::to_response(parts, bytes.into());
5785
5786                        if let common::Retry::After(d) =
5787                            dlg.http_failure(&response, error.as_ref().ok())
5788                        {
5789                            sleep(d).await;
5790                            continue;
5791                        }
5792
5793                        dlg.finished(false);
5794
5795                        return Err(match error {
5796                            Ok(value) => common::Error::BadRequest(value),
5797                            _ => common::Error::Failure(response),
5798                        });
5799                    }
5800                    let response = {
5801                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5802                        let encoded = common::to_string(&bytes);
5803                        match serde_json::from_str(&encoded) {
5804                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5805                            Err(error) => {
5806                                dlg.response_json_decode_error(&encoded, &error);
5807                                return Err(common::Error::JsonDecodeError(
5808                                    encoded.to_string(),
5809                                    error,
5810                                ));
5811                            }
5812                        }
5813                    };
5814
5815                    dlg.finished(true);
5816                    return Ok(response);
5817                }
5818            }
5819        }
5820    }
5821
5822    /// Required. The name of the subscription whose configuration to return.
5823    ///
5824    /// Sets the *name* path property to the given value.
5825    ///
5826    /// Even though the property as already been set when instantiating this call,
5827    /// we provide this method for API completeness.
5828    pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
5829        self._name = new_value.to_string();
5830        self
5831    }
5832    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5833    /// while executing the actual API request.
5834    ///
5835    /// ````text
5836    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5837    /// ````
5838    ///
5839    /// Sets the *delegate* property to the given value.
5840    pub fn delegate(
5841        mut self,
5842        new_value: &'a mut dyn common::Delegate,
5843    ) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
5844        self._delegate = Some(new_value);
5845        self
5846    }
5847
5848    /// Set any additional parameter of the query string used in the request.
5849    /// It should be used to set parameters which are not yet available through their own
5850    /// setters.
5851    ///
5852    /// Please note that this method must not be used to set any of the known parameters
5853    /// which have their own setter method. If done anyway, the request will fail.
5854    ///
5855    /// # Additional Parameters
5856    ///
5857    /// * *$.xgafv* (query-string) - V1 error format.
5858    /// * *access_token* (query-string) - OAuth access token.
5859    /// * *alt* (query-string) - Data format for response.
5860    /// * *callback* (query-string) - JSONP
5861    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5862    /// * *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.
5863    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5864    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5865    /// * *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.
5866    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5867    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5868    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionGetCall<'a, C>
5869    where
5870        T: AsRef<str>,
5871    {
5872        self._additional_params
5873            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5874        self
5875    }
5876
5877    /// Identifies the authorization scope for the method you are building.
5878    ///
5879    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5880    /// [`Scope::CloudPlatform`].
5881    ///
5882    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5883    /// tokens for more than one scope.
5884    ///
5885    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5886    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5887    /// sufficient, a read-write scope will do as well.
5888    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionGetCall<'a, C>
5889    where
5890        St: AsRef<str>,
5891    {
5892        self._scopes.insert(String::from(scope.as_ref()));
5893        self
5894    }
5895    /// Identifies the authorization scope(s) for the method you are building.
5896    ///
5897    /// See [`Self::add_scope()`] for details.
5898    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationSubscriptionGetCall<'a, C>
5899    where
5900        I: IntoIterator<Item = St>,
5901        St: AsRef<str>,
5902    {
5903        self._scopes
5904            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5905        self
5906    }
5907
5908    /// Removes all scopes, and no default scope will be used either.
5909    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5910    /// for details).
5911    pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionGetCall<'a, C> {
5912        self._scopes.clear();
5913        self
5914    }
5915}
5916
5917/// Returns the list of subscriptions for the given project.
5918///
5919/// A builder for the *projects.locations.subscriptions.list* method supported by a *admin* resource.
5920/// It is not used directly, but through a [`AdminMethods`] instance.
5921///
5922/// # Example
5923///
5924/// Instantiate a resource method builder
5925///
5926/// ```test_harness,no_run
5927/// # extern crate hyper;
5928/// # extern crate hyper_rustls;
5929/// # extern crate google_pubsublite1 as pubsublite1;
5930/// # async fn dox() {
5931/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5932///
5933/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5934/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5935/// #     .with_native_roots()
5936/// #     .unwrap()
5937/// #     .https_only()
5938/// #     .enable_http2()
5939/// #     .build();
5940///
5941/// # let executor = hyper_util::rt::TokioExecutor::new();
5942/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5943/// #     secret,
5944/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5945/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5946/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5947/// #     ),
5948/// # ).build().await.unwrap();
5949///
5950/// # let client = hyper_util::client::legacy::Client::builder(
5951/// #     hyper_util::rt::TokioExecutor::new()
5952/// # )
5953/// # .build(
5954/// #     hyper_rustls::HttpsConnectorBuilder::new()
5955/// #         .with_native_roots()
5956/// #         .unwrap()
5957/// #         .https_or_http()
5958/// #         .enable_http2()
5959/// #         .build()
5960/// # );
5961/// # let mut hub = PubsubLite::new(client, auth);
5962/// // You can configure optional parameters by calling the respective setters at will, and
5963/// // execute the final call using `doit()`.
5964/// // Values shown here are possibly random and not representative !
5965/// let result = hub.admin().projects_locations_subscriptions_list("parent")
5966///              .page_token("est")
5967///              .page_size(-50)
5968///              .doit().await;
5969/// # }
5970/// ```
5971pub struct AdminProjectLocationSubscriptionListCall<'a, C>
5972where
5973    C: 'a,
5974{
5975    hub: &'a PubsubLite<C>,
5976    _parent: String,
5977    _page_token: Option<String>,
5978    _page_size: Option<i32>,
5979    _delegate: Option<&'a mut dyn common::Delegate>,
5980    _additional_params: HashMap<String, String>,
5981    _scopes: BTreeSet<String>,
5982}
5983
5984impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionListCall<'a, C> {}
5985
5986impl<'a, C> AdminProjectLocationSubscriptionListCall<'a, C>
5987where
5988    C: common::Connector,
5989{
5990    /// Perform the operation you have build so far.
5991    pub async fn doit(mut self) -> common::Result<(common::Response, ListSubscriptionsResponse)> {
5992        use std::borrow::Cow;
5993        use std::io::{Read, Seek};
5994
5995        use common::{url::Params, ToParts};
5996        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5997
5998        let mut dd = common::DefaultDelegate;
5999        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6000        dlg.begin(common::MethodInfo {
6001            id: "pubsublite.admin.projects.locations.subscriptions.list",
6002            http_method: hyper::Method::GET,
6003        });
6004
6005        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6006            if self._additional_params.contains_key(field) {
6007                dlg.finished(false);
6008                return Err(common::Error::FieldClash(field));
6009            }
6010        }
6011
6012        let mut params = Params::with_capacity(5 + self._additional_params.len());
6013        params.push("parent", self._parent);
6014        if let Some(value) = self._page_token.as_ref() {
6015            params.push("pageToken", value);
6016        }
6017        if let Some(value) = self._page_size.as_ref() {
6018            params.push("pageSize", value.to_string());
6019        }
6020
6021        params.extend(self._additional_params.iter());
6022
6023        params.push("alt", "json");
6024        let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/subscriptions";
6025        if self._scopes.is_empty() {
6026            self._scopes
6027                .insert(Scope::CloudPlatform.as_ref().to_string());
6028        }
6029
6030        #[allow(clippy::single_element_loop)]
6031        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6032            url = params.uri_replacement(url, param_name, find_this, true);
6033        }
6034        {
6035            let to_remove = ["parent"];
6036            params.remove_params(&to_remove);
6037        }
6038
6039        let url = params.parse_with_url(&url);
6040
6041        loop {
6042            let token = match self
6043                .hub
6044                .auth
6045                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6046                .await
6047            {
6048                Ok(token) => token,
6049                Err(e) => match dlg.token(e) {
6050                    Ok(token) => token,
6051                    Err(e) => {
6052                        dlg.finished(false);
6053                        return Err(common::Error::MissingToken(e));
6054                    }
6055                },
6056            };
6057            let mut req_result = {
6058                let client = &self.hub.client;
6059                dlg.pre_request();
6060                let mut req_builder = hyper::Request::builder()
6061                    .method(hyper::Method::GET)
6062                    .uri(url.as_str())
6063                    .header(USER_AGENT, self.hub._user_agent.clone());
6064
6065                if let Some(token) = token.as_ref() {
6066                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6067                }
6068
6069                let request = req_builder
6070                    .header(CONTENT_LENGTH, 0_u64)
6071                    .body(common::to_body::<String>(None));
6072
6073                client.request(request.unwrap()).await
6074            };
6075
6076            match req_result {
6077                Err(err) => {
6078                    if let common::Retry::After(d) = dlg.http_error(&err) {
6079                        sleep(d).await;
6080                        continue;
6081                    }
6082                    dlg.finished(false);
6083                    return Err(common::Error::HttpError(err));
6084                }
6085                Ok(res) => {
6086                    let (mut parts, body) = res.into_parts();
6087                    let mut body = common::Body::new(body);
6088                    if !parts.status.is_success() {
6089                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6090                        let error = serde_json::from_str(&common::to_string(&bytes));
6091                        let response = common::to_response(parts, bytes.into());
6092
6093                        if let common::Retry::After(d) =
6094                            dlg.http_failure(&response, error.as_ref().ok())
6095                        {
6096                            sleep(d).await;
6097                            continue;
6098                        }
6099
6100                        dlg.finished(false);
6101
6102                        return Err(match error {
6103                            Ok(value) => common::Error::BadRequest(value),
6104                            _ => common::Error::Failure(response),
6105                        });
6106                    }
6107                    let response = {
6108                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6109                        let encoded = common::to_string(&bytes);
6110                        match serde_json::from_str(&encoded) {
6111                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6112                            Err(error) => {
6113                                dlg.response_json_decode_error(&encoded, &error);
6114                                return Err(common::Error::JsonDecodeError(
6115                                    encoded.to_string(),
6116                                    error,
6117                                ));
6118                            }
6119                        }
6120                    };
6121
6122                    dlg.finished(true);
6123                    return Ok(response);
6124                }
6125            }
6126        }
6127    }
6128
6129    /// Required. The parent whose subscriptions are to be listed. Structured like `projects/{project_number}/locations/{location}`.
6130    ///
6131    /// Sets the *parent* path property to the given value.
6132    ///
6133    /// Even though the property as already been set when instantiating this call,
6134    /// we provide this method for API completeness.
6135    pub fn parent(mut self, new_value: &str) -> AdminProjectLocationSubscriptionListCall<'a, C> {
6136        self._parent = new_value.to_string();
6137        self
6138    }
6139    /// 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.
6140    ///
6141    /// Sets the *page token* query property to the given value.
6142    pub fn page_token(
6143        mut self,
6144        new_value: &str,
6145    ) -> AdminProjectLocationSubscriptionListCall<'a, C> {
6146        self._page_token = Some(new_value.to_string());
6147        self
6148    }
6149    /// 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.
6150    ///
6151    /// Sets the *page size* query property to the given value.
6152    pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationSubscriptionListCall<'a, C> {
6153        self._page_size = Some(new_value);
6154        self
6155    }
6156    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6157    /// while executing the actual API request.
6158    ///
6159    /// ````text
6160    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6161    /// ````
6162    ///
6163    /// Sets the *delegate* property to the given value.
6164    pub fn delegate(
6165        mut self,
6166        new_value: &'a mut dyn common::Delegate,
6167    ) -> AdminProjectLocationSubscriptionListCall<'a, C> {
6168        self._delegate = Some(new_value);
6169        self
6170    }
6171
6172    /// Set any additional parameter of the query string used in the request.
6173    /// It should be used to set parameters which are not yet available through their own
6174    /// setters.
6175    ///
6176    /// Please note that this method must not be used to set any of the known parameters
6177    /// which have their own setter method. If done anyway, the request will fail.
6178    ///
6179    /// # Additional Parameters
6180    ///
6181    /// * *$.xgafv* (query-string) - V1 error format.
6182    /// * *access_token* (query-string) - OAuth access token.
6183    /// * *alt* (query-string) - Data format for response.
6184    /// * *callback* (query-string) - JSONP
6185    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6186    /// * *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.
6187    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6188    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6189    /// * *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.
6190    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6191    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6192    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionListCall<'a, C>
6193    where
6194        T: AsRef<str>,
6195    {
6196        self._additional_params
6197            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6198        self
6199    }
6200
6201    /// Identifies the authorization scope for the method you are building.
6202    ///
6203    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6204    /// [`Scope::CloudPlatform`].
6205    ///
6206    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6207    /// tokens for more than one scope.
6208    ///
6209    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6210    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6211    /// sufficient, a read-write scope will do as well.
6212    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionListCall<'a, C>
6213    where
6214        St: AsRef<str>,
6215    {
6216        self._scopes.insert(String::from(scope.as_ref()));
6217        self
6218    }
6219    /// Identifies the authorization scope(s) for the method you are building.
6220    ///
6221    /// See [`Self::add_scope()`] for details.
6222    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationSubscriptionListCall<'a, C>
6223    where
6224        I: IntoIterator<Item = St>,
6225        St: AsRef<str>,
6226    {
6227        self._scopes
6228            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6229        self
6230    }
6231
6232    /// Removes all scopes, and no default scope will be used either.
6233    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6234    /// for details).
6235    pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionListCall<'a, C> {
6236        self._scopes.clear();
6237        self
6238    }
6239}
6240
6241/// Updates properties of the specified subscription.
6242///
6243/// A builder for the *projects.locations.subscriptions.patch* method supported by a *admin* resource.
6244/// It is not used directly, but through a [`AdminMethods`] instance.
6245///
6246/// # Example
6247///
6248/// Instantiate a resource method builder
6249///
6250/// ```test_harness,no_run
6251/// # extern crate hyper;
6252/// # extern crate hyper_rustls;
6253/// # extern crate google_pubsublite1 as pubsublite1;
6254/// use pubsublite1::api::Subscription;
6255/// # async fn dox() {
6256/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6257///
6258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6260/// #     .with_native_roots()
6261/// #     .unwrap()
6262/// #     .https_only()
6263/// #     .enable_http2()
6264/// #     .build();
6265///
6266/// # let executor = hyper_util::rt::TokioExecutor::new();
6267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6268/// #     secret,
6269/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6270/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6271/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6272/// #     ),
6273/// # ).build().await.unwrap();
6274///
6275/// # let client = hyper_util::client::legacy::Client::builder(
6276/// #     hyper_util::rt::TokioExecutor::new()
6277/// # )
6278/// # .build(
6279/// #     hyper_rustls::HttpsConnectorBuilder::new()
6280/// #         .with_native_roots()
6281/// #         .unwrap()
6282/// #         .https_or_http()
6283/// #         .enable_http2()
6284/// #         .build()
6285/// # );
6286/// # let mut hub = PubsubLite::new(client, auth);
6287/// // As the method needs a request, you would usually fill it with the desired information
6288/// // into the respective structure. Some of the parts shown here might not be applicable !
6289/// // Values shown here are possibly random and not representative !
6290/// let mut req = Subscription::default();
6291///
6292/// // You can configure optional parameters by calling the respective setters at will, and
6293/// // execute the final call using `doit()`.
6294/// // Values shown here are possibly random and not representative !
6295/// let result = hub.admin().projects_locations_subscriptions_patch(req, "name")
6296///              .update_mask(FieldMask::new::<&str>(&[]))
6297///              .doit().await;
6298/// # }
6299/// ```
6300pub struct AdminProjectLocationSubscriptionPatchCall<'a, C>
6301where
6302    C: 'a,
6303{
6304    hub: &'a PubsubLite<C>,
6305    _request: Subscription,
6306    _name: String,
6307    _update_mask: Option<common::FieldMask>,
6308    _delegate: Option<&'a mut dyn common::Delegate>,
6309    _additional_params: HashMap<String, String>,
6310    _scopes: BTreeSet<String>,
6311}
6312
6313impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionPatchCall<'a, C> {}
6314
6315impl<'a, C> AdminProjectLocationSubscriptionPatchCall<'a, C>
6316where
6317    C: common::Connector,
6318{
6319    /// Perform the operation you have build so far.
6320    pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
6321        use std::borrow::Cow;
6322        use std::io::{Read, Seek};
6323
6324        use common::{url::Params, ToParts};
6325        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6326
6327        let mut dd = common::DefaultDelegate;
6328        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6329        dlg.begin(common::MethodInfo {
6330            id: "pubsublite.admin.projects.locations.subscriptions.patch",
6331            http_method: hyper::Method::PATCH,
6332        });
6333
6334        for &field in ["alt", "name", "updateMask"].iter() {
6335            if self._additional_params.contains_key(field) {
6336                dlg.finished(false);
6337                return Err(common::Error::FieldClash(field));
6338            }
6339        }
6340
6341        let mut params = Params::with_capacity(5 + self._additional_params.len());
6342        params.push("name", self._name);
6343        if let Some(value) = self._update_mask.as_ref() {
6344            params.push("updateMask", value.to_string());
6345        }
6346
6347        params.extend(self._additional_params.iter());
6348
6349        params.push("alt", "json");
6350        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
6351        if self._scopes.is_empty() {
6352            self._scopes
6353                .insert(Scope::CloudPlatform.as_ref().to_string());
6354        }
6355
6356        #[allow(clippy::single_element_loop)]
6357        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6358            url = params.uri_replacement(url, param_name, find_this, true);
6359        }
6360        {
6361            let to_remove = ["name"];
6362            params.remove_params(&to_remove);
6363        }
6364
6365        let url = params.parse_with_url(&url);
6366
6367        let mut json_mime_type = mime::APPLICATION_JSON;
6368        let mut request_value_reader = {
6369            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6370            common::remove_json_null_values(&mut value);
6371            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6372            serde_json::to_writer(&mut dst, &value).unwrap();
6373            dst
6374        };
6375        let request_size = request_value_reader
6376            .seek(std::io::SeekFrom::End(0))
6377            .unwrap();
6378        request_value_reader
6379            .seek(std::io::SeekFrom::Start(0))
6380            .unwrap();
6381
6382        loop {
6383            let token = match self
6384                .hub
6385                .auth
6386                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6387                .await
6388            {
6389                Ok(token) => token,
6390                Err(e) => match dlg.token(e) {
6391                    Ok(token) => token,
6392                    Err(e) => {
6393                        dlg.finished(false);
6394                        return Err(common::Error::MissingToken(e));
6395                    }
6396                },
6397            };
6398            request_value_reader
6399                .seek(std::io::SeekFrom::Start(0))
6400                .unwrap();
6401            let mut req_result = {
6402                let client = &self.hub.client;
6403                dlg.pre_request();
6404                let mut req_builder = hyper::Request::builder()
6405                    .method(hyper::Method::PATCH)
6406                    .uri(url.as_str())
6407                    .header(USER_AGENT, self.hub._user_agent.clone());
6408
6409                if let Some(token) = token.as_ref() {
6410                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6411                }
6412
6413                let request = req_builder
6414                    .header(CONTENT_TYPE, json_mime_type.to_string())
6415                    .header(CONTENT_LENGTH, request_size as u64)
6416                    .body(common::to_body(
6417                        request_value_reader.get_ref().clone().into(),
6418                    ));
6419
6420                client.request(request.unwrap()).await
6421            };
6422
6423            match req_result {
6424                Err(err) => {
6425                    if let common::Retry::After(d) = dlg.http_error(&err) {
6426                        sleep(d).await;
6427                        continue;
6428                    }
6429                    dlg.finished(false);
6430                    return Err(common::Error::HttpError(err));
6431                }
6432                Ok(res) => {
6433                    let (mut parts, body) = res.into_parts();
6434                    let mut body = common::Body::new(body);
6435                    if !parts.status.is_success() {
6436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6437                        let error = serde_json::from_str(&common::to_string(&bytes));
6438                        let response = common::to_response(parts, bytes.into());
6439
6440                        if let common::Retry::After(d) =
6441                            dlg.http_failure(&response, error.as_ref().ok())
6442                        {
6443                            sleep(d).await;
6444                            continue;
6445                        }
6446
6447                        dlg.finished(false);
6448
6449                        return Err(match error {
6450                            Ok(value) => common::Error::BadRequest(value),
6451                            _ => common::Error::Failure(response),
6452                        });
6453                    }
6454                    let response = {
6455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6456                        let encoded = common::to_string(&bytes);
6457                        match serde_json::from_str(&encoded) {
6458                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6459                            Err(error) => {
6460                                dlg.response_json_decode_error(&encoded, &error);
6461                                return Err(common::Error::JsonDecodeError(
6462                                    encoded.to_string(),
6463                                    error,
6464                                ));
6465                            }
6466                        }
6467                    };
6468
6469                    dlg.finished(true);
6470                    return Ok(response);
6471                }
6472            }
6473        }
6474    }
6475
6476    ///
6477    /// Sets the *request* property to the given value.
6478    ///
6479    /// Even though the property as already been set when instantiating this call,
6480    /// we provide this method for API completeness.
6481    pub fn request(
6482        mut self,
6483        new_value: Subscription,
6484    ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6485        self._request = new_value;
6486        self
6487    }
6488    /// The name of the subscription. Structured like: projects/{project_number}/locations/{location}/subscriptions/{subscription_id}
6489    ///
6490    /// Sets the *name* path property to the given value.
6491    ///
6492    /// Even though the property as already been set when instantiating this call,
6493    /// we provide this method for API completeness.
6494    pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6495        self._name = new_value.to_string();
6496        self
6497    }
6498    /// Required. A mask specifying the subscription fields to change.
6499    ///
6500    /// Sets the *update mask* query property to the given value.
6501    pub fn update_mask(
6502        mut self,
6503        new_value: common::FieldMask,
6504    ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6505        self._update_mask = Some(new_value);
6506        self
6507    }
6508    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6509    /// while executing the actual API request.
6510    ///
6511    /// ````text
6512    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6513    /// ````
6514    ///
6515    /// Sets the *delegate* property to the given value.
6516    pub fn delegate(
6517        mut self,
6518        new_value: &'a mut dyn common::Delegate,
6519    ) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6520        self._delegate = Some(new_value);
6521        self
6522    }
6523
6524    /// Set any additional parameter of the query string used in the request.
6525    /// It should be used to set parameters which are not yet available through their own
6526    /// setters.
6527    ///
6528    /// Please note that this method must not be used to set any of the known parameters
6529    /// which have their own setter method. If done anyway, the request will fail.
6530    ///
6531    /// # Additional Parameters
6532    ///
6533    /// * *$.xgafv* (query-string) - V1 error format.
6534    /// * *access_token* (query-string) - OAuth access token.
6535    /// * *alt* (query-string) - Data format for response.
6536    /// * *callback* (query-string) - JSONP
6537    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6538    /// * *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.
6539    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6540    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6541    /// * *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.
6542    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6543    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6544    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionPatchCall<'a, C>
6545    where
6546        T: AsRef<str>,
6547    {
6548        self._additional_params
6549            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6550        self
6551    }
6552
6553    /// Identifies the authorization scope for the method you are building.
6554    ///
6555    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6556    /// [`Scope::CloudPlatform`].
6557    ///
6558    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6559    /// tokens for more than one scope.
6560    ///
6561    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6562    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6563    /// sufficient, a read-write scope will do as well.
6564    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionPatchCall<'a, C>
6565    where
6566        St: AsRef<str>,
6567    {
6568        self._scopes.insert(String::from(scope.as_ref()));
6569        self
6570    }
6571    /// Identifies the authorization scope(s) for the method you are building.
6572    ///
6573    /// See [`Self::add_scope()`] for details.
6574    pub fn add_scopes<I, St>(
6575        mut self,
6576        scopes: I,
6577    ) -> AdminProjectLocationSubscriptionPatchCall<'a, C>
6578    where
6579        I: IntoIterator<Item = St>,
6580        St: AsRef<str>,
6581    {
6582        self._scopes
6583            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6584        self
6585    }
6586
6587    /// Removes all scopes, and no default scope will be used either.
6588    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6589    /// for details).
6590    pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionPatchCall<'a, C> {
6591        self._scopes.clear();
6592        self
6593    }
6594}
6595
6596/// 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.
6597///
6598/// A builder for the *projects.locations.subscriptions.seek* method supported by a *admin* resource.
6599/// It is not used directly, but through a [`AdminMethods`] instance.
6600///
6601/// # Example
6602///
6603/// Instantiate a resource method builder
6604///
6605/// ```test_harness,no_run
6606/// # extern crate hyper;
6607/// # extern crate hyper_rustls;
6608/// # extern crate google_pubsublite1 as pubsublite1;
6609/// use pubsublite1::api::SeekSubscriptionRequest;
6610/// # async fn dox() {
6611/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6612///
6613/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6614/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6615/// #     .with_native_roots()
6616/// #     .unwrap()
6617/// #     .https_only()
6618/// #     .enable_http2()
6619/// #     .build();
6620///
6621/// # let executor = hyper_util::rt::TokioExecutor::new();
6622/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6623/// #     secret,
6624/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6625/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6626/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6627/// #     ),
6628/// # ).build().await.unwrap();
6629///
6630/// # let client = hyper_util::client::legacy::Client::builder(
6631/// #     hyper_util::rt::TokioExecutor::new()
6632/// # )
6633/// # .build(
6634/// #     hyper_rustls::HttpsConnectorBuilder::new()
6635/// #         .with_native_roots()
6636/// #         .unwrap()
6637/// #         .https_or_http()
6638/// #         .enable_http2()
6639/// #         .build()
6640/// # );
6641/// # let mut hub = PubsubLite::new(client, auth);
6642/// // As the method needs a request, you would usually fill it with the desired information
6643/// // into the respective structure. Some of the parts shown here might not be applicable !
6644/// // Values shown here are possibly random and not representative !
6645/// let mut req = SeekSubscriptionRequest::default();
6646///
6647/// // You can configure optional parameters by calling the respective setters at will, and
6648/// // execute the final call using `doit()`.
6649/// // Values shown here are possibly random and not representative !
6650/// let result = hub.admin().projects_locations_subscriptions_seek(req, "name")
6651///              .doit().await;
6652/// # }
6653/// ```
6654pub struct AdminProjectLocationSubscriptionSeekCall<'a, C>
6655where
6656    C: 'a,
6657{
6658    hub: &'a PubsubLite<C>,
6659    _request: SeekSubscriptionRequest,
6660    _name: String,
6661    _delegate: Option<&'a mut dyn common::Delegate>,
6662    _additional_params: HashMap<String, String>,
6663    _scopes: BTreeSet<String>,
6664}
6665
6666impl<'a, C> common::CallBuilder for AdminProjectLocationSubscriptionSeekCall<'a, C> {}
6667
6668impl<'a, C> AdminProjectLocationSubscriptionSeekCall<'a, C>
6669where
6670    C: common::Connector,
6671{
6672    /// Perform the operation you have build so far.
6673    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6674        use std::borrow::Cow;
6675        use std::io::{Read, Seek};
6676
6677        use common::{url::Params, ToParts};
6678        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6679
6680        let mut dd = common::DefaultDelegate;
6681        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6682        dlg.begin(common::MethodInfo {
6683            id: "pubsublite.admin.projects.locations.subscriptions.seek",
6684            http_method: hyper::Method::POST,
6685        });
6686
6687        for &field in ["alt", "name"].iter() {
6688            if self._additional_params.contains_key(field) {
6689                dlg.finished(false);
6690                return Err(common::Error::FieldClash(field));
6691            }
6692        }
6693
6694        let mut params = Params::with_capacity(4 + self._additional_params.len());
6695        params.push("name", self._name);
6696
6697        params.extend(self._additional_params.iter());
6698
6699        params.push("alt", "json");
6700        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}:seek";
6701        if self._scopes.is_empty() {
6702            self._scopes
6703                .insert(Scope::CloudPlatform.as_ref().to_string());
6704        }
6705
6706        #[allow(clippy::single_element_loop)]
6707        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6708            url = params.uri_replacement(url, param_name, find_this, true);
6709        }
6710        {
6711            let to_remove = ["name"];
6712            params.remove_params(&to_remove);
6713        }
6714
6715        let url = params.parse_with_url(&url);
6716
6717        let mut json_mime_type = mime::APPLICATION_JSON;
6718        let mut request_value_reader = {
6719            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6720            common::remove_json_null_values(&mut value);
6721            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6722            serde_json::to_writer(&mut dst, &value).unwrap();
6723            dst
6724        };
6725        let request_size = request_value_reader
6726            .seek(std::io::SeekFrom::End(0))
6727            .unwrap();
6728        request_value_reader
6729            .seek(std::io::SeekFrom::Start(0))
6730            .unwrap();
6731
6732        loop {
6733            let token = match self
6734                .hub
6735                .auth
6736                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6737                .await
6738            {
6739                Ok(token) => token,
6740                Err(e) => match dlg.token(e) {
6741                    Ok(token) => token,
6742                    Err(e) => {
6743                        dlg.finished(false);
6744                        return Err(common::Error::MissingToken(e));
6745                    }
6746                },
6747            };
6748            request_value_reader
6749                .seek(std::io::SeekFrom::Start(0))
6750                .unwrap();
6751            let mut req_result = {
6752                let client = &self.hub.client;
6753                dlg.pre_request();
6754                let mut req_builder = hyper::Request::builder()
6755                    .method(hyper::Method::POST)
6756                    .uri(url.as_str())
6757                    .header(USER_AGENT, self.hub._user_agent.clone());
6758
6759                if let Some(token) = token.as_ref() {
6760                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6761                }
6762
6763                let request = req_builder
6764                    .header(CONTENT_TYPE, json_mime_type.to_string())
6765                    .header(CONTENT_LENGTH, request_size as u64)
6766                    .body(common::to_body(
6767                        request_value_reader.get_ref().clone().into(),
6768                    ));
6769
6770                client.request(request.unwrap()).await
6771            };
6772
6773            match req_result {
6774                Err(err) => {
6775                    if let common::Retry::After(d) = dlg.http_error(&err) {
6776                        sleep(d).await;
6777                        continue;
6778                    }
6779                    dlg.finished(false);
6780                    return Err(common::Error::HttpError(err));
6781                }
6782                Ok(res) => {
6783                    let (mut parts, body) = res.into_parts();
6784                    let mut body = common::Body::new(body);
6785                    if !parts.status.is_success() {
6786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6787                        let error = serde_json::from_str(&common::to_string(&bytes));
6788                        let response = common::to_response(parts, bytes.into());
6789
6790                        if let common::Retry::After(d) =
6791                            dlg.http_failure(&response, error.as_ref().ok())
6792                        {
6793                            sleep(d).await;
6794                            continue;
6795                        }
6796
6797                        dlg.finished(false);
6798
6799                        return Err(match error {
6800                            Ok(value) => common::Error::BadRequest(value),
6801                            _ => common::Error::Failure(response),
6802                        });
6803                    }
6804                    let response = {
6805                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6806                        let encoded = common::to_string(&bytes);
6807                        match serde_json::from_str(&encoded) {
6808                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6809                            Err(error) => {
6810                                dlg.response_json_decode_error(&encoded, &error);
6811                                return Err(common::Error::JsonDecodeError(
6812                                    encoded.to_string(),
6813                                    error,
6814                                ));
6815                            }
6816                        }
6817                    };
6818
6819                    dlg.finished(true);
6820                    return Ok(response);
6821                }
6822            }
6823        }
6824    }
6825
6826    ///
6827    /// Sets the *request* property to the given value.
6828    ///
6829    /// Even though the property as already been set when instantiating this call,
6830    /// we provide this method for API completeness.
6831    pub fn request(
6832        mut self,
6833        new_value: SeekSubscriptionRequest,
6834    ) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6835        self._request = new_value;
6836        self
6837    }
6838    /// Required. The name of the subscription to seek.
6839    ///
6840    /// Sets the *name* path property to the given value.
6841    ///
6842    /// Even though the property as already been set when instantiating this call,
6843    /// we provide this method for API completeness.
6844    pub fn name(mut self, new_value: &str) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6845        self._name = new_value.to_string();
6846        self
6847    }
6848    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6849    /// while executing the actual API request.
6850    ///
6851    /// ````text
6852    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6853    /// ````
6854    ///
6855    /// Sets the *delegate* property to the given value.
6856    pub fn delegate(
6857        mut self,
6858        new_value: &'a mut dyn common::Delegate,
6859    ) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6860        self._delegate = Some(new_value);
6861        self
6862    }
6863
6864    /// Set any additional parameter of the query string used in the request.
6865    /// It should be used to set parameters which are not yet available through their own
6866    /// setters.
6867    ///
6868    /// Please note that this method must not be used to set any of the known parameters
6869    /// which have their own setter method. If done anyway, the request will fail.
6870    ///
6871    /// # Additional Parameters
6872    ///
6873    /// * *$.xgafv* (query-string) - V1 error format.
6874    /// * *access_token* (query-string) - OAuth access token.
6875    /// * *alt* (query-string) - Data format for response.
6876    /// * *callback* (query-string) - JSONP
6877    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6878    /// * *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.
6879    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6880    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6881    /// * *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.
6882    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6883    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6884    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationSubscriptionSeekCall<'a, C>
6885    where
6886        T: AsRef<str>,
6887    {
6888        self._additional_params
6889            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6890        self
6891    }
6892
6893    /// Identifies the authorization scope for the method you are building.
6894    ///
6895    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6896    /// [`Scope::CloudPlatform`].
6897    ///
6898    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6899    /// tokens for more than one scope.
6900    ///
6901    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6902    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6903    /// sufficient, a read-write scope will do as well.
6904    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationSubscriptionSeekCall<'a, C>
6905    where
6906        St: AsRef<str>,
6907    {
6908        self._scopes.insert(String::from(scope.as_ref()));
6909        self
6910    }
6911    /// Identifies the authorization scope(s) for the method you are building.
6912    ///
6913    /// See [`Self::add_scope()`] for details.
6914    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationSubscriptionSeekCall<'a, C>
6915    where
6916        I: IntoIterator<Item = St>,
6917        St: AsRef<str>,
6918    {
6919        self._scopes
6920            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6921        self
6922    }
6923
6924    /// Removes all scopes, and no default scope will be used either.
6925    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6926    /// for details).
6927    pub fn clear_scopes(mut self) -> AdminProjectLocationSubscriptionSeekCall<'a, C> {
6928        self._scopes.clear();
6929        self
6930    }
6931}
6932
6933/// Lists the subscriptions attached to the specified topic.
6934///
6935/// A builder for the *projects.locations.topics.subscriptions.list* method supported by a *admin* resource.
6936/// It is not used directly, but through a [`AdminMethods`] instance.
6937///
6938/// # Example
6939///
6940/// Instantiate a resource method builder
6941///
6942/// ```test_harness,no_run
6943/// # extern crate hyper;
6944/// # extern crate hyper_rustls;
6945/// # extern crate google_pubsublite1 as pubsublite1;
6946/// # async fn dox() {
6947/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6948///
6949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6950/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6951/// #     .with_native_roots()
6952/// #     .unwrap()
6953/// #     .https_only()
6954/// #     .enable_http2()
6955/// #     .build();
6956///
6957/// # let executor = hyper_util::rt::TokioExecutor::new();
6958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6959/// #     secret,
6960/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6961/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6962/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6963/// #     ),
6964/// # ).build().await.unwrap();
6965///
6966/// # let client = hyper_util::client::legacy::Client::builder(
6967/// #     hyper_util::rt::TokioExecutor::new()
6968/// # )
6969/// # .build(
6970/// #     hyper_rustls::HttpsConnectorBuilder::new()
6971/// #         .with_native_roots()
6972/// #         .unwrap()
6973/// #         .https_or_http()
6974/// #         .enable_http2()
6975/// #         .build()
6976/// # );
6977/// # let mut hub = PubsubLite::new(client, auth);
6978/// // You can configure optional parameters by calling the respective setters at will, and
6979/// // execute the final call using `doit()`.
6980/// // Values shown here are possibly random and not representative !
6981/// let result = hub.admin().projects_locations_topics_subscriptions_list("name")
6982///              .page_token("ea")
6983///              .page_size(-99)
6984///              .doit().await;
6985/// # }
6986/// ```
6987pub struct AdminProjectLocationTopicSubscriptionListCall<'a, C>
6988where
6989    C: 'a,
6990{
6991    hub: &'a PubsubLite<C>,
6992    _name: String,
6993    _page_token: Option<String>,
6994    _page_size: Option<i32>,
6995    _delegate: Option<&'a mut dyn common::Delegate>,
6996    _additional_params: HashMap<String, String>,
6997    _scopes: BTreeSet<String>,
6998}
6999
7000impl<'a, C> common::CallBuilder for AdminProjectLocationTopicSubscriptionListCall<'a, C> {}
7001
7002impl<'a, C> AdminProjectLocationTopicSubscriptionListCall<'a, C>
7003where
7004    C: common::Connector,
7005{
7006    /// Perform the operation you have build so far.
7007    pub async fn doit(
7008        mut self,
7009    ) -> common::Result<(common::Response, ListTopicSubscriptionsResponse)> {
7010        use std::borrow::Cow;
7011        use std::io::{Read, Seek};
7012
7013        use common::{url::Params, ToParts};
7014        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7015
7016        let mut dd = common::DefaultDelegate;
7017        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7018        dlg.begin(common::MethodInfo {
7019            id: "pubsublite.admin.projects.locations.topics.subscriptions.list",
7020            http_method: hyper::Method::GET,
7021        });
7022
7023        for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
7024            if self._additional_params.contains_key(field) {
7025                dlg.finished(false);
7026                return Err(common::Error::FieldClash(field));
7027            }
7028        }
7029
7030        let mut params = Params::with_capacity(5 + self._additional_params.len());
7031        params.push("name", self._name);
7032        if let Some(value) = self._page_token.as_ref() {
7033            params.push("pageToken", value);
7034        }
7035        if let Some(value) = self._page_size.as_ref() {
7036            params.push("pageSize", value.to_string());
7037        }
7038
7039        params.extend(self._additional_params.iter());
7040
7041        params.push("alt", "json");
7042        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/subscriptions";
7043        if self._scopes.is_empty() {
7044            self._scopes
7045                .insert(Scope::CloudPlatform.as_ref().to_string());
7046        }
7047
7048        #[allow(clippy::single_element_loop)]
7049        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7050            url = params.uri_replacement(url, param_name, find_this, true);
7051        }
7052        {
7053            let to_remove = ["name"];
7054            params.remove_params(&to_remove);
7055        }
7056
7057        let url = params.parse_with_url(&url);
7058
7059        loop {
7060            let token = match self
7061                .hub
7062                .auth
7063                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7064                .await
7065            {
7066                Ok(token) => token,
7067                Err(e) => match dlg.token(e) {
7068                    Ok(token) => token,
7069                    Err(e) => {
7070                        dlg.finished(false);
7071                        return Err(common::Error::MissingToken(e));
7072                    }
7073                },
7074            };
7075            let mut req_result = {
7076                let client = &self.hub.client;
7077                dlg.pre_request();
7078                let mut req_builder = hyper::Request::builder()
7079                    .method(hyper::Method::GET)
7080                    .uri(url.as_str())
7081                    .header(USER_AGENT, self.hub._user_agent.clone());
7082
7083                if let Some(token) = token.as_ref() {
7084                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7085                }
7086
7087                let request = req_builder
7088                    .header(CONTENT_LENGTH, 0_u64)
7089                    .body(common::to_body::<String>(None));
7090
7091                client.request(request.unwrap()).await
7092            };
7093
7094            match req_result {
7095                Err(err) => {
7096                    if let common::Retry::After(d) = dlg.http_error(&err) {
7097                        sleep(d).await;
7098                        continue;
7099                    }
7100                    dlg.finished(false);
7101                    return Err(common::Error::HttpError(err));
7102                }
7103                Ok(res) => {
7104                    let (mut parts, body) = res.into_parts();
7105                    let mut body = common::Body::new(body);
7106                    if !parts.status.is_success() {
7107                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7108                        let error = serde_json::from_str(&common::to_string(&bytes));
7109                        let response = common::to_response(parts, bytes.into());
7110
7111                        if let common::Retry::After(d) =
7112                            dlg.http_failure(&response, error.as_ref().ok())
7113                        {
7114                            sleep(d).await;
7115                            continue;
7116                        }
7117
7118                        dlg.finished(false);
7119
7120                        return Err(match error {
7121                            Ok(value) => common::Error::BadRequest(value),
7122                            _ => common::Error::Failure(response),
7123                        });
7124                    }
7125                    let response = {
7126                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7127                        let encoded = common::to_string(&bytes);
7128                        match serde_json::from_str(&encoded) {
7129                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7130                            Err(error) => {
7131                                dlg.response_json_decode_error(&encoded, &error);
7132                                return Err(common::Error::JsonDecodeError(
7133                                    encoded.to_string(),
7134                                    error,
7135                                ));
7136                            }
7137                        }
7138                    };
7139
7140                    dlg.finished(true);
7141                    return Ok(response);
7142                }
7143            }
7144        }
7145    }
7146
7147    /// Required. The name of the topic whose subscriptions to list.
7148    ///
7149    /// Sets the *name* path property to the given value.
7150    ///
7151    /// Even though the property as already been set when instantiating this call,
7152    /// we provide this method for API completeness.
7153    pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
7154        self._name = new_value.to_string();
7155        self
7156    }
7157    /// 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.
7158    ///
7159    /// Sets the *page token* query property to the given value.
7160    pub fn page_token(
7161        mut self,
7162        new_value: &str,
7163    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
7164        self._page_token = Some(new_value.to_string());
7165        self
7166    }
7167    /// 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.
7168    ///
7169    /// Sets the *page size* query property to the given value.
7170    pub fn page_size(
7171        mut self,
7172        new_value: i32,
7173    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
7174        self._page_size = Some(new_value);
7175        self
7176    }
7177    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7178    /// while executing the actual API request.
7179    ///
7180    /// ````text
7181    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7182    /// ````
7183    ///
7184    /// Sets the *delegate* property to the given value.
7185    pub fn delegate(
7186        mut self,
7187        new_value: &'a mut dyn common::Delegate,
7188    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
7189        self._delegate = Some(new_value);
7190        self
7191    }
7192
7193    /// Set any additional parameter of the query string used in the request.
7194    /// It should be used to set parameters which are not yet available through their own
7195    /// setters.
7196    ///
7197    /// Please note that this method must not be used to set any of the known parameters
7198    /// which have their own setter method. If done anyway, the request will fail.
7199    ///
7200    /// # Additional Parameters
7201    ///
7202    /// * *$.xgafv* (query-string) - V1 error format.
7203    /// * *access_token* (query-string) - OAuth access token.
7204    /// * *alt* (query-string) - Data format for response.
7205    /// * *callback* (query-string) - JSONP
7206    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7207    /// * *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.
7208    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7209    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7210    /// * *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.
7211    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7212    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7213    pub fn param<T>(
7214        mut self,
7215        name: T,
7216        value: T,
7217    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C>
7218    where
7219        T: AsRef<str>,
7220    {
7221        self._additional_params
7222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7223        self
7224    }
7225
7226    /// Identifies the authorization scope for the method you are building.
7227    ///
7228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7229    /// [`Scope::CloudPlatform`].
7230    ///
7231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7232    /// tokens for more than one scope.
7233    ///
7234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7236    /// sufficient, a read-write scope will do as well.
7237    pub fn add_scope<St>(
7238        mut self,
7239        scope: St,
7240    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C>
7241    where
7242        St: AsRef<str>,
7243    {
7244        self._scopes.insert(String::from(scope.as_ref()));
7245        self
7246    }
7247    /// Identifies the authorization scope(s) for the method you are building.
7248    ///
7249    /// See [`Self::add_scope()`] for details.
7250    pub fn add_scopes<I, St>(
7251        mut self,
7252        scopes: I,
7253    ) -> AdminProjectLocationTopicSubscriptionListCall<'a, C>
7254    where
7255        I: IntoIterator<Item = St>,
7256        St: AsRef<str>,
7257    {
7258        self._scopes
7259            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7260        self
7261    }
7262
7263    /// Removes all scopes, and no default scope will be used either.
7264    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7265    /// for details).
7266    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicSubscriptionListCall<'a, C> {
7267        self._scopes.clear();
7268        self
7269    }
7270}
7271
7272/// Creates a new topic.
7273///
7274/// A builder for the *projects.locations.topics.create* method supported by a *admin* resource.
7275/// It is not used directly, but through a [`AdminMethods`] instance.
7276///
7277/// # Example
7278///
7279/// Instantiate a resource method builder
7280///
7281/// ```test_harness,no_run
7282/// # extern crate hyper;
7283/// # extern crate hyper_rustls;
7284/// # extern crate google_pubsublite1 as pubsublite1;
7285/// use pubsublite1::api::Topic;
7286/// # async fn dox() {
7287/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7288///
7289/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7290/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7291/// #     .with_native_roots()
7292/// #     .unwrap()
7293/// #     .https_only()
7294/// #     .enable_http2()
7295/// #     .build();
7296///
7297/// # let executor = hyper_util::rt::TokioExecutor::new();
7298/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7299/// #     secret,
7300/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7301/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7302/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7303/// #     ),
7304/// # ).build().await.unwrap();
7305///
7306/// # let client = hyper_util::client::legacy::Client::builder(
7307/// #     hyper_util::rt::TokioExecutor::new()
7308/// # )
7309/// # .build(
7310/// #     hyper_rustls::HttpsConnectorBuilder::new()
7311/// #         .with_native_roots()
7312/// #         .unwrap()
7313/// #         .https_or_http()
7314/// #         .enable_http2()
7315/// #         .build()
7316/// # );
7317/// # let mut hub = PubsubLite::new(client, auth);
7318/// // As the method needs a request, you would usually fill it with the desired information
7319/// // into the respective structure. Some of the parts shown here might not be applicable !
7320/// // Values shown here are possibly random and not representative !
7321/// let mut req = Topic::default();
7322///
7323/// // You can configure optional parameters by calling the respective setters at will, and
7324/// // execute the final call using `doit()`.
7325/// // Values shown here are possibly random and not representative !
7326/// let result = hub.admin().projects_locations_topics_create(req, "parent")
7327///              .topic_id("eos")
7328///              .doit().await;
7329/// # }
7330/// ```
7331pub struct AdminProjectLocationTopicCreateCall<'a, C>
7332where
7333    C: 'a,
7334{
7335    hub: &'a PubsubLite<C>,
7336    _request: Topic,
7337    _parent: String,
7338    _topic_id: Option<String>,
7339    _delegate: Option<&'a mut dyn common::Delegate>,
7340    _additional_params: HashMap<String, String>,
7341    _scopes: BTreeSet<String>,
7342}
7343
7344impl<'a, C> common::CallBuilder for AdminProjectLocationTopicCreateCall<'a, C> {}
7345
7346impl<'a, C> AdminProjectLocationTopicCreateCall<'a, C>
7347where
7348    C: common::Connector,
7349{
7350    /// Perform the operation you have build so far.
7351    pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
7352        use std::borrow::Cow;
7353        use std::io::{Read, Seek};
7354
7355        use common::{url::Params, ToParts};
7356        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7357
7358        let mut dd = common::DefaultDelegate;
7359        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7360        dlg.begin(common::MethodInfo {
7361            id: "pubsublite.admin.projects.locations.topics.create",
7362            http_method: hyper::Method::POST,
7363        });
7364
7365        for &field in ["alt", "parent", "topicId"].iter() {
7366            if self._additional_params.contains_key(field) {
7367                dlg.finished(false);
7368                return Err(common::Error::FieldClash(field));
7369            }
7370        }
7371
7372        let mut params = Params::with_capacity(5 + self._additional_params.len());
7373        params.push("parent", self._parent);
7374        if let Some(value) = self._topic_id.as_ref() {
7375            params.push("topicId", value);
7376        }
7377
7378        params.extend(self._additional_params.iter());
7379
7380        params.push("alt", "json");
7381        let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/topics";
7382        if self._scopes.is_empty() {
7383            self._scopes
7384                .insert(Scope::CloudPlatform.as_ref().to_string());
7385        }
7386
7387        #[allow(clippy::single_element_loop)]
7388        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7389            url = params.uri_replacement(url, param_name, find_this, true);
7390        }
7391        {
7392            let to_remove = ["parent"];
7393            params.remove_params(&to_remove);
7394        }
7395
7396        let url = params.parse_with_url(&url);
7397
7398        let mut json_mime_type = mime::APPLICATION_JSON;
7399        let mut request_value_reader = {
7400            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7401            common::remove_json_null_values(&mut value);
7402            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7403            serde_json::to_writer(&mut dst, &value).unwrap();
7404            dst
7405        };
7406        let request_size = request_value_reader
7407            .seek(std::io::SeekFrom::End(0))
7408            .unwrap();
7409        request_value_reader
7410            .seek(std::io::SeekFrom::Start(0))
7411            .unwrap();
7412
7413        loop {
7414            let token = match self
7415                .hub
7416                .auth
7417                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7418                .await
7419            {
7420                Ok(token) => token,
7421                Err(e) => match dlg.token(e) {
7422                    Ok(token) => token,
7423                    Err(e) => {
7424                        dlg.finished(false);
7425                        return Err(common::Error::MissingToken(e));
7426                    }
7427                },
7428            };
7429            request_value_reader
7430                .seek(std::io::SeekFrom::Start(0))
7431                .unwrap();
7432            let mut req_result = {
7433                let client = &self.hub.client;
7434                dlg.pre_request();
7435                let mut req_builder = hyper::Request::builder()
7436                    .method(hyper::Method::POST)
7437                    .uri(url.as_str())
7438                    .header(USER_AGENT, self.hub._user_agent.clone());
7439
7440                if let Some(token) = token.as_ref() {
7441                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7442                }
7443
7444                let request = req_builder
7445                    .header(CONTENT_TYPE, json_mime_type.to_string())
7446                    .header(CONTENT_LENGTH, request_size as u64)
7447                    .body(common::to_body(
7448                        request_value_reader.get_ref().clone().into(),
7449                    ));
7450
7451                client.request(request.unwrap()).await
7452            };
7453
7454            match req_result {
7455                Err(err) => {
7456                    if let common::Retry::After(d) = dlg.http_error(&err) {
7457                        sleep(d).await;
7458                        continue;
7459                    }
7460                    dlg.finished(false);
7461                    return Err(common::Error::HttpError(err));
7462                }
7463                Ok(res) => {
7464                    let (mut parts, body) = res.into_parts();
7465                    let mut body = common::Body::new(body);
7466                    if !parts.status.is_success() {
7467                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7468                        let error = serde_json::from_str(&common::to_string(&bytes));
7469                        let response = common::to_response(parts, bytes.into());
7470
7471                        if let common::Retry::After(d) =
7472                            dlg.http_failure(&response, error.as_ref().ok())
7473                        {
7474                            sleep(d).await;
7475                            continue;
7476                        }
7477
7478                        dlg.finished(false);
7479
7480                        return Err(match error {
7481                            Ok(value) => common::Error::BadRequest(value),
7482                            _ => common::Error::Failure(response),
7483                        });
7484                    }
7485                    let response = {
7486                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7487                        let encoded = common::to_string(&bytes);
7488                        match serde_json::from_str(&encoded) {
7489                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7490                            Err(error) => {
7491                                dlg.response_json_decode_error(&encoded, &error);
7492                                return Err(common::Error::JsonDecodeError(
7493                                    encoded.to_string(),
7494                                    error,
7495                                ));
7496                            }
7497                        }
7498                    };
7499
7500                    dlg.finished(true);
7501                    return Ok(response);
7502                }
7503            }
7504        }
7505    }
7506
7507    ///
7508    /// Sets the *request* property to the given value.
7509    ///
7510    /// Even though the property as already been set when instantiating this call,
7511    /// we provide this method for API completeness.
7512    pub fn request(mut self, new_value: Topic) -> AdminProjectLocationTopicCreateCall<'a, C> {
7513        self._request = new_value;
7514        self
7515    }
7516    /// Required. The parent location in which to create the topic. Structured like `projects/{project_number}/locations/{location}`.
7517    ///
7518    /// Sets the *parent* path property to the given value.
7519    ///
7520    /// Even though the property as already been set when instantiating this call,
7521    /// we provide this method for API completeness.
7522    pub fn parent(mut self, new_value: &str) -> AdminProjectLocationTopicCreateCall<'a, C> {
7523        self._parent = new_value.to_string();
7524        self
7525    }
7526    /// 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`.
7527    ///
7528    /// Sets the *topic id* query property to the given value.
7529    pub fn topic_id(mut self, new_value: &str) -> AdminProjectLocationTopicCreateCall<'a, C> {
7530        self._topic_id = Some(new_value.to_string());
7531        self
7532    }
7533    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7534    /// while executing the actual API request.
7535    ///
7536    /// ````text
7537    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7538    /// ````
7539    ///
7540    /// Sets the *delegate* property to the given value.
7541    pub fn delegate(
7542        mut self,
7543        new_value: &'a mut dyn common::Delegate,
7544    ) -> AdminProjectLocationTopicCreateCall<'a, C> {
7545        self._delegate = Some(new_value);
7546        self
7547    }
7548
7549    /// Set any additional parameter of the query string used in the request.
7550    /// It should be used to set parameters which are not yet available through their own
7551    /// setters.
7552    ///
7553    /// Please note that this method must not be used to set any of the known parameters
7554    /// which have their own setter method. If done anyway, the request will fail.
7555    ///
7556    /// # Additional Parameters
7557    ///
7558    /// * *$.xgafv* (query-string) - V1 error format.
7559    /// * *access_token* (query-string) - OAuth access token.
7560    /// * *alt* (query-string) - Data format for response.
7561    /// * *callback* (query-string) - JSONP
7562    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7563    /// * *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.
7564    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7565    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7566    /// * *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.
7567    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7568    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7569    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicCreateCall<'a, C>
7570    where
7571        T: AsRef<str>,
7572    {
7573        self._additional_params
7574            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7575        self
7576    }
7577
7578    /// Identifies the authorization scope for the method you are building.
7579    ///
7580    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7581    /// [`Scope::CloudPlatform`].
7582    ///
7583    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7584    /// tokens for more than one scope.
7585    ///
7586    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7587    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7588    /// sufficient, a read-write scope will do as well.
7589    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicCreateCall<'a, C>
7590    where
7591        St: AsRef<str>,
7592    {
7593        self._scopes.insert(String::from(scope.as_ref()));
7594        self
7595    }
7596    /// Identifies the authorization scope(s) for the method you are building.
7597    ///
7598    /// See [`Self::add_scope()`] for details.
7599    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicCreateCall<'a, C>
7600    where
7601        I: IntoIterator<Item = St>,
7602        St: AsRef<str>,
7603    {
7604        self._scopes
7605            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7606        self
7607    }
7608
7609    /// Removes all scopes, and no default scope will be used either.
7610    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7611    /// for details).
7612    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicCreateCall<'a, C> {
7613        self._scopes.clear();
7614        self
7615    }
7616}
7617
7618/// Deletes the specified topic.
7619///
7620/// A builder for the *projects.locations.topics.delete* method supported by a *admin* resource.
7621/// It is not used directly, but through a [`AdminMethods`] instance.
7622///
7623/// # Example
7624///
7625/// Instantiate a resource method builder
7626///
7627/// ```test_harness,no_run
7628/// # extern crate hyper;
7629/// # extern crate hyper_rustls;
7630/// # extern crate google_pubsublite1 as pubsublite1;
7631/// # async fn dox() {
7632/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7633///
7634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7636/// #     .with_native_roots()
7637/// #     .unwrap()
7638/// #     .https_only()
7639/// #     .enable_http2()
7640/// #     .build();
7641///
7642/// # let executor = hyper_util::rt::TokioExecutor::new();
7643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7644/// #     secret,
7645/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7646/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7647/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7648/// #     ),
7649/// # ).build().await.unwrap();
7650///
7651/// # let client = hyper_util::client::legacy::Client::builder(
7652/// #     hyper_util::rt::TokioExecutor::new()
7653/// # )
7654/// # .build(
7655/// #     hyper_rustls::HttpsConnectorBuilder::new()
7656/// #         .with_native_roots()
7657/// #         .unwrap()
7658/// #         .https_or_http()
7659/// #         .enable_http2()
7660/// #         .build()
7661/// # );
7662/// # let mut hub = PubsubLite::new(client, auth);
7663/// // You can configure optional parameters by calling the respective setters at will, and
7664/// // execute the final call using `doit()`.
7665/// // Values shown here are possibly random and not representative !
7666/// let result = hub.admin().projects_locations_topics_delete("name")
7667///              .doit().await;
7668/// # }
7669/// ```
7670pub struct AdminProjectLocationTopicDeleteCall<'a, C>
7671where
7672    C: 'a,
7673{
7674    hub: &'a PubsubLite<C>,
7675    _name: String,
7676    _delegate: Option<&'a mut dyn common::Delegate>,
7677    _additional_params: HashMap<String, String>,
7678    _scopes: BTreeSet<String>,
7679}
7680
7681impl<'a, C> common::CallBuilder for AdminProjectLocationTopicDeleteCall<'a, C> {}
7682
7683impl<'a, C> AdminProjectLocationTopicDeleteCall<'a, C>
7684where
7685    C: common::Connector,
7686{
7687    /// Perform the operation you have build so far.
7688    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7689        use std::borrow::Cow;
7690        use std::io::{Read, Seek};
7691
7692        use common::{url::Params, ToParts};
7693        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7694
7695        let mut dd = common::DefaultDelegate;
7696        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7697        dlg.begin(common::MethodInfo {
7698            id: "pubsublite.admin.projects.locations.topics.delete",
7699            http_method: hyper::Method::DELETE,
7700        });
7701
7702        for &field in ["alt", "name"].iter() {
7703            if self._additional_params.contains_key(field) {
7704                dlg.finished(false);
7705                return Err(common::Error::FieldClash(field));
7706            }
7707        }
7708
7709        let mut params = Params::with_capacity(3 + self._additional_params.len());
7710        params.push("name", self._name);
7711
7712        params.extend(self._additional_params.iter());
7713
7714        params.push("alt", "json");
7715        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
7716        if self._scopes.is_empty() {
7717            self._scopes
7718                .insert(Scope::CloudPlatform.as_ref().to_string());
7719        }
7720
7721        #[allow(clippy::single_element_loop)]
7722        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7723            url = params.uri_replacement(url, param_name, find_this, true);
7724        }
7725        {
7726            let to_remove = ["name"];
7727            params.remove_params(&to_remove);
7728        }
7729
7730        let url = params.parse_with_url(&url);
7731
7732        loop {
7733            let token = match self
7734                .hub
7735                .auth
7736                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7737                .await
7738            {
7739                Ok(token) => token,
7740                Err(e) => match dlg.token(e) {
7741                    Ok(token) => token,
7742                    Err(e) => {
7743                        dlg.finished(false);
7744                        return Err(common::Error::MissingToken(e));
7745                    }
7746                },
7747            };
7748            let mut req_result = {
7749                let client = &self.hub.client;
7750                dlg.pre_request();
7751                let mut req_builder = hyper::Request::builder()
7752                    .method(hyper::Method::DELETE)
7753                    .uri(url.as_str())
7754                    .header(USER_AGENT, self.hub._user_agent.clone());
7755
7756                if let Some(token) = token.as_ref() {
7757                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7758                }
7759
7760                let request = req_builder
7761                    .header(CONTENT_LENGTH, 0_u64)
7762                    .body(common::to_body::<String>(None));
7763
7764                client.request(request.unwrap()).await
7765            };
7766
7767            match req_result {
7768                Err(err) => {
7769                    if let common::Retry::After(d) = dlg.http_error(&err) {
7770                        sleep(d).await;
7771                        continue;
7772                    }
7773                    dlg.finished(false);
7774                    return Err(common::Error::HttpError(err));
7775                }
7776                Ok(res) => {
7777                    let (mut parts, body) = res.into_parts();
7778                    let mut body = common::Body::new(body);
7779                    if !parts.status.is_success() {
7780                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7781                        let error = serde_json::from_str(&common::to_string(&bytes));
7782                        let response = common::to_response(parts, bytes.into());
7783
7784                        if let common::Retry::After(d) =
7785                            dlg.http_failure(&response, error.as_ref().ok())
7786                        {
7787                            sleep(d).await;
7788                            continue;
7789                        }
7790
7791                        dlg.finished(false);
7792
7793                        return Err(match error {
7794                            Ok(value) => common::Error::BadRequest(value),
7795                            _ => common::Error::Failure(response),
7796                        });
7797                    }
7798                    let response = {
7799                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7800                        let encoded = common::to_string(&bytes);
7801                        match serde_json::from_str(&encoded) {
7802                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7803                            Err(error) => {
7804                                dlg.response_json_decode_error(&encoded, &error);
7805                                return Err(common::Error::JsonDecodeError(
7806                                    encoded.to_string(),
7807                                    error,
7808                                ));
7809                            }
7810                        }
7811                    };
7812
7813                    dlg.finished(true);
7814                    return Ok(response);
7815                }
7816            }
7817        }
7818    }
7819
7820    /// Required. The name of the topic to delete.
7821    ///
7822    /// Sets the *name* path property to the given value.
7823    ///
7824    /// Even though the property as already been set when instantiating this call,
7825    /// we provide this method for API completeness.
7826    pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicDeleteCall<'a, C> {
7827        self._name = new_value.to_string();
7828        self
7829    }
7830    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7831    /// while executing the actual API request.
7832    ///
7833    /// ````text
7834    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7835    /// ````
7836    ///
7837    /// Sets the *delegate* property to the given value.
7838    pub fn delegate(
7839        mut self,
7840        new_value: &'a mut dyn common::Delegate,
7841    ) -> AdminProjectLocationTopicDeleteCall<'a, C> {
7842        self._delegate = Some(new_value);
7843        self
7844    }
7845
7846    /// Set any additional parameter of the query string used in the request.
7847    /// It should be used to set parameters which are not yet available through their own
7848    /// setters.
7849    ///
7850    /// Please note that this method must not be used to set any of the known parameters
7851    /// which have their own setter method. If done anyway, the request will fail.
7852    ///
7853    /// # Additional Parameters
7854    ///
7855    /// * *$.xgafv* (query-string) - V1 error format.
7856    /// * *access_token* (query-string) - OAuth access token.
7857    /// * *alt* (query-string) - Data format for response.
7858    /// * *callback* (query-string) - JSONP
7859    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7860    /// * *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.
7861    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7862    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7863    /// * *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.
7864    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7865    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7866    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicDeleteCall<'a, C>
7867    where
7868        T: AsRef<str>,
7869    {
7870        self._additional_params
7871            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7872        self
7873    }
7874
7875    /// Identifies the authorization scope for the method you are building.
7876    ///
7877    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7878    /// [`Scope::CloudPlatform`].
7879    ///
7880    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7881    /// tokens for more than one scope.
7882    ///
7883    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7884    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7885    /// sufficient, a read-write scope will do as well.
7886    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicDeleteCall<'a, C>
7887    where
7888        St: AsRef<str>,
7889    {
7890        self._scopes.insert(String::from(scope.as_ref()));
7891        self
7892    }
7893    /// Identifies the authorization scope(s) for the method you are building.
7894    ///
7895    /// See [`Self::add_scope()`] for details.
7896    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicDeleteCall<'a, C>
7897    where
7898        I: IntoIterator<Item = St>,
7899        St: AsRef<str>,
7900    {
7901        self._scopes
7902            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7903        self
7904    }
7905
7906    /// Removes all scopes, and no default scope will be used either.
7907    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7908    /// for details).
7909    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicDeleteCall<'a, C> {
7910        self._scopes.clear();
7911        self
7912    }
7913}
7914
7915/// Returns the topic configuration.
7916///
7917/// A builder for the *projects.locations.topics.get* method supported by a *admin* resource.
7918/// It is not used directly, but through a [`AdminMethods`] instance.
7919///
7920/// # Example
7921///
7922/// Instantiate a resource method builder
7923///
7924/// ```test_harness,no_run
7925/// # extern crate hyper;
7926/// # extern crate hyper_rustls;
7927/// # extern crate google_pubsublite1 as pubsublite1;
7928/// # async fn dox() {
7929/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7930///
7931/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7932/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7933/// #     .with_native_roots()
7934/// #     .unwrap()
7935/// #     .https_only()
7936/// #     .enable_http2()
7937/// #     .build();
7938///
7939/// # let executor = hyper_util::rt::TokioExecutor::new();
7940/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7941/// #     secret,
7942/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7943/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7944/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7945/// #     ),
7946/// # ).build().await.unwrap();
7947///
7948/// # let client = hyper_util::client::legacy::Client::builder(
7949/// #     hyper_util::rt::TokioExecutor::new()
7950/// # )
7951/// # .build(
7952/// #     hyper_rustls::HttpsConnectorBuilder::new()
7953/// #         .with_native_roots()
7954/// #         .unwrap()
7955/// #         .https_or_http()
7956/// #         .enable_http2()
7957/// #         .build()
7958/// # );
7959/// # let mut hub = PubsubLite::new(client, auth);
7960/// // You can configure optional parameters by calling the respective setters at will, and
7961/// // execute the final call using `doit()`.
7962/// // Values shown here are possibly random and not representative !
7963/// let result = hub.admin().projects_locations_topics_get("name")
7964///              .doit().await;
7965/// # }
7966/// ```
7967pub struct AdminProjectLocationTopicGetCall<'a, C>
7968where
7969    C: 'a,
7970{
7971    hub: &'a PubsubLite<C>,
7972    _name: String,
7973    _delegate: Option<&'a mut dyn common::Delegate>,
7974    _additional_params: HashMap<String, String>,
7975    _scopes: BTreeSet<String>,
7976}
7977
7978impl<'a, C> common::CallBuilder for AdminProjectLocationTopicGetCall<'a, C> {}
7979
7980impl<'a, C> AdminProjectLocationTopicGetCall<'a, C>
7981where
7982    C: common::Connector,
7983{
7984    /// Perform the operation you have build so far.
7985    pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
7986        use std::borrow::Cow;
7987        use std::io::{Read, Seek};
7988
7989        use common::{url::Params, ToParts};
7990        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7991
7992        let mut dd = common::DefaultDelegate;
7993        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7994        dlg.begin(common::MethodInfo {
7995            id: "pubsublite.admin.projects.locations.topics.get",
7996            http_method: hyper::Method::GET,
7997        });
7998
7999        for &field in ["alt", "name"].iter() {
8000            if self._additional_params.contains_key(field) {
8001                dlg.finished(false);
8002                return Err(common::Error::FieldClash(field));
8003            }
8004        }
8005
8006        let mut params = Params::with_capacity(3 + self._additional_params.len());
8007        params.push("name", self._name);
8008
8009        params.extend(self._additional_params.iter());
8010
8011        params.push("alt", "json");
8012        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
8013        if self._scopes.is_empty() {
8014            self._scopes
8015                .insert(Scope::CloudPlatform.as_ref().to_string());
8016        }
8017
8018        #[allow(clippy::single_element_loop)]
8019        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8020            url = params.uri_replacement(url, param_name, find_this, true);
8021        }
8022        {
8023            let to_remove = ["name"];
8024            params.remove_params(&to_remove);
8025        }
8026
8027        let url = params.parse_with_url(&url);
8028
8029        loop {
8030            let token = match self
8031                .hub
8032                .auth
8033                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8034                .await
8035            {
8036                Ok(token) => token,
8037                Err(e) => match dlg.token(e) {
8038                    Ok(token) => token,
8039                    Err(e) => {
8040                        dlg.finished(false);
8041                        return Err(common::Error::MissingToken(e));
8042                    }
8043                },
8044            };
8045            let mut req_result = {
8046                let client = &self.hub.client;
8047                dlg.pre_request();
8048                let mut req_builder = hyper::Request::builder()
8049                    .method(hyper::Method::GET)
8050                    .uri(url.as_str())
8051                    .header(USER_AGENT, self.hub._user_agent.clone());
8052
8053                if let Some(token) = token.as_ref() {
8054                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8055                }
8056
8057                let request = req_builder
8058                    .header(CONTENT_LENGTH, 0_u64)
8059                    .body(common::to_body::<String>(None));
8060
8061                client.request(request.unwrap()).await
8062            };
8063
8064            match req_result {
8065                Err(err) => {
8066                    if let common::Retry::After(d) = dlg.http_error(&err) {
8067                        sleep(d).await;
8068                        continue;
8069                    }
8070                    dlg.finished(false);
8071                    return Err(common::Error::HttpError(err));
8072                }
8073                Ok(res) => {
8074                    let (mut parts, body) = res.into_parts();
8075                    let mut body = common::Body::new(body);
8076                    if !parts.status.is_success() {
8077                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8078                        let error = serde_json::from_str(&common::to_string(&bytes));
8079                        let response = common::to_response(parts, bytes.into());
8080
8081                        if let common::Retry::After(d) =
8082                            dlg.http_failure(&response, error.as_ref().ok())
8083                        {
8084                            sleep(d).await;
8085                            continue;
8086                        }
8087
8088                        dlg.finished(false);
8089
8090                        return Err(match error {
8091                            Ok(value) => common::Error::BadRequest(value),
8092                            _ => common::Error::Failure(response),
8093                        });
8094                    }
8095                    let response = {
8096                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8097                        let encoded = common::to_string(&bytes);
8098                        match serde_json::from_str(&encoded) {
8099                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8100                            Err(error) => {
8101                                dlg.response_json_decode_error(&encoded, &error);
8102                                return Err(common::Error::JsonDecodeError(
8103                                    encoded.to_string(),
8104                                    error,
8105                                ));
8106                            }
8107                        }
8108                    };
8109
8110                    dlg.finished(true);
8111                    return Ok(response);
8112                }
8113            }
8114        }
8115    }
8116
8117    /// Required. The name of the topic whose configuration to return.
8118    ///
8119    /// Sets the *name* path property to the given value.
8120    ///
8121    /// Even though the property as already been set when instantiating this call,
8122    /// we provide this method for API completeness.
8123    pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicGetCall<'a, C> {
8124        self._name = new_value.to_string();
8125        self
8126    }
8127    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8128    /// while executing the actual API request.
8129    ///
8130    /// ````text
8131    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8132    /// ````
8133    ///
8134    /// Sets the *delegate* property to the given value.
8135    pub fn delegate(
8136        mut self,
8137        new_value: &'a mut dyn common::Delegate,
8138    ) -> AdminProjectLocationTopicGetCall<'a, C> {
8139        self._delegate = Some(new_value);
8140        self
8141    }
8142
8143    /// Set any additional parameter of the query string used in the request.
8144    /// It should be used to set parameters which are not yet available through their own
8145    /// setters.
8146    ///
8147    /// Please note that this method must not be used to set any of the known parameters
8148    /// which have their own setter method. If done anyway, the request will fail.
8149    ///
8150    /// # Additional Parameters
8151    ///
8152    /// * *$.xgafv* (query-string) - V1 error format.
8153    /// * *access_token* (query-string) - OAuth access token.
8154    /// * *alt* (query-string) - Data format for response.
8155    /// * *callback* (query-string) - JSONP
8156    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8157    /// * *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.
8158    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8159    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8160    /// * *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.
8161    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8162    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8163    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicGetCall<'a, C>
8164    where
8165        T: AsRef<str>,
8166    {
8167        self._additional_params
8168            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8169        self
8170    }
8171
8172    /// Identifies the authorization scope for the method you are building.
8173    ///
8174    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8175    /// [`Scope::CloudPlatform`].
8176    ///
8177    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8178    /// tokens for more than one scope.
8179    ///
8180    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8181    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8182    /// sufficient, a read-write scope will do as well.
8183    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicGetCall<'a, C>
8184    where
8185        St: AsRef<str>,
8186    {
8187        self._scopes.insert(String::from(scope.as_ref()));
8188        self
8189    }
8190    /// Identifies the authorization scope(s) for the method you are building.
8191    ///
8192    /// See [`Self::add_scope()`] for details.
8193    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicGetCall<'a, C>
8194    where
8195        I: IntoIterator<Item = St>,
8196        St: AsRef<str>,
8197    {
8198        self._scopes
8199            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8200        self
8201    }
8202
8203    /// Removes all scopes, and no default scope will be used either.
8204    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8205    /// for details).
8206    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicGetCall<'a, C> {
8207        self._scopes.clear();
8208        self
8209    }
8210}
8211
8212/// Returns the partition information for the requested topic.
8213///
8214/// A builder for the *projects.locations.topics.getPartitions* method supported by a *admin* resource.
8215/// It is not used directly, but through a [`AdminMethods`] instance.
8216///
8217/// # Example
8218///
8219/// Instantiate a resource method builder
8220///
8221/// ```test_harness,no_run
8222/// # extern crate hyper;
8223/// # extern crate hyper_rustls;
8224/// # extern crate google_pubsublite1 as pubsublite1;
8225/// # async fn dox() {
8226/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8227///
8228/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8229/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8230/// #     .with_native_roots()
8231/// #     .unwrap()
8232/// #     .https_only()
8233/// #     .enable_http2()
8234/// #     .build();
8235///
8236/// # let executor = hyper_util::rt::TokioExecutor::new();
8237/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8238/// #     secret,
8239/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8240/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8241/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8242/// #     ),
8243/// # ).build().await.unwrap();
8244///
8245/// # let client = hyper_util::client::legacy::Client::builder(
8246/// #     hyper_util::rt::TokioExecutor::new()
8247/// # )
8248/// # .build(
8249/// #     hyper_rustls::HttpsConnectorBuilder::new()
8250/// #         .with_native_roots()
8251/// #         .unwrap()
8252/// #         .https_or_http()
8253/// #         .enable_http2()
8254/// #         .build()
8255/// # );
8256/// # let mut hub = PubsubLite::new(client, auth);
8257/// // You can configure optional parameters by calling the respective setters at will, and
8258/// // execute the final call using `doit()`.
8259/// // Values shown here are possibly random and not representative !
8260/// let result = hub.admin().projects_locations_topics_get_partitions("name")
8261///              .doit().await;
8262/// # }
8263/// ```
8264pub struct AdminProjectLocationTopicGetPartitionCall<'a, C>
8265where
8266    C: 'a,
8267{
8268    hub: &'a PubsubLite<C>,
8269    _name: String,
8270    _delegate: Option<&'a mut dyn common::Delegate>,
8271    _additional_params: HashMap<String, String>,
8272    _scopes: BTreeSet<String>,
8273}
8274
8275impl<'a, C> common::CallBuilder for AdminProjectLocationTopicGetPartitionCall<'a, C> {}
8276
8277impl<'a, C> AdminProjectLocationTopicGetPartitionCall<'a, C>
8278where
8279    C: common::Connector,
8280{
8281    /// Perform the operation you have build so far.
8282    pub async fn doit(mut self) -> common::Result<(common::Response, TopicPartitions)> {
8283        use std::borrow::Cow;
8284        use std::io::{Read, Seek};
8285
8286        use common::{url::Params, ToParts};
8287        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8288
8289        let mut dd = common::DefaultDelegate;
8290        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8291        dlg.begin(common::MethodInfo {
8292            id: "pubsublite.admin.projects.locations.topics.getPartitions",
8293            http_method: hyper::Method::GET,
8294        });
8295
8296        for &field in ["alt", "name"].iter() {
8297            if self._additional_params.contains_key(field) {
8298                dlg.finished(false);
8299                return Err(common::Error::FieldClash(field));
8300            }
8301        }
8302
8303        let mut params = Params::with_capacity(3 + self._additional_params.len());
8304        params.push("name", self._name);
8305
8306        params.extend(self._additional_params.iter());
8307
8308        params.push("alt", "json");
8309        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}/partitions";
8310        if self._scopes.is_empty() {
8311            self._scopes
8312                .insert(Scope::CloudPlatform.as_ref().to_string());
8313        }
8314
8315        #[allow(clippy::single_element_loop)]
8316        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8317            url = params.uri_replacement(url, param_name, find_this, true);
8318        }
8319        {
8320            let to_remove = ["name"];
8321            params.remove_params(&to_remove);
8322        }
8323
8324        let url = params.parse_with_url(&url);
8325
8326        loop {
8327            let token = match self
8328                .hub
8329                .auth
8330                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8331                .await
8332            {
8333                Ok(token) => token,
8334                Err(e) => match dlg.token(e) {
8335                    Ok(token) => token,
8336                    Err(e) => {
8337                        dlg.finished(false);
8338                        return Err(common::Error::MissingToken(e));
8339                    }
8340                },
8341            };
8342            let mut req_result = {
8343                let client = &self.hub.client;
8344                dlg.pre_request();
8345                let mut req_builder = hyper::Request::builder()
8346                    .method(hyper::Method::GET)
8347                    .uri(url.as_str())
8348                    .header(USER_AGENT, self.hub._user_agent.clone());
8349
8350                if let Some(token) = token.as_ref() {
8351                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8352                }
8353
8354                let request = req_builder
8355                    .header(CONTENT_LENGTH, 0_u64)
8356                    .body(common::to_body::<String>(None));
8357
8358                client.request(request.unwrap()).await
8359            };
8360
8361            match req_result {
8362                Err(err) => {
8363                    if let common::Retry::After(d) = dlg.http_error(&err) {
8364                        sleep(d).await;
8365                        continue;
8366                    }
8367                    dlg.finished(false);
8368                    return Err(common::Error::HttpError(err));
8369                }
8370                Ok(res) => {
8371                    let (mut parts, body) = res.into_parts();
8372                    let mut body = common::Body::new(body);
8373                    if !parts.status.is_success() {
8374                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8375                        let error = serde_json::from_str(&common::to_string(&bytes));
8376                        let response = common::to_response(parts, bytes.into());
8377
8378                        if let common::Retry::After(d) =
8379                            dlg.http_failure(&response, error.as_ref().ok())
8380                        {
8381                            sleep(d).await;
8382                            continue;
8383                        }
8384
8385                        dlg.finished(false);
8386
8387                        return Err(match error {
8388                            Ok(value) => common::Error::BadRequest(value),
8389                            _ => common::Error::Failure(response),
8390                        });
8391                    }
8392                    let response = {
8393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8394                        let encoded = common::to_string(&bytes);
8395                        match serde_json::from_str(&encoded) {
8396                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8397                            Err(error) => {
8398                                dlg.response_json_decode_error(&encoded, &error);
8399                                return Err(common::Error::JsonDecodeError(
8400                                    encoded.to_string(),
8401                                    error,
8402                                ));
8403                            }
8404                        }
8405                    };
8406
8407                    dlg.finished(true);
8408                    return Ok(response);
8409                }
8410            }
8411        }
8412    }
8413
8414    /// Required. The topic whose partition information to return.
8415    ///
8416    /// Sets the *name* path property to the given value.
8417    ///
8418    /// Even though the property as already been set when instantiating this call,
8419    /// we provide this method for API completeness.
8420    pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
8421        self._name = new_value.to_string();
8422        self
8423    }
8424    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8425    /// while executing the actual API request.
8426    ///
8427    /// ````text
8428    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8429    /// ````
8430    ///
8431    /// Sets the *delegate* property to the given value.
8432    pub fn delegate(
8433        mut self,
8434        new_value: &'a mut dyn common::Delegate,
8435    ) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
8436        self._delegate = Some(new_value);
8437        self
8438    }
8439
8440    /// Set any additional parameter of the query string used in the request.
8441    /// It should be used to set parameters which are not yet available through their own
8442    /// setters.
8443    ///
8444    /// Please note that this method must not be used to set any of the known parameters
8445    /// which have their own setter method. If done anyway, the request will fail.
8446    ///
8447    /// # Additional Parameters
8448    ///
8449    /// * *$.xgafv* (query-string) - V1 error format.
8450    /// * *access_token* (query-string) - OAuth access token.
8451    /// * *alt* (query-string) - Data format for response.
8452    /// * *callback* (query-string) - JSONP
8453    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8454    /// * *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.
8455    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8456    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8457    /// * *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.
8458    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8459    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8460    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicGetPartitionCall<'a, C>
8461    where
8462        T: AsRef<str>,
8463    {
8464        self._additional_params
8465            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8466        self
8467    }
8468
8469    /// Identifies the authorization scope for the method you are building.
8470    ///
8471    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8472    /// [`Scope::CloudPlatform`].
8473    ///
8474    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8475    /// tokens for more than one scope.
8476    ///
8477    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8478    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8479    /// sufficient, a read-write scope will do as well.
8480    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicGetPartitionCall<'a, C>
8481    where
8482        St: AsRef<str>,
8483    {
8484        self._scopes.insert(String::from(scope.as_ref()));
8485        self
8486    }
8487    /// Identifies the authorization scope(s) for the method you are building.
8488    ///
8489    /// See [`Self::add_scope()`] for details.
8490    pub fn add_scopes<I, St>(
8491        mut self,
8492        scopes: I,
8493    ) -> AdminProjectLocationTopicGetPartitionCall<'a, C>
8494    where
8495        I: IntoIterator<Item = St>,
8496        St: AsRef<str>,
8497    {
8498        self._scopes
8499            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8500        self
8501    }
8502
8503    /// Removes all scopes, and no default scope will be used either.
8504    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8505    /// for details).
8506    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicGetPartitionCall<'a, C> {
8507        self._scopes.clear();
8508        self
8509    }
8510}
8511
8512/// Returns the list of topics for the given project.
8513///
8514/// A builder for the *projects.locations.topics.list* method supported by a *admin* resource.
8515/// It is not used directly, but through a [`AdminMethods`] instance.
8516///
8517/// # Example
8518///
8519/// Instantiate a resource method builder
8520///
8521/// ```test_harness,no_run
8522/// # extern crate hyper;
8523/// # extern crate hyper_rustls;
8524/// # extern crate google_pubsublite1 as pubsublite1;
8525/// # async fn dox() {
8526/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8527///
8528/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8529/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8530/// #     .with_native_roots()
8531/// #     .unwrap()
8532/// #     .https_only()
8533/// #     .enable_http2()
8534/// #     .build();
8535///
8536/// # let executor = hyper_util::rt::TokioExecutor::new();
8537/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8538/// #     secret,
8539/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8540/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8541/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8542/// #     ),
8543/// # ).build().await.unwrap();
8544///
8545/// # let client = hyper_util::client::legacy::Client::builder(
8546/// #     hyper_util::rt::TokioExecutor::new()
8547/// # )
8548/// # .build(
8549/// #     hyper_rustls::HttpsConnectorBuilder::new()
8550/// #         .with_native_roots()
8551/// #         .unwrap()
8552/// #         .https_or_http()
8553/// #         .enable_http2()
8554/// #         .build()
8555/// # );
8556/// # let mut hub = PubsubLite::new(client, auth);
8557/// // You can configure optional parameters by calling the respective setters at will, and
8558/// // execute the final call using `doit()`.
8559/// // Values shown here are possibly random and not representative !
8560/// let result = hub.admin().projects_locations_topics_list("parent")
8561///              .page_token("no")
8562///              .page_size(-15)
8563///              .doit().await;
8564/// # }
8565/// ```
8566pub struct AdminProjectLocationTopicListCall<'a, C>
8567where
8568    C: 'a,
8569{
8570    hub: &'a PubsubLite<C>,
8571    _parent: String,
8572    _page_token: Option<String>,
8573    _page_size: Option<i32>,
8574    _delegate: Option<&'a mut dyn common::Delegate>,
8575    _additional_params: HashMap<String, String>,
8576    _scopes: BTreeSet<String>,
8577}
8578
8579impl<'a, C> common::CallBuilder for AdminProjectLocationTopicListCall<'a, C> {}
8580
8581impl<'a, C> AdminProjectLocationTopicListCall<'a, C>
8582where
8583    C: common::Connector,
8584{
8585    /// Perform the operation you have build so far.
8586    pub async fn doit(mut self) -> common::Result<(common::Response, ListTopicsResponse)> {
8587        use std::borrow::Cow;
8588        use std::io::{Read, Seek};
8589
8590        use common::{url::Params, ToParts};
8591        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8592
8593        let mut dd = common::DefaultDelegate;
8594        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8595        dlg.begin(common::MethodInfo {
8596            id: "pubsublite.admin.projects.locations.topics.list",
8597            http_method: hyper::Method::GET,
8598        });
8599
8600        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8601            if self._additional_params.contains_key(field) {
8602                dlg.finished(false);
8603                return Err(common::Error::FieldClash(field));
8604            }
8605        }
8606
8607        let mut params = Params::with_capacity(5 + self._additional_params.len());
8608        params.push("parent", self._parent);
8609        if let Some(value) = self._page_token.as_ref() {
8610            params.push("pageToken", value);
8611        }
8612        if let Some(value) = self._page_size.as_ref() {
8613            params.push("pageSize", value.to_string());
8614        }
8615
8616        params.extend(self._additional_params.iter());
8617
8618        params.push("alt", "json");
8619        let mut url = self.hub._base_url.clone() + "v1/admin/{+parent}/topics";
8620        if self._scopes.is_empty() {
8621            self._scopes
8622                .insert(Scope::CloudPlatform.as_ref().to_string());
8623        }
8624
8625        #[allow(clippy::single_element_loop)]
8626        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8627            url = params.uri_replacement(url, param_name, find_this, true);
8628        }
8629        {
8630            let to_remove = ["parent"];
8631            params.remove_params(&to_remove);
8632        }
8633
8634        let url = params.parse_with_url(&url);
8635
8636        loop {
8637            let token = match self
8638                .hub
8639                .auth
8640                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8641                .await
8642            {
8643                Ok(token) => token,
8644                Err(e) => match dlg.token(e) {
8645                    Ok(token) => token,
8646                    Err(e) => {
8647                        dlg.finished(false);
8648                        return Err(common::Error::MissingToken(e));
8649                    }
8650                },
8651            };
8652            let mut req_result = {
8653                let client = &self.hub.client;
8654                dlg.pre_request();
8655                let mut req_builder = hyper::Request::builder()
8656                    .method(hyper::Method::GET)
8657                    .uri(url.as_str())
8658                    .header(USER_AGENT, self.hub._user_agent.clone());
8659
8660                if let Some(token) = token.as_ref() {
8661                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8662                }
8663
8664                let request = req_builder
8665                    .header(CONTENT_LENGTH, 0_u64)
8666                    .body(common::to_body::<String>(None));
8667
8668                client.request(request.unwrap()).await
8669            };
8670
8671            match req_result {
8672                Err(err) => {
8673                    if let common::Retry::After(d) = dlg.http_error(&err) {
8674                        sleep(d).await;
8675                        continue;
8676                    }
8677                    dlg.finished(false);
8678                    return Err(common::Error::HttpError(err));
8679                }
8680                Ok(res) => {
8681                    let (mut parts, body) = res.into_parts();
8682                    let mut body = common::Body::new(body);
8683                    if !parts.status.is_success() {
8684                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8685                        let error = serde_json::from_str(&common::to_string(&bytes));
8686                        let response = common::to_response(parts, bytes.into());
8687
8688                        if let common::Retry::After(d) =
8689                            dlg.http_failure(&response, error.as_ref().ok())
8690                        {
8691                            sleep(d).await;
8692                            continue;
8693                        }
8694
8695                        dlg.finished(false);
8696
8697                        return Err(match error {
8698                            Ok(value) => common::Error::BadRequest(value),
8699                            _ => common::Error::Failure(response),
8700                        });
8701                    }
8702                    let response = {
8703                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8704                        let encoded = common::to_string(&bytes);
8705                        match serde_json::from_str(&encoded) {
8706                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8707                            Err(error) => {
8708                                dlg.response_json_decode_error(&encoded, &error);
8709                                return Err(common::Error::JsonDecodeError(
8710                                    encoded.to_string(),
8711                                    error,
8712                                ));
8713                            }
8714                        }
8715                    };
8716
8717                    dlg.finished(true);
8718                    return Ok(response);
8719                }
8720            }
8721        }
8722    }
8723
8724    /// Required. The parent whose topics are to be listed. Structured like `projects/{project_number}/locations/{location}`.
8725    ///
8726    /// Sets the *parent* path property to the given value.
8727    ///
8728    /// Even though the property as already been set when instantiating this call,
8729    /// we provide this method for API completeness.
8730    pub fn parent(mut self, new_value: &str) -> AdminProjectLocationTopicListCall<'a, C> {
8731        self._parent = new_value.to_string();
8732        self
8733    }
8734    /// 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.
8735    ///
8736    /// Sets the *page token* query property to the given value.
8737    pub fn page_token(mut self, new_value: &str) -> AdminProjectLocationTopicListCall<'a, C> {
8738        self._page_token = Some(new_value.to_string());
8739        self
8740    }
8741    /// 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.
8742    ///
8743    /// Sets the *page size* query property to the given value.
8744    pub fn page_size(mut self, new_value: i32) -> AdminProjectLocationTopicListCall<'a, C> {
8745        self._page_size = Some(new_value);
8746        self
8747    }
8748    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8749    /// while executing the actual API request.
8750    ///
8751    /// ````text
8752    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8753    /// ````
8754    ///
8755    /// Sets the *delegate* property to the given value.
8756    pub fn delegate(
8757        mut self,
8758        new_value: &'a mut dyn common::Delegate,
8759    ) -> AdminProjectLocationTopicListCall<'a, C> {
8760        self._delegate = Some(new_value);
8761        self
8762    }
8763
8764    /// Set any additional parameter of the query string used in the request.
8765    /// It should be used to set parameters which are not yet available through their own
8766    /// setters.
8767    ///
8768    /// Please note that this method must not be used to set any of the known parameters
8769    /// which have their own setter method. If done anyway, the request will fail.
8770    ///
8771    /// # Additional Parameters
8772    ///
8773    /// * *$.xgafv* (query-string) - V1 error format.
8774    /// * *access_token* (query-string) - OAuth access token.
8775    /// * *alt* (query-string) - Data format for response.
8776    /// * *callback* (query-string) - JSONP
8777    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8778    /// * *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.
8779    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8780    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8781    /// * *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.
8782    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8783    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8784    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicListCall<'a, C>
8785    where
8786        T: AsRef<str>,
8787    {
8788        self._additional_params
8789            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8790        self
8791    }
8792
8793    /// Identifies the authorization scope for the method you are building.
8794    ///
8795    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8796    /// [`Scope::CloudPlatform`].
8797    ///
8798    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8799    /// tokens for more than one scope.
8800    ///
8801    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8802    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8803    /// sufficient, a read-write scope will do as well.
8804    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicListCall<'a, C>
8805    where
8806        St: AsRef<str>,
8807    {
8808        self._scopes.insert(String::from(scope.as_ref()));
8809        self
8810    }
8811    /// Identifies the authorization scope(s) for the method you are building.
8812    ///
8813    /// See [`Self::add_scope()`] for details.
8814    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicListCall<'a, C>
8815    where
8816        I: IntoIterator<Item = St>,
8817        St: AsRef<str>,
8818    {
8819        self._scopes
8820            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8821        self
8822    }
8823
8824    /// Removes all scopes, and no default scope will be used either.
8825    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8826    /// for details).
8827    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicListCall<'a, C> {
8828        self._scopes.clear();
8829        self
8830    }
8831}
8832
8833/// Updates properties of the specified topic.
8834///
8835/// A builder for the *projects.locations.topics.patch* method supported by a *admin* resource.
8836/// It is not used directly, but through a [`AdminMethods`] instance.
8837///
8838/// # Example
8839///
8840/// Instantiate a resource method builder
8841///
8842/// ```test_harness,no_run
8843/// # extern crate hyper;
8844/// # extern crate hyper_rustls;
8845/// # extern crate google_pubsublite1 as pubsublite1;
8846/// use pubsublite1::api::Topic;
8847/// # async fn dox() {
8848/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8849///
8850/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8851/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8852/// #     .with_native_roots()
8853/// #     .unwrap()
8854/// #     .https_only()
8855/// #     .enable_http2()
8856/// #     .build();
8857///
8858/// # let executor = hyper_util::rt::TokioExecutor::new();
8859/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8860/// #     secret,
8861/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8862/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8863/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8864/// #     ),
8865/// # ).build().await.unwrap();
8866///
8867/// # let client = hyper_util::client::legacy::Client::builder(
8868/// #     hyper_util::rt::TokioExecutor::new()
8869/// # )
8870/// # .build(
8871/// #     hyper_rustls::HttpsConnectorBuilder::new()
8872/// #         .with_native_roots()
8873/// #         .unwrap()
8874/// #         .https_or_http()
8875/// #         .enable_http2()
8876/// #         .build()
8877/// # );
8878/// # let mut hub = PubsubLite::new(client, auth);
8879/// // As the method needs a request, you would usually fill it with the desired information
8880/// // into the respective structure. Some of the parts shown here might not be applicable !
8881/// // Values shown here are possibly random and not representative !
8882/// let mut req = Topic::default();
8883///
8884/// // You can configure optional parameters by calling the respective setters at will, and
8885/// // execute the final call using `doit()`.
8886/// // Values shown here are possibly random and not representative !
8887/// let result = hub.admin().projects_locations_topics_patch(req, "name")
8888///              .update_mask(FieldMask::new::<&str>(&[]))
8889///              .doit().await;
8890/// # }
8891/// ```
8892pub struct AdminProjectLocationTopicPatchCall<'a, C>
8893where
8894    C: 'a,
8895{
8896    hub: &'a PubsubLite<C>,
8897    _request: Topic,
8898    _name: String,
8899    _update_mask: Option<common::FieldMask>,
8900    _delegate: Option<&'a mut dyn common::Delegate>,
8901    _additional_params: HashMap<String, String>,
8902    _scopes: BTreeSet<String>,
8903}
8904
8905impl<'a, C> common::CallBuilder for AdminProjectLocationTopicPatchCall<'a, C> {}
8906
8907impl<'a, C> AdminProjectLocationTopicPatchCall<'a, C>
8908where
8909    C: common::Connector,
8910{
8911    /// Perform the operation you have build so far.
8912    pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
8913        use std::borrow::Cow;
8914        use std::io::{Read, Seek};
8915
8916        use common::{url::Params, ToParts};
8917        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8918
8919        let mut dd = common::DefaultDelegate;
8920        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8921        dlg.begin(common::MethodInfo {
8922            id: "pubsublite.admin.projects.locations.topics.patch",
8923            http_method: hyper::Method::PATCH,
8924        });
8925
8926        for &field in ["alt", "name", "updateMask"].iter() {
8927            if self._additional_params.contains_key(field) {
8928                dlg.finished(false);
8929                return Err(common::Error::FieldClash(field));
8930            }
8931        }
8932
8933        let mut params = Params::with_capacity(5 + self._additional_params.len());
8934        params.push("name", self._name);
8935        if let Some(value) = self._update_mask.as_ref() {
8936            params.push("updateMask", value.to_string());
8937        }
8938
8939        params.extend(self._additional_params.iter());
8940
8941        params.push("alt", "json");
8942        let mut url = self.hub._base_url.clone() + "v1/admin/{+name}";
8943        if self._scopes.is_empty() {
8944            self._scopes
8945                .insert(Scope::CloudPlatform.as_ref().to_string());
8946        }
8947
8948        #[allow(clippy::single_element_loop)]
8949        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8950            url = params.uri_replacement(url, param_name, find_this, true);
8951        }
8952        {
8953            let to_remove = ["name"];
8954            params.remove_params(&to_remove);
8955        }
8956
8957        let url = params.parse_with_url(&url);
8958
8959        let mut json_mime_type = mime::APPLICATION_JSON;
8960        let mut request_value_reader = {
8961            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8962            common::remove_json_null_values(&mut value);
8963            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8964            serde_json::to_writer(&mut dst, &value).unwrap();
8965            dst
8966        };
8967        let request_size = request_value_reader
8968            .seek(std::io::SeekFrom::End(0))
8969            .unwrap();
8970        request_value_reader
8971            .seek(std::io::SeekFrom::Start(0))
8972            .unwrap();
8973
8974        loop {
8975            let token = match self
8976                .hub
8977                .auth
8978                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8979                .await
8980            {
8981                Ok(token) => token,
8982                Err(e) => match dlg.token(e) {
8983                    Ok(token) => token,
8984                    Err(e) => {
8985                        dlg.finished(false);
8986                        return Err(common::Error::MissingToken(e));
8987                    }
8988                },
8989            };
8990            request_value_reader
8991                .seek(std::io::SeekFrom::Start(0))
8992                .unwrap();
8993            let mut req_result = {
8994                let client = &self.hub.client;
8995                dlg.pre_request();
8996                let mut req_builder = hyper::Request::builder()
8997                    .method(hyper::Method::PATCH)
8998                    .uri(url.as_str())
8999                    .header(USER_AGENT, self.hub._user_agent.clone());
9000
9001                if let Some(token) = token.as_ref() {
9002                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9003                }
9004
9005                let request = req_builder
9006                    .header(CONTENT_TYPE, json_mime_type.to_string())
9007                    .header(CONTENT_LENGTH, request_size as u64)
9008                    .body(common::to_body(
9009                        request_value_reader.get_ref().clone().into(),
9010                    ));
9011
9012                client.request(request.unwrap()).await
9013            };
9014
9015            match req_result {
9016                Err(err) => {
9017                    if let common::Retry::After(d) = dlg.http_error(&err) {
9018                        sleep(d).await;
9019                        continue;
9020                    }
9021                    dlg.finished(false);
9022                    return Err(common::Error::HttpError(err));
9023                }
9024                Ok(res) => {
9025                    let (mut parts, body) = res.into_parts();
9026                    let mut body = common::Body::new(body);
9027                    if !parts.status.is_success() {
9028                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9029                        let error = serde_json::from_str(&common::to_string(&bytes));
9030                        let response = common::to_response(parts, bytes.into());
9031
9032                        if let common::Retry::After(d) =
9033                            dlg.http_failure(&response, error.as_ref().ok())
9034                        {
9035                            sleep(d).await;
9036                            continue;
9037                        }
9038
9039                        dlg.finished(false);
9040
9041                        return Err(match error {
9042                            Ok(value) => common::Error::BadRequest(value),
9043                            _ => common::Error::Failure(response),
9044                        });
9045                    }
9046                    let response = {
9047                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9048                        let encoded = common::to_string(&bytes);
9049                        match serde_json::from_str(&encoded) {
9050                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9051                            Err(error) => {
9052                                dlg.response_json_decode_error(&encoded, &error);
9053                                return Err(common::Error::JsonDecodeError(
9054                                    encoded.to_string(),
9055                                    error,
9056                                ));
9057                            }
9058                        }
9059                    };
9060
9061                    dlg.finished(true);
9062                    return Ok(response);
9063                }
9064            }
9065        }
9066    }
9067
9068    ///
9069    /// Sets the *request* property to the given value.
9070    ///
9071    /// Even though the property as already been set when instantiating this call,
9072    /// we provide this method for API completeness.
9073    pub fn request(mut self, new_value: Topic) -> AdminProjectLocationTopicPatchCall<'a, C> {
9074        self._request = new_value;
9075        self
9076    }
9077    /// The name of the topic. Structured like: projects/{project_number}/locations/{location}/topics/{topic_id}
9078    ///
9079    /// Sets the *name* path property to the given value.
9080    ///
9081    /// Even though the property as already been set when instantiating this call,
9082    /// we provide this method for API completeness.
9083    pub fn name(mut self, new_value: &str) -> AdminProjectLocationTopicPatchCall<'a, C> {
9084        self._name = new_value.to_string();
9085        self
9086    }
9087    /// Required. A mask specifying the topic fields to change.
9088    ///
9089    /// Sets the *update mask* query property to the given value.
9090    pub fn update_mask(
9091        mut self,
9092        new_value: common::FieldMask,
9093    ) -> AdminProjectLocationTopicPatchCall<'a, C> {
9094        self._update_mask = Some(new_value);
9095        self
9096    }
9097    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9098    /// while executing the actual API request.
9099    ///
9100    /// ````text
9101    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9102    /// ````
9103    ///
9104    /// Sets the *delegate* property to the given value.
9105    pub fn delegate(
9106        mut self,
9107        new_value: &'a mut dyn common::Delegate,
9108    ) -> AdminProjectLocationTopicPatchCall<'a, C> {
9109        self._delegate = Some(new_value);
9110        self
9111    }
9112
9113    /// Set any additional parameter of the query string used in the request.
9114    /// It should be used to set parameters which are not yet available through their own
9115    /// setters.
9116    ///
9117    /// Please note that this method must not be used to set any of the known parameters
9118    /// which have their own setter method. If done anyway, the request will fail.
9119    ///
9120    /// # Additional Parameters
9121    ///
9122    /// * *$.xgafv* (query-string) - V1 error format.
9123    /// * *access_token* (query-string) - OAuth access token.
9124    /// * *alt* (query-string) - Data format for response.
9125    /// * *callback* (query-string) - JSONP
9126    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9127    /// * *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.
9128    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9129    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9130    /// * *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.
9131    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9132    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9133    pub fn param<T>(mut self, name: T, value: T) -> AdminProjectLocationTopicPatchCall<'a, C>
9134    where
9135        T: AsRef<str>,
9136    {
9137        self._additional_params
9138            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9139        self
9140    }
9141
9142    /// Identifies the authorization scope for the method you are building.
9143    ///
9144    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9145    /// [`Scope::CloudPlatform`].
9146    ///
9147    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9148    /// tokens for more than one scope.
9149    ///
9150    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9151    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9152    /// sufficient, a read-write scope will do as well.
9153    pub fn add_scope<St>(mut self, scope: St) -> AdminProjectLocationTopicPatchCall<'a, C>
9154    where
9155        St: AsRef<str>,
9156    {
9157        self._scopes.insert(String::from(scope.as_ref()));
9158        self
9159    }
9160    /// Identifies the authorization scope(s) for the method you are building.
9161    ///
9162    /// See [`Self::add_scope()`] for details.
9163    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdminProjectLocationTopicPatchCall<'a, C>
9164    where
9165        I: IntoIterator<Item = St>,
9166        St: AsRef<str>,
9167    {
9168        self._scopes
9169            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9170        self
9171    }
9172
9173    /// Removes all scopes, and no default scope will be used either.
9174    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9175    /// for details).
9176    pub fn clear_scopes(mut self) -> AdminProjectLocationTopicPatchCall<'a, C> {
9177        self._scopes.clear();
9178        self
9179    }
9180}
9181
9182/// Returns all committed cursor information for a subscription.
9183///
9184/// A builder for the *projects.locations.subscriptions.cursors.list* method supported by a *cursor* resource.
9185/// It is not used directly, but through a [`CursorMethods`] instance.
9186///
9187/// # Example
9188///
9189/// Instantiate a resource method builder
9190///
9191/// ```test_harness,no_run
9192/// # extern crate hyper;
9193/// # extern crate hyper_rustls;
9194/// # extern crate google_pubsublite1 as pubsublite1;
9195/// # async fn dox() {
9196/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9197///
9198/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9199/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9200/// #     .with_native_roots()
9201/// #     .unwrap()
9202/// #     .https_only()
9203/// #     .enable_http2()
9204/// #     .build();
9205///
9206/// # let executor = hyper_util::rt::TokioExecutor::new();
9207/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9208/// #     secret,
9209/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9210/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9211/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9212/// #     ),
9213/// # ).build().await.unwrap();
9214///
9215/// # let client = hyper_util::client::legacy::Client::builder(
9216/// #     hyper_util::rt::TokioExecutor::new()
9217/// # )
9218/// # .build(
9219/// #     hyper_rustls::HttpsConnectorBuilder::new()
9220/// #         .with_native_roots()
9221/// #         .unwrap()
9222/// #         .https_or_http()
9223/// #         .enable_http2()
9224/// #         .build()
9225/// # );
9226/// # let mut hub = PubsubLite::new(client, auth);
9227/// // You can configure optional parameters by calling the respective setters at will, and
9228/// // execute the final call using `doit()`.
9229/// // Values shown here are possibly random and not representative !
9230/// let result = hub.cursor().projects_locations_subscriptions_cursors_list("parent")
9231///              .page_token("sed")
9232///              .page_size(-24)
9233///              .doit().await;
9234/// # }
9235/// ```
9236pub struct CursorProjectLocationSubscriptionCursorListCall<'a, C>
9237where
9238    C: 'a,
9239{
9240    hub: &'a PubsubLite<C>,
9241    _parent: String,
9242    _page_token: Option<String>,
9243    _page_size: Option<i32>,
9244    _delegate: Option<&'a mut dyn common::Delegate>,
9245    _additional_params: HashMap<String, String>,
9246    _scopes: BTreeSet<String>,
9247}
9248
9249impl<'a, C> common::CallBuilder for CursorProjectLocationSubscriptionCursorListCall<'a, C> {}
9250
9251impl<'a, C> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9252where
9253    C: common::Connector,
9254{
9255    /// Perform the operation you have build so far.
9256    pub async fn doit(
9257        mut self,
9258    ) -> common::Result<(common::Response, ListPartitionCursorsResponse)> {
9259        use std::borrow::Cow;
9260        use std::io::{Read, Seek};
9261
9262        use common::{url::Params, ToParts};
9263        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9264
9265        let mut dd = common::DefaultDelegate;
9266        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9267        dlg.begin(common::MethodInfo {
9268            id: "pubsublite.cursor.projects.locations.subscriptions.cursors.list",
9269            http_method: hyper::Method::GET,
9270        });
9271
9272        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9273            if self._additional_params.contains_key(field) {
9274                dlg.finished(false);
9275                return Err(common::Error::FieldClash(field));
9276            }
9277        }
9278
9279        let mut params = Params::with_capacity(5 + self._additional_params.len());
9280        params.push("parent", self._parent);
9281        if let Some(value) = self._page_token.as_ref() {
9282            params.push("pageToken", value);
9283        }
9284        if let Some(value) = self._page_size.as_ref() {
9285            params.push("pageSize", value.to_string());
9286        }
9287
9288        params.extend(self._additional_params.iter());
9289
9290        params.push("alt", "json");
9291        let mut url = self.hub._base_url.clone() + "v1/cursor/{+parent}/cursors";
9292        if self._scopes.is_empty() {
9293            self._scopes
9294                .insert(Scope::CloudPlatform.as_ref().to_string());
9295        }
9296
9297        #[allow(clippy::single_element_loop)]
9298        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9299            url = params.uri_replacement(url, param_name, find_this, true);
9300        }
9301        {
9302            let to_remove = ["parent"];
9303            params.remove_params(&to_remove);
9304        }
9305
9306        let url = params.parse_with_url(&url);
9307
9308        loop {
9309            let token = match self
9310                .hub
9311                .auth
9312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9313                .await
9314            {
9315                Ok(token) => token,
9316                Err(e) => match dlg.token(e) {
9317                    Ok(token) => token,
9318                    Err(e) => {
9319                        dlg.finished(false);
9320                        return Err(common::Error::MissingToken(e));
9321                    }
9322                },
9323            };
9324            let mut req_result = {
9325                let client = &self.hub.client;
9326                dlg.pre_request();
9327                let mut req_builder = hyper::Request::builder()
9328                    .method(hyper::Method::GET)
9329                    .uri(url.as_str())
9330                    .header(USER_AGENT, self.hub._user_agent.clone());
9331
9332                if let Some(token) = token.as_ref() {
9333                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9334                }
9335
9336                let request = req_builder
9337                    .header(CONTENT_LENGTH, 0_u64)
9338                    .body(common::to_body::<String>(None));
9339
9340                client.request(request.unwrap()).await
9341            };
9342
9343            match req_result {
9344                Err(err) => {
9345                    if let common::Retry::After(d) = dlg.http_error(&err) {
9346                        sleep(d).await;
9347                        continue;
9348                    }
9349                    dlg.finished(false);
9350                    return Err(common::Error::HttpError(err));
9351                }
9352                Ok(res) => {
9353                    let (mut parts, body) = res.into_parts();
9354                    let mut body = common::Body::new(body);
9355                    if !parts.status.is_success() {
9356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9357                        let error = serde_json::from_str(&common::to_string(&bytes));
9358                        let response = common::to_response(parts, bytes.into());
9359
9360                        if let common::Retry::After(d) =
9361                            dlg.http_failure(&response, error.as_ref().ok())
9362                        {
9363                            sleep(d).await;
9364                            continue;
9365                        }
9366
9367                        dlg.finished(false);
9368
9369                        return Err(match error {
9370                            Ok(value) => common::Error::BadRequest(value),
9371                            _ => common::Error::Failure(response),
9372                        });
9373                    }
9374                    let response = {
9375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9376                        let encoded = common::to_string(&bytes);
9377                        match serde_json::from_str(&encoded) {
9378                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9379                            Err(error) => {
9380                                dlg.response_json_decode_error(&encoded, &error);
9381                                return Err(common::Error::JsonDecodeError(
9382                                    encoded.to_string(),
9383                                    error,
9384                                ));
9385                            }
9386                        }
9387                    };
9388
9389                    dlg.finished(true);
9390                    return Ok(response);
9391                }
9392            }
9393        }
9394    }
9395
9396    /// Required. The subscription for which to retrieve cursors. Structured like `projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.
9397    ///
9398    /// Sets the *parent* path property to the given value.
9399    ///
9400    /// Even though the property as already been set when instantiating this call,
9401    /// we provide this method for API completeness.
9402    pub fn parent(
9403        mut self,
9404        new_value: &str,
9405    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9406        self._parent = new_value.to_string();
9407        self
9408    }
9409    /// 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.
9410    ///
9411    /// Sets the *page token* query property to the given value.
9412    pub fn page_token(
9413        mut self,
9414        new_value: &str,
9415    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9416        self._page_token = Some(new_value.to_string());
9417        self
9418    }
9419    /// 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.
9420    ///
9421    /// Sets the *page size* query property to the given value.
9422    pub fn page_size(
9423        mut self,
9424        new_value: i32,
9425    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9426        self._page_size = Some(new_value);
9427        self
9428    }
9429    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9430    /// while executing the actual API request.
9431    ///
9432    /// ````text
9433    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9434    /// ````
9435    ///
9436    /// Sets the *delegate* property to the given value.
9437    pub fn delegate(
9438        mut self,
9439        new_value: &'a mut dyn common::Delegate,
9440    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9441        self._delegate = Some(new_value);
9442        self
9443    }
9444
9445    /// Set any additional parameter of the query string used in the request.
9446    /// It should be used to set parameters which are not yet available through their own
9447    /// setters.
9448    ///
9449    /// Please note that this method must not be used to set any of the known parameters
9450    /// which have their own setter method. If done anyway, the request will fail.
9451    ///
9452    /// # Additional Parameters
9453    ///
9454    /// * *$.xgafv* (query-string) - V1 error format.
9455    /// * *access_token* (query-string) - OAuth access token.
9456    /// * *alt* (query-string) - Data format for response.
9457    /// * *callback* (query-string) - JSONP
9458    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9459    /// * *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.
9460    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9461    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9462    /// * *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.
9463    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9464    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9465    pub fn param<T>(
9466        mut self,
9467        name: T,
9468        value: T,
9469    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9470    where
9471        T: AsRef<str>,
9472    {
9473        self._additional_params
9474            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9475        self
9476    }
9477
9478    /// Identifies the authorization scope for the method you are building.
9479    ///
9480    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9481    /// [`Scope::CloudPlatform`].
9482    ///
9483    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9484    /// tokens for more than one scope.
9485    ///
9486    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9487    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9488    /// sufficient, a read-write scope will do as well.
9489    pub fn add_scope<St>(
9490        mut self,
9491        scope: St,
9492    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9493    where
9494        St: AsRef<str>,
9495    {
9496        self._scopes.insert(String::from(scope.as_ref()));
9497        self
9498    }
9499    /// Identifies the authorization scope(s) for the method you are building.
9500    ///
9501    /// See [`Self::add_scope()`] for details.
9502    pub fn add_scopes<I, St>(
9503        mut self,
9504        scopes: I,
9505    ) -> CursorProjectLocationSubscriptionCursorListCall<'a, C>
9506    where
9507        I: IntoIterator<Item = St>,
9508        St: AsRef<str>,
9509    {
9510        self._scopes
9511            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9512        self
9513    }
9514
9515    /// Removes all scopes, and no default scope will be used either.
9516    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9517    /// for details).
9518    pub fn clear_scopes(mut self) -> CursorProjectLocationSubscriptionCursorListCall<'a, C> {
9519        self._scopes.clear();
9520        self
9521    }
9522}
9523
9524/// Updates the committed cursor.
9525///
9526/// A builder for the *projects.locations.subscriptions.commitCursor* method supported by a *cursor* resource.
9527/// It is not used directly, but through a [`CursorMethods`] instance.
9528///
9529/// # Example
9530///
9531/// Instantiate a resource method builder
9532///
9533/// ```test_harness,no_run
9534/// # extern crate hyper;
9535/// # extern crate hyper_rustls;
9536/// # extern crate google_pubsublite1 as pubsublite1;
9537/// use pubsublite1::api::CommitCursorRequest;
9538/// # async fn dox() {
9539/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9540///
9541/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9542/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9543/// #     .with_native_roots()
9544/// #     .unwrap()
9545/// #     .https_only()
9546/// #     .enable_http2()
9547/// #     .build();
9548///
9549/// # let executor = hyper_util::rt::TokioExecutor::new();
9550/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9551/// #     secret,
9552/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9553/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9554/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9555/// #     ),
9556/// # ).build().await.unwrap();
9557///
9558/// # let client = hyper_util::client::legacy::Client::builder(
9559/// #     hyper_util::rt::TokioExecutor::new()
9560/// # )
9561/// # .build(
9562/// #     hyper_rustls::HttpsConnectorBuilder::new()
9563/// #         .with_native_roots()
9564/// #         .unwrap()
9565/// #         .https_or_http()
9566/// #         .enable_http2()
9567/// #         .build()
9568/// # );
9569/// # let mut hub = PubsubLite::new(client, auth);
9570/// // As the method needs a request, you would usually fill it with the desired information
9571/// // into the respective structure. Some of the parts shown here might not be applicable !
9572/// // Values shown here are possibly random and not representative !
9573/// let mut req = CommitCursorRequest::default();
9574///
9575/// // You can configure optional parameters by calling the respective setters at will, and
9576/// // execute the final call using `doit()`.
9577/// // Values shown here are possibly random and not representative !
9578/// let result = hub.cursor().projects_locations_subscriptions_commit_cursor(req, "subscription")
9579///              .doit().await;
9580/// # }
9581/// ```
9582pub struct CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9583where
9584    C: 'a,
9585{
9586    hub: &'a PubsubLite<C>,
9587    _request: CommitCursorRequest,
9588    _subscription: String,
9589    _delegate: Option<&'a mut dyn common::Delegate>,
9590    _additional_params: HashMap<String, String>,
9591    _scopes: BTreeSet<String>,
9592}
9593
9594impl<'a, C> common::CallBuilder for CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {}
9595
9596impl<'a, C> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9597where
9598    C: common::Connector,
9599{
9600    /// Perform the operation you have build so far.
9601    pub async fn doit(mut self) -> common::Result<(common::Response, CommitCursorResponse)> {
9602        use std::borrow::Cow;
9603        use std::io::{Read, Seek};
9604
9605        use common::{url::Params, ToParts};
9606        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9607
9608        let mut dd = common::DefaultDelegate;
9609        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9610        dlg.begin(common::MethodInfo {
9611            id: "pubsublite.cursor.projects.locations.subscriptions.commitCursor",
9612            http_method: hyper::Method::POST,
9613        });
9614
9615        for &field in ["alt", "subscription"].iter() {
9616            if self._additional_params.contains_key(field) {
9617                dlg.finished(false);
9618                return Err(common::Error::FieldClash(field));
9619            }
9620        }
9621
9622        let mut params = Params::with_capacity(4 + self._additional_params.len());
9623        params.push("subscription", self._subscription);
9624
9625        params.extend(self._additional_params.iter());
9626
9627        params.push("alt", "json");
9628        let mut url = self.hub._base_url.clone() + "v1/cursor/{+subscription}:commitCursor";
9629        if self._scopes.is_empty() {
9630            self._scopes
9631                .insert(Scope::CloudPlatform.as_ref().to_string());
9632        }
9633
9634        #[allow(clippy::single_element_loop)]
9635        for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
9636            url = params.uri_replacement(url, param_name, find_this, true);
9637        }
9638        {
9639            let to_remove = ["subscription"];
9640            params.remove_params(&to_remove);
9641        }
9642
9643        let url = params.parse_with_url(&url);
9644
9645        let mut json_mime_type = mime::APPLICATION_JSON;
9646        let mut request_value_reader = {
9647            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9648            common::remove_json_null_values(&mut value);
9649            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9650            serde_json::to_writer(&mut dst, &value).unwrap();
9651            dst
9652        };
9653        let request_size = request_value_reader
9654            .seek(std::io::SeekFrom::End(0))
9655            .unwrap();
9656        request_value_reader
9657            .seek(std::io::SeekFrom::Start(0))
9658            .unwrap();
9659
9660        loop {
9661            let token = match self
9662                .hub
9663                .auth
9664                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9665                .await
9666            {
9667                Ok(token) => token,
9668                Err(e) => match dlg.token(e) {
9669                    Ok(token) => token,
9670                    Err(e) => {
9671                        dlg.finished(false);
9672                        return Err(common::Error::MissingToken(e));
9673                    }
9674                },
9675            };
9676            request_value_reader
9677                .seek(std::io::SeekFrom::Start(0))
9678                .unwrap();
9679            let mut req_result = {
9680                let client = &self.hub.client;
9681                dlg.pre_request();
9682                let mut req_builder = hyper::Request::builder()
9683                    .method(hyper::Method::POST)
9684                    .uri(url.as_str())
9685                    .header(USER_AGENT, self.hub._user_agent.clone());
9686
9687                if let Some(token) = token.as_ref() {
9688                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9689                }
9690
9691                let request = req_builder
9692                    .header(CONTENT_TYPE, json_mime_type.to_string())
9693                    .header(CONTENT_LENGTH, request_size as u64)
9694                    .body(common::to_body(
9695                        request_value_reader.get_ref().clone().into(),
9696                    ));
9697
9698                client.request(request.unwrap()).await
9699            };
9700
9701            match req_result {
9702                Err(err) => {
9703                    if let common::Retry::After(d) = dlg.http_error(&err) {
9704                        sleep(d).await;
9705                        continue;
9706                    }
9707                    dlg.finished(false);
9708                    return Err(common::Error::HttpError(err));
9709                }
9710                Ok(res) => {
9711                    let (mut parts, body) = res.into_parts();
9712                    let mut body = common::Body::new(body);
9713                    if !parts.status.is_success() {
9714                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9715                        let error = serde_json::from_str(&common::to_string(&bytes));
9716                        let response = common::to_response(parts, bytes.into());
9717
9718                        if let common::Retry::After(d) =
9719                            dlg.http_failure(&response, error.as_ref().ok())
9720                        {
9721                            sleep(d).await;
9722                            continue;
9723                        }
9724
9725                        dlg.finished(false);
9726
9727                        return Err(match error {
9728                            Ok(value) => common::Error::BadRequest(value),
9729                            _ => common::Error::Failure(response),
9730                        });
9731                    }
9732                    let response = {
9733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9734                        let encoded = common::to_string(&bytes);
9735                        match serde_json::from_str(&encoded) {
9736                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9737                            Err(error) => {
9738                                dlg.response_json_decode_error(&encoded, &error);
9739                                return Err(common::Error::JsonDecodeError(
9740                                    encoded.to_string(),
9741                                    error,
9742                                ));
9743                            }
9744                        }
9745                    };
9746
9747                    dlg.finished(true);
9748                    return Ok(response);
9749                }
9750            }
9751        }
9752    }
9753
9754    ///
9755    /// Sets the *request* property to the given value.
9756    ///
9757    /// Even though the property as already been set when instantiating this call,
9758    /// we provide this method for API completeness.
9759    pub fn request(
9760        mut self,
9761        new_value: CommitCursorRequest,
9762    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9763        self._request = new_value;
9764        self
9765    }
9766    /// The subscription for which to update the cursor.
9767    ///
9768    /// Sets the *subscription* path property to the given value.
9769    ///
9770    /// Even though the property as already been set when instantiating this call,
9771    /// we provide this method for API completeness.
9772    pub fn subscription(
9773        mut self,
9774        new_value: &str,
9775    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9776        self._subscription = new_value.to_string();
9777        self
9778    }
9779    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9780    /// while executing the actual API request.
9781    ///
9782    /// ````text
9783    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9784    /// ````
9785    ///
9786    /// Sets the *delegate* property to the given value.
9787    pub fn delegate(
9788        mut self,
9789        new_value: &'a mut dyn common::Delegate,
9790    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9791        self._delegate = Some(new_value);
9792        self
9793    }
9794
9795    /// Set any additional parameter of the query string used in the request.
9796    /// It should be used to set parameters which are not yet available through their own
9797    /// setters.
9798    ///
9799    /// Please note that this method must not be used to set any of the known parameters
9800    /// which have their own setter method. If done anyway, the request will fail.
9801    ///
9802    /// # Additional Parameters
9803    ///
9804    /// * *$.xgafv* (query-string) - V1 error format.
9805    /// * *access_token* (query-string) - OAuth access token.
9806    /// * *alt* (query-string) - Data format for response.
9807    /// * *callback* (query-string) - JSONP
9808    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9809    /// * *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.
9810    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9811    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9812    /// * *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.
9813    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9814    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9815    pub fn param<T>(
9816        mut self,
9817        name: T,
9818        value: T,
9819    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9820    where
9821        T: AsRef<str>,
9822    {
9823        self._additional_params
9824            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9825        self
9826    }
9827
9828    /// Identifies the authorization scope for the method you are building.
9829    ///
9830    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9831    /// [`Scope::CloudPlatform`].
9832    ///
9833    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9834    /// tokens for more than one scope.
9835    ///
9836    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9837    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9838    /// sufficient, a read-write scope will do as well.
9839    pub fn add_scope<St>(
9840        mut self,
9841        scope: St,
9842    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9843    where
9844        St: AsRef<str>,
9845    {
9846        self._scopes.insert(String::from(scope.as_ref()));
9847        self
9848    }
9849    /// Identifies the authorization scope(s) for the method you are building.
9850    ///
9851    /// See [`Self::add_scope()`] for details.
9852    pub fn add_scopes<I, St>(
9853        mut self,
9854        scopes: I,
9855    ) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C>
9856    where
9857        I: IntoIterator<Item = St>,
9858        St: AsRef<str>,
9859    {
9860        self._scopes
9861            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9862        self
9863    }
9864
9865    /// Removes all scopes, and no default scope will be used either.
9866    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9867    /// for details).
9868    pub fn clear_scopes(mut self) -> CursorProjectLocationSubscriptionCommitCursorCall<'a, C> {
9869        self._scopes.clear();
9870        self
9871    }
9872}
9873
9874/// 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.
9875///
9876/// A builder for the *projects.locations.topics.computeHeadCursor* method supported by a *topicStat* resource.
9877/// It is not used directly, but through a [`TopicStatMethods`] instance.
9878///
9879/// # Example
9880///
9881/// Instantiate a resource method builder
9882///
9883/// ```test_harness,no_run
9884/// # extern crate hyper;
9885/// # extern crate hyper_rustls;
9886/// # extern crate google_pubsublite1 as pubsublite1;
9887/// use pubsublite1::api::ComputeHeadCursorRequest;
9888/// # async fn dox() {
9889/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9890///
9891/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9892/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9893/// #     .with_native_roots()
9894/// #     .unwrap()
9895/// #     .https_only()
9896/// #     .enable_http2()
9897/// #     .build();
9898///
9899/// # let executor = hyper_util::rt::TokioExecutor::new();
9900/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9901/// #     secret,
9902/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9903/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9904/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9905/// #     ),
9906/// # ).build().await.unwrap();
9907///
9908/// # let client = hyper_util::client::legacy::Client::builder(
9909/// #     hyper_util::rt::TokioExecutor::new()
9910/// # )
9911/// # .build(
9912/// #     hyper_rustls::HttpsConnectorBuilder::new()
9913/// #         .with_native_roots()
9914/// #         .unwrap()
9915/// #         .https_or_http()
9916/// #         .enable_http2()
9917/// #         .build()
9918/// # );
9919/// # let mut hub = PubsubLite::new(client, auth);
9920/// // As the method needs a request, you would usually fill it with the desired information
9921/// // into the respective structure. Some of the parts shown here might not be applicable !
9922/// // Values shown here are possibly random and not representative !
9923/// let mut req = ComputeHeadCursorRequest::default();
9924///
9925/// // You can configure optional parameters by calling the respective setters at will, and
9926/// // execute the final call using `doit()`.
9927/// // Values shown here are possibly random and not representative !
9928/// let result = hub.topic_stats().projects_locations_topics_compute_head_cursor(req, "topic")
9929///              .doit().await;
9930/// # }
9931/// ```
9932pub struct TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9933where
9934    C: 'a,
9935{
9936    hub: &'a PubsubLite<C>,
9937    _request: ComputeHeadCursorRequest,
9938    _topic: String,
9939    _delegate: Option<&'a mut dyn common::Delegate>,
9940    _additional_params: HashMap<String, String>,
9941    _scopes: BTreeSet<String>,
9942}
9943
9944impl<'a, C> common::CallBuilder for TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {}
9945
9946impl<'a, C> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
9947where
9948    C: common::Connector,
9949{
9950    /// Perform the operation you have build so far.
9951    pub async fn doit(mut self) -> common::Result<(common::Response, ComputeHeadCursorResponse)> {
9952        use std::borrow::Cow;
9953        use std::io::{Read, Seek};
9954
9955        use common::{url::Params, ToParts};
9956        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9957
9958        let mut dd = common::DefaultDelegate;
9959        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9960        dlg.begin(common::MethodInfo {
9961            id: "pubsublite.topicStats.projects.locations.topics.computeHeadCursor",
9962            http_method: hyper::Method::POST,
9963        });
9964
9965        for &field in ["alt", "topic"].iter() {
9966            if self._additional_params.contains_key(field) {
9967                dlg.finished(false);
9968                return Err(common::Error::FieldClash(field));
9969            }
9970        }
9971
9972        let mut params = Params::with_capacity(4 + self._additional_params.len());
9973        params.push("topic", self._topic);
9974
9975        params.extend(self._additional_params.iter());
9976
9977        params.push("alt", "json");
9978        let mut url = self.hub._base_url.clone() + "v1/topicStats/{+topic}:computeHeadCursor";
9979        if self._scopes.is_empty() {
9980            self._scopes
9981                .insert(Scope::CloudPlatform.as_ref().to_string());
9982        }
9983
9984        #[allow(clippy::single_element_loop)]
9985        for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
9986            url = params.uri_replacement(url, param_name, find_this, true);
9987        }
9988        {
9989            let to_remove = ["topic"];
9990            params.remove_params(&to_remove);
9991        }
9992
9993        let url = params.parse_with_url(&url);
9994
9995        let mut json_mime_type = mime::APPLICATION_JSON;
9996        let mut request_value_reader = {
9997            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9998            common::remove_json_null_values(&mut value);
9999            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10000            serde_json::to_writer(&mut dst, &value).unwrap();
10001            dst
10002        };
10003        let request_size = request_value_reader
10004            .seek(std::io::SeekFrom::End(0))
10005            .unwrap();
10006        request_value_reader
10007            .seek(std::io::SeekFrom::Start(0))
10008            .unwrap();
10009
10010        loop {
10011            let token = match self
10012                .hub
10013                .auth
10014                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10015                .await
10016            {
10017                Ok(token) => token,
10018                Err(e) => match dlg.token(e) {
10019                    Ok(token) => token,
10020                    Err(e) => {
10021                        dlg.finished(false);
10022                        return Err(common::Error::MissingToken(e));
10023                    }
10024                },
10025            };
10026            request_value_reader
10027                .seek(std::io::SeekFrom::Start(0))
10028                .unwrap();
10029            let mut req_result = {
10030                let client = &self.hub.client;
10031                dlg.pre_request();
10032                let mut req_builder = hyper::Request::builder()
10033                    .method(hyper::Method::POST)
10034                    .uri(url.as_str())
10035                    .header(USER_AGENT, self.hub._user_agent.clone());
10036
10037                if let Some(token) = token.as_ref() {
10038                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10039                }
10040
10041                let request = req_builder
10042                    .header(CONTENT_TYPE, json_mime_type.to_string())
10043                    .header(CONTENT_LENGTH, request_size as u64)
10044                    .body(common::to_body(
10045                        request_value_reader.get_ref().clone().into(),
10046                    ));
10047
10048                client.request(request.unwrap()).await
10049            };
10050
10051            match req_result {
10052                Err(err) => {
10053                    if let common::Retry::After(d) = dlg.http_error(&err) {
10054                        sleep(d).await;
10055                        continue;
10056                    }
10057                    dlg.finished(false);
10058                    return Err(common::Error::HttpError(err));
10059                }
10060                Ok(res) => {
10061                    let (mut parts, body) = res.into_parts();
10062                    let mut body = common::Body::new(body);
10063                    if !parts.status.is_success() {
10064                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10065                        let error = serde_json::from_str(&common::to_string(&bytes));
10066                        let response = common::to_response(parts, bytes.into());
10067
10068                        if let common::Retry::After(d) =
10069                            dlg.http_failure(&response, error.as_ref().ok())
10070                        {
10071                            sleep(d).await;
10072                            continue;
10073                        }
10074
10075                        dlg.finished(false);
10076
10077                        return Err(match error {
10078                            Ok(value) => common::Error::BadRequest(value),
10079                            _ => common::Error::Failure(response),
10080                        });
10081                    }
10082                    let response = {
10083                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10084                        let encoded = common::to_string(&bytes);
10085                        match serde_json::from_str(&encoded) {
10086                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10087                            Err(error) => {
10088                                dlg.response_json_decode_error(&encoded, &error);
10089                                return Err(common::Error::JsonDecodeError(
10090                                    encoded.to_string(),
10091                                    error,
10092                                ));
10093                            }
10094                        }
10095                    };
10096
10097                    dlg.finished(true);
10098                    return Ok(response);
10099                }
10100            }
10101        }
10102    }
10103
10104    ///
10105    /// Sets the *request* property to the given value.
10106    ///
10107    /// Even though the property as already been set when instantiating this call,
10108    /// we provide this method for API completeness.
10109    pub fn request(
10110        mut self,
10111        new_value: ComputeHeadCursorRequest,
10112    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
10113        self._request = new_value;
10114        self
10115    }
10116    /// Required. The topic for which we should compute the head cursor.
10117    ///
10118    /// Sets the *topic* path property to the given value.
10119    ///
10120    /// Even though the property as already been set when instantiating this call,
10121    /// we provide this method for API completeness.
10122    pub fn topic(
10123        mut self,
10124        new_value: &str,
10125    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
10126        self._topic = new_value.to_string();
10127        self
10128    }
10129    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10130    /// while executing the actual API request.
10131    ///
10132    /// ````text
10133    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10134    /// ````
10135    ///
10136    /// Sets the *delegate* property to the given value.
10137    pub fn delegate(
10138        mut self,
10139        new_value: &'a mut dyn common::Delegate,
10140    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
10141        self._delegate = Some(new_value);
10142        self
10143    }
10144
10145    /// Set any additional parameter of the query string used in the request.
10146    /// It should be used to set parameters which are not yet available through their own
10147    /// setters.
10148    ///
10149    /// Please note that this method must not be used to set any of the known parameters
10150    /// which have their own setter method. If done anyway, the request will fail.
10151    ///
10152    /// # Additional Parameters
10153    ///
10154    /// * *$.xgafv* (query-string) - V1 error format.
10155    /// * *access_token* (query-string) - OAuth access token.
10156    /// * *alt* (query-string) - Data format for response.
10157    /// * *callback* (query-string) - JSONP
10158    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10159    /// * *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.
10160    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10161    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10162    /// * *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.
10163    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10164    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10165    pub fn param<T>(
10166        mut self,
10167        name: T,
10168        value: T,
10169    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
10170    where
10171        T: AsRef<str>,
10172    {
10173        self._additional_params
10174            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10175        self
10176    }
10177
10178    /// Identifies the authorization scope for the method you are building.
10179    ///
10180    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10181    /// [`Scope::CloudPlatform`].
10182    ///
10183    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10184    /// tokens for more than one scope.
10185    ///
10186    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10187    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10188    /// sufficient, a read-write scope will do as well.
10189    pub fn add_scope<St>(
10190        mut self,
10191        scope: St,
10192    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
10193    where
10194        St: AsRef<str>,
10195    {
10196        self._scopes.insert(String::from(scope.as_ref()));
10197        self
10198    }
10199    /// Identifies the authorization scope(s) for the method you are building.
10200    ///
10201    /// See [`Self::add_scope()`] for details.
10202    pub fn add_scopes<I, St>(
10203        mut self,
10204        scopes: I,
10205    ) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C>
10206    where
10207        I: IntoIterator<Item = St>,
10208        St: AsRef<str>,
10209    {
10210        self._scopes
10211            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10212        self
10213    }
10214
10215    /// Removes all scopes, and no default scope will be used either.
10216    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10217    /// for details).
10218    pub fn clear_scopes(mut self) -> TopicStatProjectLocationTopicComputeHeadCursorCall<'a, C> {
10219        self._scopes.clear();
10220        self
10221    }
10222}
10223
10224/// Compute statistics about a range of messages in a given topic and partition.
10225///
10226/// A builder for the *projects.locations.topics.computeMessageStats* method supported by a *topicStat* resource.
10227/// It is not used directly, but through a [`TopicStatMethods`] instance.
10228///
10229/// # Example
10230///
10231/// Instantiate a resource method builder
10232///
10233/// ```test_harness,no_run
10234/// # extern crate hyper;
10235/// # extern crate hyper_rustls;
10236/// # extern crate google_pubsublite1 as pubsublite1;
10237/// use pubsublite1::api::ComputeMessageStatsRequest;
10238/// # async fn dox() {
10239/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10240///
10241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10242/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10243/// #     .with_native_roots()
10244/// #     .unwrap()
10245/// #     .https_only()
10246/// #     .enable_http2()
10247/// #     .build();
10248///
10249/// # let executor = hyper_util::rt::TokioExecutor::new();
10250/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10251/// #     secret,
10252/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10253/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10254/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10255/// #     ),
10256/// # ).build().await.unwrap();
10257///
10258/// # let client = hyper_util::client::legacy::Client::builder(
10259/// #     hyper_util::rt::TokioExecutor::new()
10260/// # )
10261/// # .build(
10262/// #     hyper_rustls::HttpsConnectorBuilder::new()
10263/// #         .with_native_roots()
10264/// #         .unwrap()
10265/// #         .https_or_http()
10266/// #         .enable_http2()
10267/// #         .build()
10268/// # );
10269/// # let mut hub = PubsubLite::new(client, auth);
10270/// // As the method needs a request, you would usually fill it with the desired information
10271/// // into the respective structure. Some of the parts shown here might not be applicable !
10272/// // Values shown here are possibly random and not representative !
10273/// let mut req = ComputeMessageStatsRequest::default();
10274///
10275/// // You can configure optional parameters by calling the respective setters at will, and
10276/// // execute the final call using `doit()`.
10277/// // Values shown here are possibly random and not representative !
10278/// let result = hub.topic_stats().projects_locations_topics_compute_message_stats(req, "topic")
10279///              .doit().await;
10280/// # }
10281/// ```
10282pub struct TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10283where
10284    C: 'a,
10285{
10286    hub: &'a PubsubLite<C>,
10287    _request: ComputeMessageStatsRequest,
10288    _topic: String,
10289    _delegate: Option<&'a mut dyn common::Delegate>,
10290    _additional_params: HashMap<String, String>,
10291    _scopes: BTreeSet<String>,
10292}
10293
10294impl<'a, C> common::CallBuilder for TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {}
10295
10296impl<'a, C> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10297where
10298    C: common::Connector,
10299{
10300    /// Perform the operation you have build so far.
10301    pub async fn doit(mut self) -> common::Result<(common::Response, ComputeMessageStatsResponse)> {
10302        use std::borrow::Cow;
10303        use std::io::{Read, Seek};
10304
10305        use common::{url::Params, ToParts};
10306        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10307
10308        let mut dd = common::DefaultDelegate;
10309        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10310        dlg.begin(common::MethodInfo {
10311            id: "pubsublite.topicStats.projects.locations.topics.computeMessageStats",
10312            http_method: hyper::Method::POST,
10313        });
10314
10315        for &field in ["alt", "topic"].iter() {
10316            if self._additional_params.contains_key(field) {
10317                dlg.finished(false);
10318                return Err(common::Error::FieldClash(field));
10319            }
10320        }
10321
10322        let mut params = Params::with_capacity(4 + self._additional_params.len());
10323        params.push("topic", self._topic);
10324
10325        params.extend(self._additional_params.iter());
10326
10327        params.push("alt", "json");
10328        let mut url = self.hub._base_url.clone() + "v1/topicStats/{+topic}:computeMessageStats";
10329        if self._scopes.is_empty() {
10330            self._scopes
10331                .insert(Scope::CloudPlatform.as_ref().to_string());
10332        }
10333
10334        #[allow(clippy::single_element_loop)]
10335        for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
10336            url = params.uri_replacement(url, param_name, find_this, true);
10337        }
10338        {
10339            let to_remove = ["topic"];
10340            params.remove_params(&to_remove);
10341        }
10342
10343        let url = params.parse_with_url(&url);
10344
10345        let mut json_mime_type = mime::APPLICATION_JSON;
10346        let mut request_value_reader = {
10347            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10348            common::remove_json_null_values(&mut value);
10349            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10350            serde_json::to_writer(&mut dst, &value).unwrap();
10351            dst
10352        };
10353        let request_size = request_value_reader
10354            .seek(std::io::SeekFrom::End(0))
10355            .unwrap();
10356        request_value_reader
10357            .seek(std::io::SeekFrom::Start(0))
10358            .unwrap();
10359
10360        loop {
10361            let token = match self
10362                .hub
10363                .auth
10364                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10365                .await
10366            {
10367                Ok(token) => token,
10368                Err(e) => match dlg.token(e) {
10369                    Ok(token) => token,
10370                    Err(e) => {
10371                        dlg.finished(false);
10372                        return Err(common::Error::MissingToken(e));
10373                    }
10374                },
10375            };
10376            request_value_reader
10377                .seek(std::io::SeekFrom::Start(0))
10378                .unwrap();
10379            let mut req_result = {
10380                let client = &self.hub.client;
10381                dlg.pre_request();
10382                let mut req_builder = hyper::Request::builder()
10383                    .method(hyper::Method::POST)
10384                    .uri(url.as_str())
10385                    .header(USER_AGENT, self.hub._user_agent.clone());
10386
10387                if let Some(token) = token.as_ref() {
10388                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10389                }
10390
10391                let request = req_builder
10392                    .header(CONTENT_TYPE, json_mime_type.to_string())
10393                    .header(CONTENT_LENGTH, request_size as u64)
10394                    .body(common::to_body(
10395                        request_value_reader.get_ref().clone().into(),
10396                    ));
10397
10398                client.request(request.unwrap()).await
10399            };
10400
10401            match req_result {
10402                Err(err) => {
10403                    if let common::Retry::After(d) = dlg.http_error(&err) {
10404                        sleep(d).await;
10405                        continue;
10406                    }
10407                    dlg.finished(false);
10408                    return Err(common::Error::HttpError(err));
10409                }
10410                Ok(res) => {
10411                    let (mut parts, body) = res.into_parts();
10412                    let mut body = common::Body::new(body);
10413                    if !parts.status.is_success() {
10414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10415                        let error = serde_json::from_str(&common::to_string(&bytes));
10416                        let response = common::to_response(parts, bytes.into());
10417
10418                        if let common::Retry::After(d) =
10419                            dlg.http_failure(&response, error.as_ref().ok())
10420                        {
10421                            sleep(d).await;
10422                            continue;
10423                        }
10424
10425                        dlg.finished(false);
10426
10427                        return Err(match error {
10428                            Ok(value) => common::Error::BadRequest(value),
10429                            _ => common::Error::Failure(response),
10430                        });
10431                    }
10432                    let response = {
10433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10434                        let encoded = common::to_string(&bytes);
10435                        match serde_json::from_str(&encoded) {
10436                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10437                            Err(error) => {
10438                                dlg.response_json_decode_error(&encoded, &error);
10439                                return Err(common::Error::JsonDecodeError(
10440                                    encoded.to_string(),
10441                                    error,
10442                                ));
10443                            }
10444                        }
10445                    };
10446
10447                    dlg.finished(true);
10448                    return Ok(response);
10449                }
10450            }
10451        }
10452    }
10453
10454    ///
10455    /// Sets the *request* property to the given value.
10456    ///
10457    /// Even though the property as already been set when instantiating this call,
10458    /// we provide this method for API completeness.
10459    pub fn request(
10460        mut self,
10461        new_value: ComputeMessageStatsRequest,
10462    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10463        self._request = new_value;
10464        self
10465    }
10466    /// Required. The topic for which we should compute message stats.
10467    ///
10468    /// Sets the *topic* path property to the given value.
10469    ///
10470    /// Even though the property as already been set when instantiating this call,
10471    /// we provide this method for API completeness.
10472    pub fn topic(
10473        mut self,
10474        new_value: &str,
10475    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10476        self._topic = new_value.to_string();
10477        self
10478    }
10479    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10480    /// while executing the actual API request.
10481    ///
10482    /// ````text
10483    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10484    /// ````
10485    ///
10486    /// Sets the *delegate* property to the given value.
10487    pub fn delegate(
10488        mut self,
10489        new_value: &'a mut dyn common::Delegate,
10490    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10491        self._delegate = Some(new_value);
10492        self
10493    }
10494
10495    /// Set any additional parameter of the query string used in the request.
10496    /// It should be used to set parameters which are not yet available through their own
10497    /// setters.
10498    ///
10499    /// Please note that this method must not be used to set any of the known parameters
10500    /// which have their own setter method. If done anyway, the request will fail.
10501    ///
10502    /// # Additional Parameters
10503    ///
10504    /// * *$.xgafv* (query-string) - V1 error format.
10505    /// * *access_token* (query-string) - OAuth access token.
10506    /// * *alt* (query-string) - Data format for response.
10507    /// * *callback* (query-string) - JSONP
10508    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10509    /// * *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.
10510    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10511    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10512    /// * *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.
10513    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10514    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10515    pub fn param<T>(
10516        mut self,
10517        name: T,
10518        value: T,
10519    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10520    where
10521        T: AsRef<str>,
10522    {
10523        self._additional_params
10524            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10525        self
10526    }
10527
10528    /// Identifies the authorization scope for the method you are building.
10529    ///
10530    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10531    /// [`Scope::CloudPlatform`].
10532    ///
10533    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10534    /// tokens for more than one scope.
10535    ///
10536    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10537    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10538    /// sufficient, a read-write scope will do as well.
10539    pub fn add_scope<St>(
10540        mut self,
10541        scope: St,
10542    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10543    where
10544        St: AsRef<str>,
10545    {
10546        self._scopes.insert(String::from(scope.as_ref()));
10547        self
10548    }
10549    /// Identifies the authorization scope(s) for the method you are building.
10550    ///
10551    /// See [`Self::add_scope()`] for details.
10552    pub fn add_scopes<I, St>(
10553        mut self,
10554        scopes: I,
10555    ) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C>
10556    where
10557        I: IntoIterator<Item = St>,
10558        St: AsRef<str>,
10559    {
10560        self._scopes
10561            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10562        self
10563    }
10564
10565    /// Removes all scopes, and no default scope will be used either.
10566    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10567    /// for details).
10568    pub fn clear_scopes(mut self) -> TopicStatProjectLocationTopicComputeMessageStatCall<'a, C> {
10569        self._scopes.clear();
10570        self
10571    }
10572}
10573
10574/// Compute the corresponding cursor for a publish or event time in a topic partition.
10575///
10576/// A builder for the *projects.locations.topics.computeTimeCursor* method supported by a *topicStat* resource.
10577/// It is not used directly, but through a [`TopicStatMethods`] instance.
10578///
10579/// # Example
10580///
10581/// Instantiate a resource method builder
10582///
10583/// ```test_harness,no_run
10584/// # extern crate hyper;
10585/// # extern crate hyper_rustls;
10586/// # extern crate google_pubsublite1 as pubsublite1;
10587/// use pubsublite1::api::ComputeTimeCursorRequest;
10588/// # async fn dox() {
10589/// # use pubsublite1::{PubsubLite, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10590///
10591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10592/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10593/// #     .with_native_roots()
10594/// #     .unwrap()
10595/// #     .https_only()
10596/// #     .enable_http2()
10597/// #     .build();
10598///
10599/// # let executor = hyper_util::rt::TokioExecutor::new();
10600/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10601/// #     secret,
10602/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10603/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10604/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10605/// #     ),
10606/// # ).build().await.unwrap();
10607///
10608/// # let client = hyper_util::client::legacy::Client::builder(
10609/// #     hyper_util::rt::TokioExecutor::new()
10610/// # )
10611/// # .build(
10612/// #     hyper_rustls::HttpsConnectorBuilder::new()
10613/// #         .with_native_roots()
10614/// #         .unwrap()
10615/// #         .https_or_http()
10616/// #         .enable_http2()
10617/// #         .build()
10618/// # );
10619/// # let mut hub = PubsubLite::new(client, auth);
10620/// // As the method needs a request, you would usually fill it with the desired information
10621/// // into the respective structure. Some of the parts shown here might not be applicable !
10622/// // Values shown here are possibly random and not representative !
10623/// let mut req = ComputeTimeCursorRequest::default();
10624///
10625/// // You can configure optional parameters by calling the respective setters at will, and
10626/// // execute the final call using `doit()`.
10627/// // Values shown here are possibly random and not representative !
10628/// let result = hub.topic_stats().projects_locations_topics_compute_time_cursor(req, "topic")
10629///              .doit().await;
10630/// # }
10631/// ```
10632pub struct TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10633where
10634    C: 'a,
10635{
10636    hub: &'a PubsubLite<C>,
10637    _request: ComputeTimeCursorRequest,
10638    _topic: String,
10639    _delegate: Option<&'a mut dyn common::Delegate>,
10640    _additional_params: HashMap<String, String>,
10641    _scopes: BTreeSet<String>,
10642}
10643
10644impl<'a, C> common::CallBuilder for TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {}
10645
10646impl<'a, C> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10647where
10648    C: common::Connector,
10649{
10650    /// Perform the operation you have build so far.
10651    pub async fn doit(mut self) -> common::Result<(common::Response, ComputeTimeCursorResponse)> {
10652        use std::borrow::Cow;
10653        use std::io::{Read, Seek};
10654
10655        use common::{url::Params, ToParts};
10656        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10657
10658        let mut dd = common::DefaultDelegate;
10659        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10660        dlg.begin(common::MethodInfo {
10661            id: "pubsublite.topicStats.projects.locations.topics.computeTimeCursor",
10662            http_method: hyper::Method::POST,
10663        });
10664
10665        for &field in ["alt", "topic"].iter() {
10666            if self._additional_params.contains_key(field) {
10667                dlg.finished(false);
10668                return Err(common::Error::FieldClash(field));
10669            }
10670        }
10671
10672        let mut params = Params::with_capacity(4 + self._additional_params.len());
10673        params.push("topic", self._topic);
10674
10675        params.extend(self._additional_params.iter());
10676
10677        params.push("alt", "json");
10678        let mut url = self.hub._base_url.clone() + "v1/topicStats/{+topic}:computeTimeCursor";
10679        if self._scopes.is_empty() {
10680            self._scopes
10681                .insert(Scope::CloudPlatform.as_ref().to_string());
10682        }
10683
10684        #[allow(clippy::single_element_loop)]
10685        for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
10686            url = params.uri_replacement(url, param_name, find_this, true);
10687        }
10688        {
10689            let to_remove = ["topic"];
10690            params.remove_params(&to_remove);
10691        }
10692
10693        let url = params.parse_with_url(&url);
10694
10695        let mut json_mime_type = mime::APPLICATION_JSON;
10696        let mut request_value_reader = {
10697            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10698            common::remove_json_null_values(&mut value);
10699            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10700            serde_json::to_writer(&mut dst, &value).unwrap();
10701            dst
10702        };
10703        let request_size = request_value_reader
10704            .seek(std::io::SeekFrom::End(0))
10705            .unwrap();
10706        request_value_reader
10707            .seek(std::io::SeekFrom::Start(0))
10708            .unwrap();
10709
10710        loop {
10711            let token = match self
10712                .hub
10713                .auth
10714                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10715                .await
10716            {
10717                Ok(token) => token,
10718                Err(e) => match dlg.token(e) {
10719                    Ok(token) => token,
10720                    Err(e) => {
10721                        dlg.finished(false);
10722                        return Err(common::Error::MissingToken(e));
10723                    }
10724                },
10725            };
10726            request_value_reader
10727                .seek(std::io::SeekFrom::Start(0))
10728                .unwrap();
10729            let mut req_result = {
10730                let client = &self.hub.client;
10731                dlg.pre_request();
10732                let mut req_builder = hyper::Request::builder()
10733                    .method(hyper::Method::POST)
10734                    .uri(url.as_str())
10735                    .header(USER_AGENT, self.hub._user_agent.clone());
10736
10737                if let Some(token) = token.as_ref() {
10738                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10739                }
10740
10741                let request = req_builder
10742                    .header(CONTENT_TYPE, json_mime_type.to_string())
10743                    .header(CONTENT_LENGTH, request_size as u64)
10744                    .body(common::to_body(
10745                        request_value_reader.get_ref().clone().into(),
10746                    ));
10747
10748                client.request(request.unwrap()).await
10749            };
10750
10751            match req_result {
10752                Err(err) => {
10753                    if let common::Retry::After(d) = dlg.http_error(&err) {
10754                        sleep(d).await;
10755                        continue;
10756                    }
10757                    dlg.finished(false);
10758                    return Err(common::Error::HttpError(err));
10759                }
10760                Ok(res) => {
10761                    let (mut parts, body) = res.into_parts();
10762                    let mut body = common::Body::new(body);
10763                    if !parts.status.is_success() {
10764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10765                        let error = serde_json::from_str(&common::to_string(&bytes));
10766                        let response = common::to_response(parts, bytes.into());
10767
10768                        if let common::Retry::After(d) =
10769                            dlg.http_failure(&response, error.as_ref().ok())
10770                        {
10771                            sleep(d).await;
10772                            continue;
10773                        }
10774
10775                        dlg.finished(false);
10776
10777                        return Err(match error {
10778                            Ok(value) => common::Error::BadRequest(value),
10779                            _ => common::Error::Failure(response),
10780                        });
10781                    }
10782                    let response = {
10783                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10784                        let encoded = common::to_string(&bytes);
10785                        match serde_json::from_str(&encoded) {
10786                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10787                            Err(error) => {
10788                                dlg.response_json_decode_error(&encoded, &error);
10789                                return Err(common::Error::JsonDecodeError(
10790                                    encoded.to_string(),
10791                                    error,
10792                                ));
10793                            }
10794                        }
10795                    };
10796
10797                    dlg.finished(true);
10798                    return Ok(response);
10799                }
10800            }
10801        }
10802    }
10803
10804    ///
10805    /// Sets the *request* property to the given value.
10806    ///
10807    /// Even though the property as already been set when instantiating this call,
10808    /// we provide this method for API completeness.
10809    pub fn request(
10810        mut self,
10811        new_value: ComputeTimeCursorRequest,
10812    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10813        self._request = new_value;
10814        self
10815    }
10816    /// Required. The topic for which we should compute the cursor.
10817    ///
10818    /// Sets the *topic* path property to the given value.
10819    ///
10820    /// Even though the property as already been set when instantiating this call,
10821    /// we provide this method for API completeness.
10822    pub fn topic(
10823        mut self,
10824        new_value: &str,
10825    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10826        self._topic = new_value.to_string();
10827        self
10828    }
10829    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10830    /// while executing the actual API request.
10831    ///
10832    /// ````text
10833    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10834    /// ````
10835    ///
10836    /// Sets the *delegate* property to the given value.
10837    pub fn delegate(
10838        mut self,
10839        new_value: &'a mut dyn common::Delegate,
10840    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10841        self._delegate = Some(new_value);
10842        self
10843    }
10844
10845    /// Set any additional parameter of the query string used in the request.
10846    /// It should be used to set parameters which are not yet available through their own
10847    /// setters.
10848    ///
10849    /// Please note that this method must not be used to set any of the known parameters
10850    /// which have their own setter method. If done anyway, the request will fail.
10851    ///
10852    /// # Additional Parameters
10853    ///
10854    /// * *$.xgafv* (query-string) - V1 error format.
10855    /// * *access_token* (query-string) - OAuth access token.
10856    /// * *alt* (query-string) - Data format for response.
10857    /// * *callback* (query-string) - JSONP
10858    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10859    /// * *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.
10860    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10861    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10862    /// * *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.
10863    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10864    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10865    pub fn param<T>(
10866        mut self,
10867        name: T,
10868        value: T,
10869    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10870    where
10871        T: AsRef<str>,
10872    {
10873        self._additional_params
10874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10875        self
10876    }
10877
10878    /// Identifies the authorization scope for the method you are building.
10879    ///
10880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10881    /// [`Scope::CloudPlatform`].
10882    ///
10883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10884    /// tokens for more than one scope.
10885    ///
10886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10888    /// sufficient, a read-write scope will do as well.
10889    pub fn add_scope<St>(
10890        mut self,
10891        scope: St,
10892    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10893    where
10894        St: AsRef<str>,
10895    {
10896        self._scopes.insert(String::from(scope.as_ref()));
10897        self
10898    }
10899    /// Identifies the authorization scope(s) for the method you are building.
10900    ///
10901    /// See [`Self::add_scope()`] for details.
10902    pub fn add_scopes<I, St>(
10903        mut self,
10904        scopes: I,
10905    ) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C>
10906    where
10907        I: IntoIterator<Item = St>,
10908        St: AsRef<str>,
10909    {
10910        self._scopes
10911            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10912        self
10913    }
10914
10915    /// Removes all scopes, and no default scope will be used either.
10916    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10917    /// for details).
10918    pub fn clear_scopes(mut self) -> TopicStatProjectLocationTopicComputeTimeCursorCall<'a, C> {
10919        self._scopes.clear();
10920        self
10921    }
10922}