google_tpu1/
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 TPU 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_tpu1 as tpu1;
49/// use tpu1::api::Node;
50/// use tpu1::{Result, Error};
51/// # async fn dox() {
52/// use tpu1::{TPU, 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 = TPU::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 = Node::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.projects().locations_nodes_create(req, "parent")
99///              .node_id("At")
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct TPU<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for TPU<C> {}
131
132impl<'a, C> TPU<C> {
133    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> TPU<C> {
134        TPU {
135            client,
136            auth: Box::new(auth),
137            _user_agent: "google-api-rust-client/7.0.0".to_string(),
138            _base_url: "https://tpu.googleapis.com/".to_string(),
139            _root_url: "https://tpu.googleapis.com/".to_string(),
140        }
141    }
142
143    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
144        ProjectMethods { hub: self }
145    }
146
147    /// Set the user-agent header field to use in all requests to the server.
148    /// It defaults to `google-api-rust-client/7.0.0`.
149    ///
150    /// Returns the previously set user-agent.
151    pub fn user_agent(&mut self, agent_name: String) -> String {
152        std::mem::replace(&mut self._user_agent, agent_name)
153    }
154
155    /// Set the base url to use in all requests to the server.
156    /// It defaults to `https://tpu.googleapis.com/`.
157    ///
158    /// Returns the previously set base url.
159    pub fn base_url(&mut self, new_base_url: String) -> String {
160        std::mem::replace(&mut self._base_url, new_base_url)
161    }
162
163    /// Set the root url to use in all requests to the server.
164    /// It defaults to `https://tpu.googleapis.com/`.
165    ///
166    /// Returns the previously set root url.
167    pub fn root_url(&mut self, new_root_url: String) -> String {
168        std::mem::replace(&mut self._root_url, new_root_url)
169    }
170}
171
172// ############
173// SCHEMAS ###
174// ##########
175/// A accelerator type that a Node can be configured with.
176///
177/// # Activities
178///
179/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
180/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
181///
182/// * [locations accelerator types get projects](ProjectLocationAcceleratorTypeGetCall) (response)
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct AcceleratorType {
187    /// The resource name.
188    pub name: Option<String>,
189    /// the accelerator type.
190    #[serde(rename = "type")]
191    pub type_: Option<String>,
192}
193
194impl common::ResponseResult for AcceleratorType {}
195
196/// 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); }
197///
198/// # Activities
199///
200/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
201/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
202///
203/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
204/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct Empty {
209    _never_set: Option<bool>,
210}
211
212impl common::ResponseResult for Empty {}
213
214/// Response for ListAcceleratorTypes.
215///
216/// # Activities
217///
218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
220///
221/// * [locations accelerator types list projects](ProjectLocationAcceleratorTypeListCall) (response)
222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
223#[serde_with::serde_as]
224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
225pub struct ListAcceleratorTypesResponse {
226    /// The listed nodes.
227    #[serde(rename = "acceleratorTypes")]
228    pub accelerator_types: Option<Vec<AcceleratorType>>,
229    /// The next page token or empty if none.
230    #[serde(rename = "nextPageToken")]
231    pub next_page_token: Option<String>,
232    /// Locations that could not be reached.
233    pub unreachable: Option<Vec<String>>,
234}
235
236impl common::ResponseResult for ListAcceleratorTypesResponse {}
237
238/// The response message for Locations.ListLocations.
239///
240/// # Activities
241///
242/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
243/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
244///
245/// * [locations list projects](ProjectLocationListCall) (response)
246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
247#[serde_with::serde_as]
248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
249pub struct ListLocationsResponse {
250    /// A list of locations that matches the specified filter in the request.
251    pub locations: Option<Vec<Location>>,
252    /// The standard List next-page token.
253    #[serde(rename = "nextPageToken")]
254    pub next_page_token: Option<String>,
255}
256
257impl common::ResponseResult for ListLocationsResponse {}
258
259/// Response for ListNodes.
260///
261/// # Activities
262///
263/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
264/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
265///
266/// * [locations nodes list projects](ProjectLocationNodeListCall) (response)
267#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
268#[serde_with::serde_as]
269#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
270pub struct ListNodesResponse {
271    /// The next page token or empty if none.
272    #[serde(rename = "nextPageToken")]
273    pub next_page_token: Option<String>,
274    /// The listed nodes.
275    pub nodes: Option<Vec<Node>>,
276    /// Locations that could not be reached.
277    pub unreachable: Option<Vec<String>>,
278}
279
280impl common::ResponseResult for ListNodesResponse {}
281
282/// The response message for Operations.ListOperations.
283///
284/// # Activities
285///
286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
288///
289/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
291#[serde_with::serde_as]
292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
293pub struct ListOperationsResponse {
294    /// The standard List next-page token.
295    #[serde(rename = "nextPageToken")]
296    pub next_page_token: Option<String>,
297    /// A list of operations that matches the specified filter in the request.
298    pub operations: Option<Vec<Operation>>,
299    /// 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.
300    pub unreachable: Option<Vec<String>>,
301}
302
303impl common::ResponseResult for ListOperationsResponse {}
304
305/// Response for ListTensorFlowVersions.
306///
307/// # Activities
308///
309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
311///
312/// * [locations tensorflow versions list projects](ProjectLocationTensorflowVersionListCall) (response)
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct ListTensorFlowVersionsResponse {
317    /// The next page token or empty if none.
318    #[serde(rename = "nextPageToken")]
319    pub next_page_token: Option<String>,
320    /// The listed nodes.
321    #[serde(rename = "tensorflowVersions")]
322    pub tensorflow_versions: Option<Vec<TensorFlowVersion>>,
323    /// Locations that could not be reached.
324    pub unreachable: Option<Vec<String>>,
325}
326
327impl common::ResponseResult for ListTensorFlowVersionsResponse {}
328
329/// A resource that represents a Google Cloud location.
330///
331/// # Activities
332///
333/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
334/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
335///
336/// * [locations get projects](ProjectLocationGetCall) (response)
337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
338#[serde_with::serde_as]
339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
340pub struct Location {
341    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
342    #[serde(rename = "displayName")]
343    pub display_name: Option<String>,
344    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
345    pub labels: Option<HashMap<String, String>>,
346    /// The canonical id for this location. For example: `"us-east1"`.
347    #[serde(rename = "locationId")]
348    pub location_id: Option<String>,
349    /// Service-specific metadata. For example the available capacity at the given location.
350    pub metadata: Option<HashMap<String, serde_json::Value>>,
351    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
352    pub name: Option<String>,
353}
354
355impl common::ResponseResult for Location {}
356
357/// A network endpoint over which a TPU worker can be reached.
358///
359/// This type is not used in any activity, and only used as *part* of another schema.
360///
361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
362#[serde_with::serde_as]
363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
364pub struct NetworkEndpoint {
365    /// The IP address of this network endpoint.
366    #[serde(rename = "ipAddress")]
367    pub ip_address: Option<String>,
368    /// The port of this network endpoint.
369    pub port: Option<i32>,
370}
371
372impl common::Part for NetworkEndpoint {}
373
374/// A TPU instance.
375///
376/// # Activities
377///
378/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
379/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
380///
381/// * [locations nodes create projects](ProjectLocationNodeCreateCall) (request)
382/// * [locations nodes get projects](ProjectLocationNodeGetCall) (response)
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct Node {
387    /// Required. The type of hardware accelerators associated with this node.
388    #[serde(rename = "acceleratorType")]
389    pub accelerator_type: Option<String>,
390    /// Output only. The API version that created this Node.
391    #[serde(rename = "apiVersion")]
392    pub api_version: Option<String>,
393    /// The CIDR block that the TPU node will use when selecting an IP address. This CIDR block must be a /29 block; the Compute Engine networks API forbids a smaller block, and using a larger block would be wasteful (a node can only consume one IP address). Errors will occur if the CIDR block has already been used for a currently existing TPU node, the CIDR block conflicts with any subnetworks in the user's provided network, or the provided network is peered with another network that is using that CIDR block.
394    #[serde(rename = "cidrBlock")]
395    pub cidr_block: Option<String>,
396    /// Output only. The time when the node was created.
397    #[serde(rename = "createTime")]
398    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
399    /// The user-supplied description of the TPU. Maximum of 512 characters.
400    pub description: Option<String>,
401    /// The health status of the TPU node.
402    pub health: Option<String>,
403    /// Output only. If this field is populated, it contains a description of why the TPU Node is unhealthy.
404    #[serde(rename = "healthDescription")]
405    pub health_description: Option<String>,
406    /// Output only. DEPRECATED! Use network_endpoints instead. The network address for the TPU Node as visible to Compute Engine instances.
407    #[serde(rename = "ipAddress")]
408    pub ip_address: Option<String>,
409    /// Resource labels to represent user-provided metadata.
410    pub labels: Option<HashMap<String, String>>,
411    /// Output only. Immutable. The name of the TPU
412    pub name: Option<String>,
413    /// The name of a network they wish to peer the TPU node to. It must be a preexisting Compute Engine network inside of the project on which this API has been activated. If none is provided, "default" will be used.
414    pub network: Option<String>,
415    /// Output only. The network endpoints where TPU workers can be accessed and sent work. It is recommended that Tensorflow clients of the node reach out to the 0th entry in this map first.
416    #[serde(rename = "networkEndpoints")]
417    pub network_endpoints: Option<Vec<NetworkEndpoint>>,
418    /// Output only. DEPRECATED! Use network_endpoints instead. The network port for the TPU Node as visible to Compute Engine instances.
419    pub port: Option<String>,
420    /// The scheduling options for this node.
421    #[serde(rename = "schedulingConfig")]
422    pub scheduling_config: Option<SchedulingConfig>,
423    /// Output only. The service account used to run the tensor flow services within the node. To share resources, including Google Cloud Storage data, with the Tensorflow job running in the Node, this account must have permissions to that data.
424    #[serde(rename = "serviceAccount")]
425    pub service_account: Option<String>,
426    /// Output only. The current state for the TPU Node.
427    pub state: Option<String>,
428    /// Output only. The Symptoms that have occurred to the TPU Node.
429    pub symptoms: Option<Vec<Symptom>>,
430    /// Required. The version of Tensorflow running in the Node.
431    #[serde(rename = "tensorflowVersion")]
432    pub tensorflow_version: Option<String>,
433    /// Whether the VPC peering for the node is set up through Service Networking API. The VPC Peering should be set up before provisioning the node. If this field is set, cidr_block field should not be specified. If the network, that you want to peer the TPU Node to, is Shared VPC networks, the node must be created with this this field enabled.
434    #[serde(rename = "useServiceNetworking")]
435    pub use_service_networking: Option<bool>,
436}
437
438impl common::RequestValue for Node {}
439impl common::ResponseResult for Node {}
440
441/// This resource represents a long-running operation that is the result of a network API call.
442///
443/// # Activities
444///
445/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
446/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
447///
448/// * [locations nodes create projects](ProjectLocationNodeCreateCall) (response)
449/// * [locations nodes delete projects](ProjectLocationNodeDeleteCall) (response)
450/// * [locations nodes reimage projects](ProjectLocationNodeReimageCall) (response)
451/// * [locations nodes start projects](ProjectLocationNodeStartCall) (response)
452/// * [locations nodes stop projects](ProjectLocationNodeStopCall) (response)
453/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
455#[serde_with::serde_as]
456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
457pub struct Operation {
458    /// 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.
459    pub done: Option<bool>,
460    /// The error result of the operation in case of failure or cancellation.
461    pub error: Option<Status>,
462    /// 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.
463    pub metadata: Option<HashMap<String, serde_json::Value>>,
464    /// 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}`.
465    pub name: Option<String>,
466    /// 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`.
467    pub response: Option<HashMap<String, serde_json::Value>>,
468}
469
470impl common::ResponseResult for Operation {}
471
472/// Request for ReimageNode.
473///
474/// # Activities
475///
476/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
477/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
478///
479/// * [locations nodes reimage projects](ProjectLocationNodeReimageCall) (request)
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct ReimageNodeRequest {
484    /// The version for reimage to create.
485    #[serde(rename = "tensorflowVersion")]
486    pub tensorflow_version: Option<String>,
487}
488
489impl common::RequestValue for ReimageNodeRequest {}
490
491/// Sets the scheduling options for this node.
492///
493/// This type is not used in any activity, and only used as *part* of another schema.
494///
495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
496#[serde_with::serde_as]
497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
498pub struct SchedulingConfig {
499    /// Defines whether the node is preemptible.
500    pub preemptible: Option<bool>,
501    /// Whether the node is created under a reservation.
502    pub reserved: Option<bool>,
503}
504
505impl common::Part for SchedulingConfig {}
506
507/// Request for StartNode.
508///
509/// # Activities
510///
511/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
512/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
513///
514/// * [locations nodes start projects](ProjectLocationNodeStartCall) (request)
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct StartNodeRequest {
519    _never_set: Option<bool>,
520}
521
522impl common::RequestValue for StartNodeRequest {}
523
524/// 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).
525///
526/// This type is not used in any activity, and only used as *part* of another schema.
527///
528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
529#[serde_with::serde_as]
530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
531pub struct Status {
532    /// The status code, which should be an enum value of google.rpc.Code.
533    pub code: Option<i32>,
534    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
535    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
536    /// 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.
537    pub message: Option<String>,
538}
539
540impl common::Part for Status {}
541
542/// Request for StopNode.
543///
544/// # Activities
545///
546/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
547/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
548///
549/// * [locations nodes stop projects](ProjectLocationNodeStopCall) (request)
550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
551#[serde_with::serde_as]
552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
553pub struct StopNodeRequest {
554    _never_set: Option<bool>,
555}
556
557impl common::RequestValue for StopNodeRequest {}
558
559/// A Symptom instance.
560///
561/// This type is not used in any activity, and only used as *part* of another schema.
562///
563#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
564#[serde_with::serde_as]
565#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
566pub struct Symptom {
567    /// Timestamp when the Symptom is created.
568    #[serde(rename = "createTime")]
569    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
570    /// Detailed information of the current Symptom.
571    pub details: Option<String>,
572    /// Type of the Symptom.
573    #[serde(rename = "symptomType")]
574    pub symptom_type: Option<String>,
575    /// A string used to uniquely distinguish a worker within a TPU node.
576    #[serde(rename = "workerId")]
577    pub worker_id: Option<String>,
578}
579
580impl common::Part for Symptom {}
581
582/// A tensorflow version that a Node can be configured with.
583///
584/// # Activities
585///
586/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
587/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
588///
589/// * [locations tensorflow versions get projects](ProjectLocationTensorflowVersionGetCall) (response)
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct TensorFlowVersion {
594    /// The resource name.
595    pub name: Option<String>,
596    /// the tensorflow version.
597    pub version: Option<String>,
598}
599
600impl common::ResponseResult for TensorFlowVersion {}
601
602// ###################
603// MethodBuilders ###
604// #################
605
606/// A builder providing access to all methods supported on *project* resources.
607/// It is not used directly, but through the [`TPU`] hub.
608///
609/// # Example
610///
611/// Instantiate a resource builder
612///
613/// ```test_harness,no_run
614/// extern crate hyper;
615/// extern crate hyper_rustls;
616/// extern crate google_tpu1 as tpu1;
617///
618/// # async fn dox() {
619/// use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
620///
621/// let secret: yup_oauth2::ApplicationSecret = Default::default();
622/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
623///     .with_native_roots()
624///     .unwrap()
625///     .https_only()
626///     .enable_http2()
627///     .build();
628///
629/// let executor = hyper_util::rt::TokioExecutor::new();
630/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
631///     secret,
632///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
633///     yup_oauth2::client::CustomHyperClientBuilder::from(
634///         hyper_util::client::legacy::Client::builder(executor).build(connector),
635///     ),
636/// ).build().await.unwrap();
637///
638/// let client = hyper_util::client::legacy::Client::builder(
639///     hyper_util::rt::TokioExecutor::new()
640/// )
641/// .build(
642///     hyper_rustls::HttpsConnectorBuilder::new()
643///         .with_native_roots()
644///         .unwrap()
645///         .https_or_http()
646///         .enable_http2()
647///         .build()
648/// );
649/// let mut hub = TPU::new(client, auth);
650/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
651/// // like `locations_accelerator_types_get(...)`, `locations_accelerator_types_list(...)`, `locations_get(...)`, `locations_list(...)`, `locations_nodes_create(...)`, `locations_nodes_delete(...)`, `locations_nodes_get(...)`, `locations_nodes_list(...)`, `locations_nodes_reimage(...)`, `locations_nodes_start(...)`, `locations_nodes_stop(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_tensorflow_versions_get(...)` and `locations_tensorflow_versions_list(...)`
652/// // to build up your call.
653/// let rb = hub.projects();
654/// # }
655/// ```
656pub struct ProjectMethods<'a, C>
657where
658    C: 'a,
659{
660    hub: &'a TPU<C>,
661}
662
663impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
664
665impl<'a, C> ProjectMethods<'a, C> {
666    /// Create a builder to help you perform the following task:
667    ///
668    /// Gets AcceleratorType.
669    ///
670    /// # Arguments
671    ///
672    /// * `name` - Required. The resource name.
673    pub fn locations_accelerator_types_get(
674        &self,
675        name: &str,
676    ) -> ProjectLocationAcceleratorTypeGetCall<'a, C> {
677        ProjectLocationAcceleratorTypeGetCall {
678            hub: self.hub,
679            _name: name.to_string(),
680            _delegate: Default::default(),
681            _additional_params: Default::default(),
682            _scopes: Default::default(),
683        }
684    }
685
686    /// Create a builder to help you perform the following task:
687    ///
688    /// Lists accelerator types supported by this API.
689    ///
690    /// # Arguments
691    ///
692    /// * `parent` - Required. The parent resource name.
693    pub fn locations_accelerator_types_list(
694        &self,
695        parent: &str,
696    ) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
697        ProjectLocationAcceleratorTypeListCall {
698            hub: self.hub,
699            _parent: parent.to_string(),
700            _page_token: Default::default(),
701            _page_size: Default::default(),
702            _order_by: Default::default(),
703            _filter: Default::default(),
704            _delegate: Default::default(),
705            _additional_params: Default::default(),
706            _scopes: Default::default(),
707        }
708    }
709
710    /// Create a builder to help you perform the following task:
711    ///
712    /// Creates a node.
713    ///
714    /// # Arguments
715    ///
716    /// * `request` - No description provided.
717    /// * `parent` - Required. The parent resource name.
718    pub fn locations_nodes_create(
719        &self,
720        request: Node,
721        parent: &str,
722    ) -> ProjectLocationNodeCreateCall<'a, C> {
723        ProjectLocationNodeCreateCall {
724            hub: self.hub,
725            _request: request,
726            _parent: parent.to_string(),
727            _node_id: Default::default(),
728            _delegate: Default::default(),
729            _additional_params: Default::default(),
730            _scopes: Default::default(),
731        }
732    }
733
734    /// Create a builder to help you perform the following task:
735    ///
736    /// Deletes a node.
737    ///
738    /// # Arguments
739    ///
740    /// * `name` - Required. The resource name.
741    pub fn locations_nodes_delete(&self, name: &str) -> ProjectLocationNodeDeleteCall<'a, C> {
742        ProjectLocationNodeDeleteCall {
743            hub: self.hub,
744            _name: name.to_string(),
745            _delegate: Default::default(),
746            _additional_params: Default::default(),
747            _scopes: Default::default(),
748        }
749    }
750
751    /// Create a builder to help you perform the following task:
752    ///
753    /// Gets the details of a node.
754    ///
755    /// # Arguments
756    ///
757    /// * `name` - Required. The resource name.
758    pub fn locations_nodes_get(&self, name: &str) -> ProjectLocationNodeGetCall<'a, C> {
759        ProjectLocationNodeGetCall {
760            hub: self.hub,
761            _name: name.to_string(),
762            _delegate: Default::default(),
763            _additional_params: Default::default(),
764            _scopes: Default::default(),
765        }
766    }
767
768    /// Create a builder to help you perform the following task:
769    ///
770    /// Lists nodes.
771    ///
772    /// # Arguments
773    ///
774    /// * `parent` - Required. The parent resource name.
775    pub fn locations_nodes_list(&self, parent: &str) -> ProjectLocationNodeListCall<'a, C> {
776        ProjectLocationNodeListCall {
777            hub: self.hub,
778            _parent: parent.to_string(),
779            _page_token: Default::default(),
780            _page_size: Default::default(),
781            _delegate: Default::default(),
782            _additional_params: Default::default(),
783            _scopes: Default::default(),
784        }
785    }
786
787    /// Create a builder to help you perform the following task:
788    ///
789    /// Reimages a node's OS.
790    ///
791    /// # Arguments
792    ///
793    /// * `request` - No description provided.
794    /// * `name` - The resource name.
795    pub fn locations_nodes_reimage(
796        &self,
797        request: ReimageNodeRequest,
798        name: &str,
799    ) -> ProjectLocationNodeReimageCall<'a, C> {
800        ProjectLocationNodeReimageCall {
801            hub: self.hub,
802            _request: request,
803            _name: name.to_string(),
804            _delegate: Default::default(),
805            _additional_params: Default::default(),
806            _scopes: Default::default(),
807        }
808    }
809
810    /// Create a builder to help you perform the following task:
811    ///
812    /// Starts a node.
813    ///
814    /// # Arguments
815    ///
816    /// * `request` - No description provided.
817    /// * `name` - The resource name.
818    pub fn locations_nodes_start(
819        &self,
820        request: StartNodeRequest,
821        name: &str,
822    ) -> ProjectLocationNodeStartCall<'a, C> {
823        ProjectLocationNodeStartCall {
824            hub: self.hub,
825            _request: request,
826            _name: name.to_string(),
827            _delegate: Default::default(),
828            _additional_params: Default::default(),
829            _scopes: Default::default(),
830        }
831    }
832
833    /// Create a builder to help you perform the following task:
834    ///
835    /// Stops a node, this operation is only available with single TPU nodes.
836    ///
837    /// # Arguments
838    ///
839    /// * `request` - No description provided.
840    /// * `name` - The resource name.
841    pub fn locations_nodes_stop(
842        &self,
843        request: StopNodeRequest,
844        name: &str,
845    ) -> ProjectLocationNodeStopCall<'a, C> {
846        ProjectLocationNodeStopCall {
847            hub: self.hub,
848            _request: request,
849            _name: name.to_string(),
850            _delegate: Default::default(),
851            _additional_params: Default::default(),
852            _scopes: Default::default(),
853        }
854    }
855
856    /// Create a builder to help you perform the following task:
857    ///
858    /// 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`.
859    ///
860    /// # Arguments
861    ///
862    /// * `name` - The name of the operation resource to be cancelled.
863    pub fn locations_operations_cancel(
864        &self,
865        name: &str,
866    ) -> ProjectLocationOperationCancelCall<'a, C> {
867        ProjectLocationOperationCancelCall {
868            hub: self.hub,
869            _name: name.to_string(),
870            _delegate: Default::default(),
871            _additional_params: Default::default(),
872            _scopes: Default::default(),
873        }
874    }
875
876    /// Create a builder to help you perform the following task:
877    ///
878    /// 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`.
879    ///
880    /// # Arguments
881    ///
882    /// * `name` - The name of the operation resource to be deleted.
883    pub fn locations_operations_delete(
884        &self,
885        name: &str,
886    ) -> ProjectLocationOperationDeleteCall<'a, C> {
887        ProjectLocationOperationDeleteCall {
888            hub: self.hub,
889            _name: name.to_string(),
890            _delegate: Default::default(),
891            _additional_params: Default::default(),
892            _scopes: Default::default(),
893        }
894    }
895
896    /// Create a builder to help you perform the following task:
897    ///
898    /// 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.
899    ///
900    /// # Arguments
901    ///
902    /// * `name` - The name of the operation resource.
903    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
904        ProjectLocationOperationGetCall {
905            hub: self.hub,
906            _name: name.to_string(),
907            _delegate: Default::default(),
908            _additional_params: Default::default(),
909            _scopes: Default::default(),
910        }
911    }
912
913    /// Create a builder to help you perform the following task:
914    ///
915    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
916    ///
917    /// # Arguments
918    ///
919    /// * `name` - The name of the operation's parent resource.
920    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
921        ProjectLocationOperationListCall {
922            hub: self.hub,
923            _name: name.to_string(),
924            _return_partial_success: Default::default(),
925            _page_token: Default::default(),
926            _page_size: Default::default(),
927            _filter: Default::default(),
928            _delegate: Default::default(),
929            _additional_params: Default::default(),
930            _scopes: Default::default(),
931        }
932    }
933
934    /// Create a builder to help you perform the following task:
935    ///
936    /// Gets TensorFlow Version.
937    ///
938    /// # Arguments
939    ///
940    /// * `name` - Required. The resource name.
941    pub fn locations_tensorflow_versions_get(
942        &self,
943        name: &str,
944    ) -> ProjectLocationTensorflowVersionGetCall<'a, C> {
945        ProjectLocationTensorflowVersionGetCall {
946            hub: self.hub,
947            _name: name.to_string(),
948            _delegate: Default::default(),
949            _additional_params: Default::default(),
950            _scopes: Default::default(),
951        }
952    }
953
954    /// Create a builder to help you perform the following task:
955    ///
956    /// List TensorFlow versions supported by this API.
957    ///
958    /// # Arguments
959    ///
960    /// * `parent` - Required. The parent resource name.
961    pub fn locations_tensorflow_versions_list(
962        &self,
963        parent: &str,
964    ) -> ProjectLocationTensorflowVersionListCall<'a, C> {
965        ProjectLocationTensorflowVersionListCall {
966            hub: self.hub,
967            _parent: parent.to_string(),
968            _page_token: Default::default(),
969            _page_size: Default::default(),
970            _order_by: Default::default(),
971            _filter: Default::default(),
972            _delegate: Default::default(),
973            _additional_params: Default::default(),
974            _scopes: Default::default(),
975        }
976    }
977
978    /// Create a builder to help you perform the following task:
979    ///
980    /// Gets information about a location.
981    ///
982    /// # Arguments
983    ///
984    /// * `name` - Resource name for the location.
985    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
986        ProjectLocationGetCall {
987            hub: self.hub,
988            _name: name.to_string(),
989            _delegate: Default::default(),
990            _additional_params: Default::default(),
991            _scopes: Default::default(),
992        }
993    }
994
995    /// Create a builder to help you perform the following task:
996    ///
997    /// Lists information about the supported locations for this service.
998    ///
999    /// # Arguments
1000    ///
1001    /// * `name` - The resource that owns the locations collection, if applicable.
1002    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1003        ProjectLocationListCall {
1004            hub: self.hub,
1005            _name: name.to_string(),
1006            _page_token: Default::default(),
1007            _page_size: Default::default(),
1008            _filter: Default::default(),
1009            _extra_location_types: Default::default(),
1010            _delegate: Default::default(),
1011            _additional_params: Default::default(),
1012            _scopes: Default::default(),
1013        }
1014    }
1015}
1016
1017// ###################
1018// CallBuilders   ###
1019// #################
1020
1021/// Gets AcceleratorType.
1022///
1023/// A builder for the *locations.acceleratorTypes.get* method supported by a *project* resource.
1024/// It is not used directly, but through a [`ProjectMethods`] instance.
1025///
1026/// # Example
1027///
1028/// Instantiate a resource method builder
1029///
1030/// ```test_harness,no_run
1031/// # extern crate hyper;
1032/// # extern crate hyper_rustls;
1033/// # extern crate google_tpu1 as tpu1;
1034/// # async fn dox() {
1035/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1036///
1037/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1038/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1039/// #     .with_native_roots()
1040/// #     .unwrap()
1041/// #     .https_only()
1042/// #     .enable_http2()
1043/// #     .build();
1044///
1045/// # let executor = hyper_util::rt::TokioExecutor::new();
1046/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1047/// #     secret,
1048/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1049/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1050/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1051/// #     ),
1052/// # ).build().await.unwrap();
1053///
1054/// # let client = hyper_util::client::legacy::Client::builder(
1055/// #     hyper_util::rt::TokioExecutor::new()
1056/// # )
1057/// # .build(
1058/// #     hyper_rustls::HttpsConnectorBuilder::new()
1059/// #         .with_native_roots()
1060/// #         .unwrap()
1061/// #         .https_or_http()
1062/// #         .enable_http2()
1063/// #         .build()
1064/// # );
1065/// # let mut hub = TPU::new(client, auth);
1066/// // You can configure optional parameters by calling the respective setters at will, and
1067/// // execute the final call using `doit()`.
1068/// // Values shown here are possibly random and not representative !
1069/// let result = hub.projects().locations_accelerator_types_get("name")
1070///              .doit().await;
1071/// # }
1072/// ```
1073pub struct ProjectLocationAcceleratorTypeGetCall<'a, C>
1074where
1075    C: 'a,
1076{
1077    hub: &'a TPU<C>,
1078    _name: String,
1079    _delegate: Option<&'a mut dyn common::Delegate>,
1080    _additional_params: HashMap<String, String>,
1081    _scopes: BTreeSet<String>,
1082}
1083
1084impl<'a, C> common::CallBuilder for ProjectLocationAcceleratorTypeGetCall<'a, C> {}
1085
1086impl<'a, C> ProjectLocationAcceleratorTypeGetCall<'a, C>
1087where
1088    C: common::Connector,
1089{
1090    /// Perform the operation you have build so far.
1091    pub async fn doit(mut self) -> common::Result<(common::Response, AcceleratorType)> {
1092        use std::borrow::Cow;
1093        use std::io::{Read, Seek};
1094
1095        use common::{url::Params, ToParts};
1096        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1097
1098        let mut dd = common::DefaultDelegate;
1099        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1100        dlg.begin(common::MethodInfo {
1101            id: "tpu.projects.locations.acceleratorTypes.get",
1102            http_method: hyper::Method::GET,
1103        });
1104
1105        for &field in ["alt", "name"].iter() {
1106            if self._additional_params.contains_key(field) {
1107                dlg.finished(false);
1108                return Err(common::Error::FieldClash(field));
1109            }
1110        }
1111
1112        let mut params = Params::with_capacity(3 + self._additional_params.len());
1113        params.push("name", self._name);
1114
1115        params.extend(self._additional_params.iter());
1116
1117        params.push("alt", "json");
1118        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1119        if self._scopes.is_empty() {
1120            self._scopes
1121                .insert(Scope::CloudPlatform.as_ref().to_string());
1122        }
1123
1124        #[allow(clippy::single_element_loop)]
1125        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1126            url = params.uri_replacement(url, param_name, find_this, true);
1127        }
1128        {
1129            let to_remove = ["name"];
1130            params.remove_params(&to_remove);
1131        }
1132
1133        let url = params.parse_with_url(&url);
1134
1135        loop {
1136            let token = match self
1137                .hub
1138                .auth
1139                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1140                .await
1141            {
1142                Ok(token) => token,
1143                Err(e) => match dlg.token(e) {
1144                    Ok(token) => token,
1145                    Err(e) => {
1146                        dlg.finished(false);
1147                        return Err(common::Error::MissingToken(e));
1148                    }
1149                },
1150            };
1151            let mut req_result = {
1152                let client = &self.hub.client;
1153                dlg.pre_request();
1154                let mut req_builder = hyper::Request::builder()
1155                    .method(hyper::Method::GET)
1156                    .uri(url.as_str())
1157                    .header(USER_AGENT, self.hub._user_agent.clone());
1158
1159                if let Some(token) = token.as_ref() {
1160                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1161                }
1162
1163                let request = req_builder
1164                    .header(CONTENT_LENGTH, 0_u64)
1165                    .body(common::to_body::<String>(None));
1166
1167                client.request(request.unwrap()).await
1168            };
1169
1170            match req_result {
1171                Err(err) => {
1172                    if let common::Retry::After(d) = dlg.http_error(&err) {
1173                        sleep(d).await;
1174                        continue;
1175                    }
1176                    dlg.finished(false);
1177                    return Err(common::Error::HttpError(err));
1178                }
1179                Ok(res) => {
1180                    let (mut parts, body) = res.into_parts();
1181                    let mut body = common::Body::new(body);
1182                    if !parts.status.is_success() {
1183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1184                        let error = serde_json::from_str(&common::to_string(&bytes));
1185                        let response = common::to_response(parts, bytes.into());
1186
1187                        if let common::Retry::After(d) =
1188                            dlg.http_failure(&response, error.as_ref().ok())
1189                        {
1190                            sleep(d).await;
1191                            continue;
1192                        }
1193
1194                        dlg.finished(false);
1195
1196                        return Err(match error {
1197                            Ok(value) => common::Error::BadRequest(value),
1198                            _ => common::Error::Failure(response),
1199                        });
1200                    }
1201                    let response = {
1202                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1203                        let encoded = common::to_string(&bytes);
1204                        match serde_json::from_str(&encoded) {
1205                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1206                            Err(error) => {
1207                                dlg.response_json_decode_error(&encoded, &error);
1208                                return Err(common::Error::JsonDecodeError(
1209                                    encoded.to_string(),
1210                                    error,
1211                                ));
1212                            }
1213                        }
1214                    };
1215
1216                    dlg.finished(true);
1217                    return Ok(response);
1218                }
1219            }
1220        }
1221    }
1222
1223    /// Required. The resource name.
1224    ///
1225    /// Sets the *name* path property to the given value.
1226    ///
1227    /// Even though the property as already been set when instantiating this call,
1228    /// we provide this method for API completeness.
1229    pub fn name(mut self, new_value: &str) -> ProjectLocationAcceleratorTypeGetCall<'a, C> {
1230        self._name = new_value.to_string();
1231        self
1232    }
1233    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1234    /// while executing the actual API request.
1235    ///
1236    /// ````text
1237    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1238    /// ````
1239    ///
1240    /// Sets the *delegate* property to the given value.
1241    pub fn delegate(
1242        mut self,
1243        new_value: &'a mut dyn common::Delegate,
1244    ) -> ProjectLocationAcceleratorTypeGetCall<'a, C> {
1245        self._delegate = Some(new_value);
1246        self
1247    }
1248
1249    /// Set any additional parameter of the query string used in the request.
1250    /// It should be used to set parameters which are not yet available through their own
1251    /// setters.
1252    ///
1253    /// Please note that this method must not be used to set any of the known parameters
1254    /// which have their own setter method. If done anyway, the request will fail.
1255    ///
1256    /// # Additional Parameters
1257    ///
1258    /// * *$.xgafv* (query-string) - V1 error format.
1259    /// * *access_token* (query-string) - OAuth access token.
1260    /// * *alt* (query-string) - Data format for response.
1261    /// * *callback* (query-string) - JSONP
1262    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1263    /// * *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.
1264    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1265    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1266    /// * *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.
1267    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1268    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1269    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAcceleratorTypeGetCall<'a, C>
1270    where
1271        T: AsRef<str>,
1272    {
1273        self._additional_params
1274            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1275        self
1276    }
1277
1278    /// Identifies the authorization scope for the method you are building.
1279    ///
1280    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1281    /// [`Scope::CloudPlatform`].
1282    ///
1283    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1284    /// tokens for more than one scope.
1285    ///
1286    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1287    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1288    /// sufficient, a read-write scope will do as well.
1289    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAcceleratorTypeGetCall<'a, C>
1290    where
1291        St: AsRef<str>,
1292    {
1293        self._scopes.insert(String::from(scope.as_ref()));
1294        self
1295    }
1296    /// Identifies the authorization scope(s) for the method you are building.
1297    ///
1298    /// See [`Self::add_scope()`] for details.
1299    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAcceleratorTypeGetCall<'a, C>
1300    where
1301        I: IntoIterator<Item = St>,
1302        St: AsRef<str>,
1303    {
1304        self._scopes
1305            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1306        self
1307    }
1308
1309    /// Removes all scopes, and no default scope will be used either.
1310    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1311    /// for details).
1312    pub fn clear_scopes(mut self) -> ProjectLocationAcceleratorTypeGetCall<'a, C> {
1313        self._scopes.clear();
1314        self
1315    }
1316}
1317
1318/// Lists accelerator types supported by this API.
1319///
1320/// A builder for the *locations.acceleratorTypes.list* method supported by a *project* resource.
1321/// It is not used directly, but through a [`ProjectMethods`] instance.
1322///
1323/// # Example
1324///
1325/// Instantiate a resource method builder
1326///
1327/// ```test_harness,no_run
1328/// # extern crate hyper;
1329/// # extern crate hyper_rustls;
1330/// # extern crate google_tpu1 as tpu1;
1331/// # async fn dox() {
1332/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1333///
1334/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1335/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1336/// #     .with_native_roots()
1337/// #     .unwrap()
1338/// #     .https_only()
1339/// #     .enable_http2()
1340/// #     .build();
1341///
1342/// # let executor = hyper_util::rt::TokioExecutor::new();
1343/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1344/// #     secret,
1345/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1346/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1347/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1348/// #     ),
1349/// # ).build().await.unwrap();
1350///
1351/// # let client = hyper_util::client::legacy::Client::builder(
1352/// #     hyper_util::rt::TokioExecutor::new()
1353/// # )
1354/// # .build(
1355/// #     hyper_rustls::HttpsConnectorBuilder::new()
1356/// #         .with_native_roots()
1357/// #         .unwrap()
1358/// #         .https_or_http()
1359/// #         .enable_http2()
1360/// #         .build()
1361/// # );
1362/// # let mut hub = TPU::new(client, auth);
1363/// // You can configure optional parameters by calling the respective setters at will, and
1364/// // execute the final call using `doit()`.
1365/// // Values shown here are possibly random and not representative !
1366/// let result = hub.projects().locations_accelerator_types_list("parent")
1367///              .page_token("amet.")
1368///              .page_size(-59)
1369///              .order_by("amet.")
1370///              .filter("duo")
1371///              .doit().await;
1372/// # }
1373/// ```
1374pub struct ProjectLocationAcceleratorTypeListCall<'a, C>
1375where
1376    C: 'a,
1377{
1378    hub: &'a TPU<C>,
1379    _parent: String,
1380    _page_token: Option<String>,
1381    _page_size: Option<i32>,
1382    _order_by: Option<String>,
1383    _filter: Option<String>,
1384    _delegate: Option<&'a mut dyn common::Delegate>,
1385    _additional_params: HashMap<String, String>,
1386    _scopes: BTreeSet<String>,
1387}
1388
1389impl<'a, C> common::CallBuilder for ProjectLocationAcceleratorTypeListCall<'a, C> {}
1390
1391impl<'a, C> ProjectLocationAcceleratorTypeListCall<'a, C>
1392where
1393    C: common::Connector,
1394{
1395    /// Perform the operation you have build so far.
1396    pub async fn doit(
1397        mut self,
1398    ) -> common::Result<(common::Response, ListAcceleratorTypesResponse)> {
1399        use std::borrow::Cow;
1400        use std::io::{Read, Seek};
1401
1402        use common::{url::Params, ToParts};
1403        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1404
1405        let mut dd = common::DefaultDelegate;
1406        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1407        dlg.begin(common::MethodInfo {
1408            id: "tpu.projects.locations.acceleratorTypes.list",
1409            http_method: hyper::Method::GET,
1410        });
1411
1412        for &field in [
1413            "alt",
1414            "parent",
1415            "pageToken",
1416            "pageSize",
1417            "orderBy",
1418            "filter",
1419        ]
1420        .iter()
1421        {
1422            if self._additional_params.contains_key(field) {
1423                dlg.finished(false);
1424                return Err(common::Error::FieldClash(field));
1425            }
1426        }
1427
1428        let mut params = Params::with_capacity(7 + self._additional_params.len());
1429        params.push("parent", self._parent);
1430        if let Some(value) = self._page_token.as_ref() {
1431            params.push("pageToken", value);
1432        }
1433        if let Some(value) = self._page_size.as_ref() {
1434            params.push("pageSize", value.to_string());
1435        }
1436        if let Some(value) = self._order_by.as_ref() {
1437            params.push("orderBy", value);
1438        }
1439        if let Some(value) = self._filter.as_ref() {
1440            params.push("filter", value);
1441        }
1442
1443        params.extend(self._additional_params.iter());
1444
1445        params.push("alt", "json");
1446        let mut url = self.hub._base_url.clone() + "v1/{+parent}/acceleratorTypes";
1447        if self._scopes.is_empty() {
1448            self._scopes
1449                .insert(Scope::CloudPlatform.as_ref().to_string());
1450        }
1451
1452        #[allow(clippy::single_element_loop)]
1453        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1454            url = params.uri_replacement(url, param_name, find_this, true);
1455        }
1456        {
1457            let to_remove = ["parent"];
1458            params.remove_params(&to_remove);
1459        }
1460
1461        let url = params.parse_with_url(&url);
1462
1463        loop {
1464            let token = match self
1465                .hub
1466                .auth
1467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1468                .await
1469            {
1470                Ok(token) => token,
1471                Err(e) => match dlg.token(e) {
1472                    Ok(token) => token,
1473                    Err(e) => {
1474                        dlg.finished(false);
1475                        return Err(common::Error::MissingToken(e));
1476                    }
1477                },
1478            };
1479            let mut req_result = {
1480                let client = &self.hub.client;
1481                dlg.pre_request();
1482                let mut req_builder = hyper::Request::builder()
1483                    .method(hyper::Method::GET)
1484                    .uri(url.as_str())
1485                    .header(USER_AGENT, self.hub._user_agent.clone());
1486
1487                if let Some(token) = token.as_ref() {
1488                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1489                }
1490
1491                let request = req_builder
1492                    .header(CONTENT_LENGTH, 0_u64)
1493                    .body(common::to_body::<String>(None));
1494
1495                client.request(request.unwrap()).await
1496            };
1497
1498            match req_result {
1499                Err(err) => {
1500                    if let common::Retry::After(d) = dlg.http_error(&err) {
1501                        sleep(d).await;
1502                        continue;
1503                    }
1504                    dlg.finished(false);
1505                    return Err(common::Error::HttpError(err));
1506                }
1507                Ok(res) => {
1508                    let (mut parts, body) = res.into_parts();
1509                    let mut body = common::Body::new(body);
1510                    if !parts.status.is_success() {
1511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1512                        let error = serde_json::from_str(&common::to_string(&bytes));
1513                        let response = common::to_response(parts, bytes.into());
1514
1515                        if let common::Retry::After(d) =
1516                            dlg.http_failure(&response, error.as_ref().ok())
1517                        {
1518                            sleep(d).await;
1519                            continue;
1520                        }
1521
1522                        dlg.finished(false);
1523
1524                        return Err(match error {
1525                            Ok(value) => common::Error::BadRequest(value),
1526                            _ => common::Error::Failure(response),
1527                        });
1528                    }
1529                    let response = {
1530                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1531                        let encoded = common::to_string(&bytes);
1532                        match serde_json::from_str(&encoded) {
1533                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1534                            Err(error) => {
1535                                dlg.response_json_decode_error(&encoded, &error);
1536                                return Err(common::Error::JsonDecodeError(
1537                                    encoded.to_string(),
1538                                    error,
1539                                ));
1540                            }
1541                        }
1542                    };
1543
1544                    dlg.finished(true);
1545                    return Ok(response);
1546                }
1547            }
1548        }
1549    }
1550
1551    /// Required. The parent resource name.
1552    ///
1553    /// Sets the *parent* path property to the given value.
1554    ///
1555    /// Even though the property as already been set when instantiating this call,
1556    /// we provide this method for API completeness.
1557    pub fn parent(mut self, new_value: &str) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1558        self._parent = new_value.to_string();
1559        self
1560    }
1561    /// The next_page_token value returned from a previous List request, if any.
1562    ///
1563    /// Sets the *page token* query property to the given value.
1564    pub fn page_token(mut self, new_value: &str) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1565        self._page_token = Some(new_value.to_string());
1566        self
1567    }
1568    /// The maximum number of items to return.
1569    ///
1570    /// Sets the *page size* query property to the given value.
1571    pub fn page_size(mut self, new_value: i32) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1572        self._page_size = Some(new_value);
1573        self
1574    }
1575    /// Sort results.
1576    ///
1577    /// Sets the *order by* query property to the given value.
1578    pub fn order_by(mut self, new_value: &str) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1579        self._order_by = Some(new_value.to_string());
1580        self
1581    }
1582    /// List filter.
1583    ///
1584    /// Sets the *filter* query property to the given value.
1585    pub fn filter(mut self, new_value: &str) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1586        self._filter = Some(new_value.to_string());
1587        self
1588    }
1589    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1590    /// while executing the actual API request.
1591    ///
1592    /// ````text
1593    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1594    /// ````
1595    ///
1596    /// Sets the *delegate* property to the given value.
1597    pub fn delegate(
1598        mut self,
1599        new_value: &'a mut dyn common::Delegate,
1600    ) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1601        self._delegate = Some(new_value);
1602        self
1603    }
1604
1605    /// Set any additional parameter of the query string used in the request.
1606    /// It should be used to set parameters which are not yet available through their own
1607    /// setters.
1608    ///
1609    /// Please note that this method must not be used to set any of the known parameters
1610    /// which have their own setter method. If done anyway, the request will fail.
1611    ///
1612    /// # Additional Parameters
1613    ///
1614    /// * *$.xgafv* (query-string) - V1 error format.
1615    /// * *access_token* (query-string) - OAuth access token.
1616    /// * *alt* (query-string) - Data format for response.
1617    /// * *callback* (query-string) - JSONP
1618    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1619    /// * *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.
1620    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1621    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1622    /// * *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.
1623    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1624    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1625    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAcceleratorTypeListCall<'a, C>
1626    where
1627        T: AsRef<str>,
1628    {
1629        self._additional_params
1630            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1631        self
1632    }
1633
1634    /// Identifies the authorization scope for the method you are building.
1635    ///
1636    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1637    /// [`Scope::CloudPlatform`].
1638    ///
1639    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1640    /// tokens for more than one scope.
1641    ///
1642    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1643    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1644    /// sufficient, a read-write scope will do as well.
1645    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAcceleratorTypeListCall<'a, C>
1646    where
1647        St: AsRef<str>,
1648    {
1649        self._scopes.insert(String::from(scope.as_ref()));
1650        self
1651    }
1652    /// Identifies the authorization scope(s) for the method you are building.
1653    ///
1654    /// See [`Self::add_scope()`] for details.
1655    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAcceleratorTypeListCall<'a, C>
1656    where
1657        I: IntoIterator<Item = St>,
1658        St: AsRef<str>,
1659    {
1660        self._scopes
1661            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1662        self
1663    }
1664
1665    /// Removes all scopes, and no default scope will be used either.
1666    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1667    /// for details).
1668    pub fn clear_scopes(mut self) -> ProjectLocationAcceleratorTypeListCall<'a, C> {
1669        self._scopes.clear();
1670        self
1671    }
1672}
1673
1674/// Creates a node.
1675///
1676/// A builder for the *locations.nodes.create* method supported by a *project* resource.
1677/// It is not used directly, but through a [`ProjectMethods`] instance.
1678///
1679/// # Example
1680///
1681/// Instantiate a resource method builder
1682///
1683/// ```test_harness,no_run
1684/// # extern crate hyper;
1685/// # extern crate hyper_rustls;
1686/// # extern crate google_tpu1 as tpu1;
1687/// use tpu1::api::Node;
1688/// # async fn dox() {
1689/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1690///
1691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1693/// #     .with_native_roots()
1694/// #     .unwrap()
1695/// #     .https_only()
1696/// #     .enable_http2()
1697/// #     .build();
1698///
1699/// # let executor = hyper_util::rt::TokioExecutor::new();
1700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1701/// #     secret,
1702/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1703/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1704/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1705/// #     ),
1706/// # ).build().await.unwrap();
1707///
1708/// # let client = hyper_util::client::legacy::Client::builder(
1709/// #     hyper_util::rt::TokioExecutor::new()
1710/// # )
1711/// # .build(
1712/// #     hyper_rustls::HttpsConnectorBuilder::new()
1713/// #         .with_native_roots()
1714/// #         .unwrap()
1715/// #         .https_or_http()
1716/// #         .enable_http2()
1717/// #         .build()
1718/// # );
1719/// # let mut hub = TPU::new(client, auth);
1720/// // As the method needs a request, you would usually fill it with the desired information
1721/// // into the respective structure. Some of the parts shown here might not be applicable !
1722/// // Values shown here are possibly random and not representative !
1723/// let mut req = Node::default();
1724///
1725/// // You can configure optional parameters by calling the respective setters at will, and
1726/// // execute the final call using `doit()`.
1727/// // Values shown here are possibly random and not representative !
1728/// let result = hub.projects().locations_nodes_create(req, "parent")
1729///              .node_id("gubergren")
1730///              .doit().await;
1731/// # }
1732/// ```
1733pub struct ProjectLocationNodeCreateCall<'a, C>
1734where
1735    C: 'a,
1736{
1737    hub: &'a TPU<C>,
1738    _request: Node,
1739    _parent: String,
1740    _node_id: Option<String>,
1741    _delegate: Option<&'a mut dyn common::Delegate>,
1742    _additional_params: HashMap<String, String>,
1743    _scopes: BTreeSet<String>,
1744}
1745
1746impl<'a, C> common::CallBuilder for ProjectLocationNodeCreateCall<'a, C> {}
1747
1748impl<'a, C> ProjectLocationNodeCreateCall<'a, C>
1749where
1750    C: common::Connector,
1751{
1752    /// Perform the operation you have build so far.
1753    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1754        use std::borrow::Cow;
1755        use std::io::{Read, Seek};
1756
1757        use common::{url::Params, ToParts};
1758        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1759
1760        let mut dd = common::DefaultDelegate;
1761        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1762        dlg.begin(common::MethodInfo {
1763            id: "tpu.projects.locations.nodes.create",
1764            http_method: hyper::Method::POST,
1765        });
1766
1767        for &field in ["alt", "parent", "nodeId"].iter() {
1768            if self._additional_params.contains_key(field) {
1769                dlg.finished(false);
1770                return Err(common::Error::FieldClash(field));
1771            }
1772        }
1773
1774        let mut params = Params::with_capacity(5 + self._additional_params.len());
1775        params.push("parent", self._parent);
1776        if let Some(value) = self._node_id.as_ref() {
1777            params.push("nodeId", value);
1778        }
1779
1780        params.extend(self._additional_params.iter());
1781
1782        params.push("alt", "json");
1783        let mut url = self.hub._base_url.clone() + "v1/{+parent}/nodes";
1784        if self._scopes.is_empty() {
1785            self._scopes
1786                .insert(Scope::CloudPlatform.as_ref().to_string());
1787        }
1788
1789        #[allow(clippy::single_element_loop)]
1790        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1791            url = params.uri_replacement(url, param_name, find_this, true);
1792        }
1793        {
1794            let to_remove = ["parent"];
1795            params.remove_params(&to_remove);
1796        }
1797
1798        let url = params.parse_with_url(&url);
1799
1800        let mut json_mime_type = mime::APPLICATION_JSON;
1801        let mut request_value_reader = {
1802            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1803            common::remove_json_null_values(&mut value);
1804            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1805            serde_json::to_writer(&mut dst, &value).unwrap();
1806            dst
1807        };
1808        let request_size = request_value_reader
1809            .seek(std::io::SeekFrom::End(0))
1810            .unwrap();
1811        request_value_reader
1812            .seek(std::io::SeekFrom::Start(0))
1813            .unwrap();
1814
1815        loop {
1816            let token = match self
1817                .hub
1818                .auth
1819                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1820                .await
1821            {
1822                Ok(token) => token,
1823                Err(e) => match dlg.token(e) {
1824                    Ok(token) => token,
1825                    Err(e) => {
1826                        dlg.finished(false);
1827                        return Err(common::Error::MissingToken(e));
1828                    }
1829                },
1830            };
1831            request_value_reader
1832                .seek(std::io::SeekFrom::Start(0))
1833                .unwrap();
1834            let mut req_result = {
1835                let client = &self.hub.client;
1836                dlg.pre_request();
1837                let mut req_builder = hyper::Request::builder()
1838                    .method(hyper::Method::POST)
1839                    .uri(url.as_str())
1840                    .header(USER_AGENT, self.hub._user_agent.clone());
1841
1842                if let Some(token) = token.as_ref() {
1843                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1844                }
1845
1846                let request = req_builder
1847                    .header(CONTENT_TYPE, json_mime_type.to_string())
1848                    .header(CONTENT_LENGTH, request_size as u64)
1849                    .body(common::to_body(
1850                        request_value_reader.get_ref().clone().into(),
1851                    ));
1852
1853                client.request(request.unwrap()).await
1854            };
1855
1856            match req_result {
1857                Err(err) => {
1858                    if let common::Retry::After(d) = dlg.http_error(&err) {
1859                        sleep(d).await;
1860                        continue;
1861                    }
1862                    dlg.finished(false);
1863                    return Err(common::Error::HttpError(err));
1864                }
1865                Ok(res) => {
1866                    let (mut parts, body) = res.into_parts();
1867                    let mut body = common::Body::new(body);
1868                    if !parts.status.is_success() {
1869                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1870                        let error = serde_json::from_str(&common::to_string(&bytes));
1871                        let response = common::to_response(parts, bytes.into());
1872
1873                        if let common::Retry::After(d) =
1874                            dlg.http_failure(&response, error.as_ref().ok())
1875                        {
1876                            sleep(d).await;
1877                            continue;
1878                        }
1879
1880                        dlg.finished(false);
1881
1882                        return Err(match error {
1883                            Ok(value) => common::Error::BadRequest(value),
1884                            _ => common::Error::Failure(response),
1885                        });
1886                    }
1887                    let response = {
1888                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1889                        let encoded = common::to_string(&bytes);
1890                        match serde_json::from_str(&encoded) {
1891                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1892                            Err(error) => {
1893                                dlg.response_json_decode_error(&encoded, &error);
1894                                return Err(common::Error::JsonDecodeError(
1895                                    encoded.to_string(),
1896                                    error,
1897                                ));
1898                            }
1899                        }
1900                    };
1901
1902                    dlg.finished(true);
1903                    return Ok(response);
1904                }
1905            }
1906        }
1907    }
1908
1909    ///
1910    /// Sets the *request* property to the given value.
1911    ///
1912    /// Even though the property as already been set when instantiating this call,
1913    /// we provide this method for API completeness.
1914    pub fn request(mut self, new_value: Node) -> ProjectLocationNodeCreateCall<'a, C> {
1915        self._request = new_value;
1916        self
1917    }
1918    /// Required. The parent resource name.
1919    ///
1920    /// Sets the *parent* path property to the given value.
1921    ///
1922    /// Even though the property as already been set when instantiating this call,
1923    /// we provide this method for API completeness.
1924    pub fn parent(mut self, new_value: &str) -> ProjectLocationNodeCreateCall<'a, C> {
1925        self._parent = new_value.to_string();
1926        self
1927    }
1928    /// The unqualified resource name.
1929    ///
1930    /// Sets the *node id* query property to the given value.
1931    pub fn node_id(mut self, new_value: &str) -> ProjectLocationNodeCreateCall<'a, C> {
1932        self._node_id = Some(new_value.to_string());
1933        self
1934    }
1935    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1936    /// while executing the actual API request.
1937    ///
1938    /// ````text
1939    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1940    /// ````
1941    ///
1942    /// Sets the *delegate* property to the given value.
1943    pub fn delegate(
1944        mut self,
1945        new_value: &'a mut dyn common::Delegate,
1946    ) -> ProjectLocationNodeCreateCall<'a, C> {
1947        self._delegate = Some(new_value);
1948        self
1949    }
1950
1951    /// Set any additional parameter of the query string used in the request.
1952    /// It should be used to set parameters which are not yet available through their own
1953    /// setters.
1954    ///
1955    /// Please note that this method must not be used to set any of the known parameters
1956    /// which have their own setter method. If done anyway, the request will fail.
1957    ///
1958    /// # Additional Parameters
1959    ///
1960    /// * *$.xgafv* (query-string) - V1 error format.
1961    /// * *access_token* (query-string) - OAuth access token.
1962    /// * *alt* (query-string) - Data format for response.
1963    /// * *callback* (query-string) - JSONP
1964    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1965    /// * *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.
1966    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1967    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1968    /// * *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.
1969    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1970    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1971    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeCreateCall<'a, C>
1972    where
1973        T: AsRef<str>,
1974    {
1975        self._additional_params
1976            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1977        self
1978    }
1979
1980    /// Identifies the authorization scope for the method you are building.
1981    ///
1982    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1983    /// [`Scope::CloudPlatform`].
1984    ///
1985    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1986    /// tokens for more than one scope.
1987    ///
1988    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1989    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1990    /// sufficient, a read-write scope will do as well.
1991    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeCreateCall<'a, C>
1992    where
1993        St: AsRef<str>,
1994    {
1995        self._scopes.insert(String::from(scope.as_ref()));
1996        self
1997    }
1998    /// Identifies the authorization scope(s) for the method you are building.
1999    ///
2000    /// See [`Self::add_scope()`] for details.
2001    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeCreateCall<'a, C>
2002    where
2003        I: IntoIterator<Item = St>,
2004        St: AsRef<str>,
2005    {
2006        self._scopes
2007            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2008        self
2009    }
2010
2011    /// Removes all scopes, and no default scope will be used either.
2012    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2013    /// for details).
2014    pub fn clear_scopes(mut self) -> ProjectLocationNodeCreateCall<'a, C> {
2015        self._scopes.clear();
2016        self
2017    }
2018}
2019
2020/// Deletes a node.
2021///
2022/// A builder for the *locations.nodes.delete* method supported by a *project* resource.
2023/// It is not used directly, but through a [`ProjectMethods`] instance.
2024///
2025/// # Example
2026///
2027/// Instantiate a resource method builder
2028///
2029/// ```test_harness,no_run
2030/// # extern crate hyper;
2031/// # extern crate hyper_rustls;
2032/// # extern crate google_tpu1 as tpu1;
2033/// # async fn dox() {
2034/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2035///
2036/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2037/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2038/// #     .with_native_roots()
2039/// #     .unwrap()
2040/// #     .https_only()
2041/// #     .enable_http2()
2042/// #     .build();
2043///
2044/// # let executor = hyper_util::rt::TokioExecutor::new();
2045/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2046/// #     secret,
2047/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2048/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2049/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2050/// #     ),
2051/// # ).build().await.unwrap();
2052///
2053/// # let client = hyper_util::client::legacy::Client::builder(
2054/// #     hyper_util::rt::TokioExecutor::new()
2055/// # )
2056/// # .build(
2057/// #     hyper_rustls::HttpsConnectorBuilder::new()
2058/// #         .with_native_roots()
2059/// #         .unwrap()
2060/// #         .https_or_http()
2061/// #         .enable_http2()
2062/// #         .build()
2063/// # );
2064/// # let mut hub = TPU::new(client, auth);
2065/// // You can configure optional parameters by calling the respective setters at will, and
2066/// // execute the final call using `doit()`.
2067/// // Values shown here are possibly random and not representative !
2068/// let result = hub.projects().locations_nodes_delete("name")
2069///              .doit().await;
2070/// # }
2071/// ```
2072pub struct ProjectLocationNodeDeleteCall<'a, C>
2073where
2074    C: 'a,
2075{
2076    hub: &'a TPU<C>,
2077    _name: String,
2078    _delegate: Option<&'a mut dyn common::Delegate>,
2079    _additional_params: HashMap<String, String>,
2080    _scopes: BTreeSet<String>,
2081}
2082
2083impl<'a, C> common::CallBuilder for ProjectLocationNodeDeleteCall<'a, C> {}
2084
2085impl<'a, C> ProjectLocationNodeDeleteCall<'a, C>
2086where
2087    C: common::Connector,
2088{
2089    /// Perform the operation you have build so far.
2090    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2091        use std::borrow::Cow;
2092        use std::io::{Read, Seek};
2093
2094        use common::{url::Params, ToParts};
2095        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2096
2097        let mut dd = common::DefaultDelegate;
2098        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2099        dlg.begin(common::MethodInfo {
2100            id: "tpu.projects.locations.nodes.delete",
2101            http_method: hyper::Method::DELETE,
2102        });
2103
2104        for &field in ["alt", "name"].iter() {
2105            if self._additional_params.contains_key(field) {
2106                dlg.finished(false);
2107                return Err(common::Error::FieldClash(field));
2108            }
2109        }
2110
2111        let mut params = Params::with_capacity(3 + self._additional_params.len());
2112        params.push("name", self._name);
2113
2114        params.extend(self._additional_params.iter());
2115
2116        params.push("alt", "json");
2117        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2118        if self._scopes.is_empty() {
2119            self._scopes
2120                .insert(Scope::CloudPlatform.as_ref().to_string());
2121        }
2122
2123        #[allow(clippy::single_element_loop)]
2124        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2125            url = params.uri_replacement(url, param_name, find_this, true);
2126        }
2127        {
2128            let to_remove = ["name"];
2129            params.remove_params(&to_remove);
2130        }
2131
2132        let url = params.parse_with_url(&url);
2133
2134        loop {
2135            let token = match self
2136                .hub
2137                .auth
2138                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2139                .await
2140            {
2141                Ok(token) => token,
2142                Err(e) => match dlg.token(e) {
2143                    Ok(token) => token,
2144                    Err(e) => {
2145                        dlg.finished(false);
2146                        return Err(common::Error::MissingToken(e));
2147                    }
2148                },
2149            };
2150            let mut req_result = {
2151                let client = &self.hub.client;
2152                dlg.pre_request();
2153                let mut req_builder = hyper::Request::builder()
2154                    .method(hyper::Method::DELETE)
2155                    .uri(url.as_str())
2156                    .header(USER_AGENT, self.hub._user_agent.clone());
2157
2158                if let Some(token) = token.as_ref() {
2159                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2160                }
2161
2162                let request = req_builder
2163                    .header(CONTENT_LENGTH, 0_u64)
2164                    .body(common::to_body::<String>(None));
2165
2166                client.request(request.unwrap()).await
2167            };
2168
2169            match req_result {
2170                Err(err) => {
2171                    if let common::Retry::After(d) = dlg.http_error(&err) {
2172                        sleep(d).await;
2173                        continue;
2174                    }
2175                    dlg.finished(false);
2176                    return Err(common::Error::HttpError(err));
2177                }
2178                Ok(res) => {
2179                    let (mut parts, body) = res.into_parts();
2180                    let mut body = common::Body::new(body);
2181                    if !parts.status.is_success() {
2182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2183                        let error = serde_json::from_str(&common::to_string(&bytes));
2184                        let response = common::to_response(parts, bytes.into());
2185
2186                        if let common::Retry::After(d) =
2187                            dlg.http_failure(&response, error.as_ref().ok())
2188                        {
2189                            sleep(d).await;
2190                            continue;
2191                        }
2192
2193                        dlg.finished(false);
2194
2195                        return Err(match error {
2196                            Ok(value) => common::Error::BadRequest(value),
2197                            _ => common::Error::Failure(response),
2198                        });
2199                    }
2200                    let response = {
2201                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2202                        let encoded = common::to_string(&bytes);
2203                        match serde_json::from_str(&encoded) {
2204                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2205                            Err(error) => {
2206                                dlg.response_json_decode_error(&encoded, &error);
2207                                return Err(common::Error::JsonDecodeError(
2208                                    encoded.to_string(),
2209                                    error,
2210                                ));
2211                            }
2212                        }
2213                    };
2214
2215                    dlg.finished(true);
2216                    return Ok(response);
2217                }
2218            }
2219        }
2220    }
2221
2222    /// Required. The resource name.
2223    ///
2224    /// Sets the *name* path property to the given value.
2225    ///
2226    /// Even though the property as already been set when instantiating this call,
2227    /// we provide this method for API completeness.
2228    pub fn name(mut self, new_value: &str) -> ProjectLocationNodeDeleteCall<'a, C> {
2229        self._name = new_value.to_string();
2230        self
2231    }
2232    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2233    /// while executing the actual API request.
2234    ///
2235    /// ````text
2236    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2237    /// ````
2238    ///
2239    /// Sets the *delegate* property to the given value.
2240    pub fn delegate(
2241        mut self,
2242        new_value: &'a mut dyn common::Delegate,
2243    ) -> ProjectLocationNodeDeleteCall<'a, C> {
2244        self._delegate = Some(new_value);
2245        self
2246    }
2247
2248    /// Set any additional parameter of the query string used in the request.
2249    /// It should be used to set parameters which are not yet available through their own
2250    /// setters.
2251    ///
2252    /// Please note that this method must not be used to set any of the known parameters
2253    /// which have their own setter method. If done anyway, the request will fail.
2254    ///
2255    /// # Additional Parameters
2256    ///
2257    /// * *$.xgafv* (query-string) - V1 error format.
2258    /// * *access_token* (query-string) - OAuth access token.
2259    /// * *alt* (query-string) - Data format for response.
2260    /// * *callback* (query-string) - JSONP
2261    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2262    /// * *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.
2263    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2264    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2265    /// * *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.
2266    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2267    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2268    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeDeleteCall<'a, C>
2269    where
2270        T: AsRef<str>,
2271    {
2272        self._additional_params
2273            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2274        self
2275    }
2276
2277    /// Identifies the authorization scope for the method you are building.
2278    ///
2279    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2280    /// [`Scope::CloudPlatform`].
2281    ///
2282    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2283    /// tokens for more than one scope.
2284    ///
2285    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2286    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2287    /// sufficient, a read-write scope will do as well.
2288    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeDeleteCall<'a, C>
2289    where
2290        St: AsRef<str>,
2291    {
2292        self._scopes.insert(String::from(scope.as_ref()));
2293        self
2294    }
2295    /// Identifies the authorization scope(s) for the method you are building.
2296    ///
2297    /// See [`Self::add_scope()`] for details.
2298    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeDeleteCall<'a, C>
2299    where
2300        I: IntoIterator<Item = St>,
2301        St: AsRef<str>,
2302    {
2303        self._scopes
2304            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2305        self
2306    }
2307
2308    /// Removes all scopes, and no default scope will be used either.
2309    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2310    /// for details).
2311    pub fn clear_scopes(mut self) -> ProjectLocationNodeDeleteCall<'a, C> {
2312        self._scopes.clear();
2313        self
2314    }
2315}
2316
2317/// Gets the details of a node.
2318///
2319/// A builder for the *locations.nodes.get* method supported by a *project* resource.
2320/// It is not used directly, but through a [`ProjectMethods`] instance.
2321///
2322/// # Example
2323///
2324/// Instantiate a resource method builder
2325///
2326/// ```test_harness,no_run
2327/// # extern crate hyper;
2328/// # extern crate hyper_rustls;
2329/// # extern crate google_tpu1 as tpu1;
2330/// # async fn dox() {
2331/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2332///
2333/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2334/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2335/// #     .with_native_roots()
2336/// #     .unwrap()
2337/// #     .https_only()
2338/// #     .enable_http2()
2339/// #     .build();
2340///
2341/// # let executor = hyper_util::rt::TokioExecutor::new();
2342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2343/// #     secret,
2344/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2345/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2346/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2347/// #     ),
2348/// # ).build().await.unwrap();
2349///
2350/// # let client = hyper_util::client::legacy::Client::builder(
2351/// #     hyper_util::rt::TokioExecutor::new()
2352/// # )
2353/// # .build(
2354/// #     hyper_rustls::HttpsConnectorBuilder::new()
2355/// #         .with_native_roots()
2356/// #         .unwrap()
2357/// #         .https_or_http()
2358/// #         .enable_http2()
2359/// #         .build()
2360/// # );
2361/// # let mut hub = TPU::new(client, auth);
2362/// // You can configure optional parameters by calling the respective setters at will, and
2363/// // execute the final call using `doit()`.
2364/// // Values shown here are possibly random and not representative !
2365/// let result = hub.projects().locations_nodes_get("name")
2366///              .doit().await;
2367/// # }
2368/// ```
2369pub struct ProjectLocationNodeGetCall<'a, C>
2370where
2371    C: 'a,
2372{
2373    hub: &'a TPU<C>,
2374    _name: String,
2375    _delegate: Option<&'a mut dyn common::Delegate>,
2376    _additional_params: HashMap<String, String>,
2377    _scopes: BTreeSet<String>,
2378}
2379
2380impl<'a, C> common::CallBuilder for ProjectLocationNodeGetCall<'a, C> {}
2381
2382impl<'a, C> ProjectLocationNodeGetCall<'a, C>
2383where
2384    C: common::Connector,
2385{
2386    /// Perform the operation you have build so far.
2387    pub async fn doit(mut self) -> common::Result<(common::Response, Node)> {
2388        use std::borrow::Cow;
2389        use std::io::{Read, Seek};
2390
2391        use common::{url::Params, ToParts};
2392        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2393
2394        let mut dd = common::DefaultDelegate;
2395        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2396        dlg.begin(common::MethodInfo {
2397            id: "tpu.projects.locations.nodes.get",
2398            http_method: hyper::Method::GET,
2399        });
2400
2401        for &field in ["alt", "name"].iter() {
2402            if self._additional_params.contains_key(field) {
2403                dlg.finished(false);
2404                return Err(common::Error::FieldClash(field));
2405            }
2406        }
2407
2408        let mut params = Params::with_capacity(3 + self._additional_params.len());
2409        params.push("name", self._name);
2410
2411        params.extend(self._additional_params.iter());
2412
2413        params.push("alt", "json");
2414        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2415        if self._scopes.is_empty() {
2416            self._scopes
2417                .insert(Scope::CloudPlatform.as_ref().to_string());
2418        }
2419
2420        #[allow(clippy::single_element_loop)]
2421        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2422            url = params.uri_replacement(url, param_name, find_this, true);
2423        }
2424        {
2425            let to_remove = ["name"];
2426            params.remove_params(&to_remove);
2427        }
2428
2429        let url = params.parse_with_url(&url);
2430
2431        loop {
2432            let token = match self
2433                .hub
2434                .auth
2435                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2436                .await
2437            {
2438                Ok(token) => token,
2439                Err(e) => match dlg.token(e) {
2440                    Ok(token) => token,
2441                    Err(e) => {
2442                        dlg.finished(false);
2443                        return Err(common::Error::MissingToken(e));
2444                    }
2445                },
2446            };
2447            let mut req_result = {
2448                let client = &self.hub.client;
2449                dlg.pre_request();
2450                let mut req_builder = hyper::Request::builder()
2451                    .method(hyper::Method::GET)
2452                    .uri(url.as_str())
2453                    .header(USER_AGENT, self.hub._user_agent.clone());
2454
2455                if let Some(token) = token.as_ref() {
2456                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2457                }
2458
2459                let request = req_builder
2460                    .header(CONTENT_LENGTH, 0_u64)
2461                    .body(common::to_body::<String>(None));
2462
2463                client.request(request.unwrap()).await
2464            };
2465
2466            match req_result {
2467                Err(err) => {
2468                    if let common::Retry::After(d) = dlg.http_error(&err) {
2469                        sleep(d).await;
2470                        continue;
2471                    }
2472                    dlg.finished(false);
2473                    return Err(common::Error::HttpError(err));
2474                }
2475                Ok(res) => {
2476                    let (mut parts, body) = res.into_parts();
2477                    let mut body = common::Body::new(body);
2478                    if !parts.status.is_success() {
2479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2480                        let error = serde_json::from_str(&common::to_string(&bytes));
2481                        let response = common::to_response(parts, bytes.into());
2482
2483                        if let common::Retry::After(d) =
2484                            dlg.http_failure(&response, error.as_ref().ok())
2485                        {
2486                            sleep(d).await;
2487                            continue;
2488                        }
2489
2490                        dlg.finished(false);
2491
2492                        return Err(match error {
2493                            Ok(value) => common::Error::BadRequest(value),
2494                            _ => common::Error::Failure(response),
2495                        });
2496                    }
2497                    let response = {
2498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2499                        let encoded = common::to_string(&bytes);
2500                        match serde_json::from_str(&encoded) {
2501                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2502                            Err(error) => {
2503                                dlg.response_json_decode_error(&encoded, &error);
2504                                return Err(common::Error::JsonDecodeError(
2505                                    encoded.to_string(),
2506                                    error,
2507                                ));
2508                            }
2509                        }
2510                    };
2511
2512                    dlg.finished(true);
2513                    return Ok(response);
2514                }
2515            }
2516        }
2517    }
2518
2519    /// Required. The resource name.
2520    ///
2521    /// Sets the *name* path property to the given value.
2522    ///
2523    /// Even though the property as already been set when instantiating this call,
2524    /// we provide this method for API completeness.
2525    pub fn name(mut self, new_value: &str) -> ProjectLocationNodeGetCall<'a, C> {
2526        self._name = new_value.to_string();
2527        self
2528    }
2529    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2530    /// while executing the actual API request.
2531    ///
2532    /// ````text
2533    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2534    /// ````
2535    ///
2536    /// Sets the *delegate* property to the given value.
2537    pub fn delegate(
2538        mut self,
2539        new_value: &'a mut dyn common::Delegate,
2540    ) -> ProjectLocationNodeGetCall<'a, C> {
2541        self._delegate = Some(new_value);
2542        self
2543    }
2544
2545    /// Set any additional parameter of the query string used in the request.
2546    /// It should be used to set parameters which are not yet available through their own
2547    /// setters.
2548    ///
2549    /// Please note that this method must not be used to set any of the known parameters
2550    /// which have their own setter method. If done anyway, the request will fail.
2551    ///
2552    /// # Additional Parameters
2553    ///
2554    /// * *$.xgafv* (query-string) - V1 error format.
2555    /// * *access_token* (query-string) - OAuth access token.
2556    /// * *alt* (query-string) - Data format for response.
2557    /// * *callback* (query-string) - JSONP
2558    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2559    /// * *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.
2560    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2561    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2562    /// * *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.
2563    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2564    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2565    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeGetCall<'a, C>
2566    where
2567        T: AsRef<str>,
2568    {
2569        self._additional_params
2570            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2571        self
2572    }
2573
2574    /// Identifies the authorization scope for the method you are building.
2575    ///
2576    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2577    /// [`Scope::CloudPlatform`].
2578    ///
2579    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2580    /// tokens for more than one scope.
2581    ///
2582    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2583    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2584    /// sufficient, a read-write scope will do as well.
2585    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeGetCall<'a, C>
2586    where
2587        St: AsRef<str>,
2588    {
2589        self._scopes.insert(String::from(scope.as_ref()));
2590        self
2591    }
2592    /// Identifies the authorization scope(s) for the method you are building.
2593    ///
2594    /// See [`Self::add_scope()`] for details.
2595    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeGetCall<'a, C>
2596    where
2597        I: IntoIterator<Item = St>,
2598        St: AsRef<str>,
2599    {
2600        self._scopes
2601            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2602        self
2603    }
2604
2605    /// Removes all scopes, and no default scope will be used either.
2606    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2607    /// for details).
2608    pub fn clear_scopes(mut self) -> ProjectLocationNodeGetCall<'a, C> {
2609        self._scopes.clear();
2610        self
2611    }
2612}
2613
2614/// Lists nodes.
2615///
2616/// A builder for the *locations.nodes.list* method supported by a *project* resource.
2617/// It is not used directly, but through a [`ProjectMethods`] instance.
2618///
2619/// # Example
2620///
2621/// Instantiate a resource method builder
2622///
2623/// ```test_harness,no_run
2624/// # extern crate hyper;
2625/// # extern crate hyper_rustls;
2626/// # extern crate google_tpu1 as tpu1;
2627/// # async fn dox() {
2628/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2629///
2630/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2631/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2632/// #     .with_native_roots()
2633/// #     .unwrap()
2634/// #     .https_only()
2635/// #     .enable_http2()
2636/// #     .build();
2637///
2638/// # let executor = hyper_util::rt::TokioExecutor::new();
2639/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2640/// #     secret,
2641/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2642/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2643/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2644/// #     ),
2645/// # ).build().await.unwrap();
2646///
2647/// # let client = hyper_util::client::legacy::Client::builder(
2648/// #     hyper_util::rt::TokioExecutor::new()
2649/// # )
2650/// # .build(
2651/// #     hyper_rustls::HttpsConnectorBuilder::new()
2652/// #         .with_native_roots()
2653/// #         .unwrap()
2654/// #         .https_or_http()
2655/// #         .enable_http2()
2656/// #         .build()
2657/// # );
2658/// # let mut hub = TPU::new(client, auth);
2659/// // You can configure optional parameters by calling the respective setters at will, and
2660/// // execute the final call using `doit()`.
2661/// // Values shown here are possibly random and not representative !
2662/// let result = hub.projects().locations_nodes_list("parent")
2663///              .page_token("dolor")
2664///              .page_size(-17)
2665///              .doit().await;
2666/// # }
2667/// ```
2668pub struct ProjectLocationNodeListCall<'a, C>
2669where
2670    C: 'a,
2671{
2672    hub: &'a TPU<C>,
2673    _parent: String,
2674    _page_token: Option<String>,
2675    _page_size: Option<i32>,
2676    _delegate: Option<&'a mut dyn common::Delegate>,
2677    _additional_params: HashMap<String, String>,
2678    _scopes: BTreeSet<String>,
2679}
2680
2681impl<'a, C> common::CallBuilder for ProjectLocationNodeListCall<'a, C> {}
2682
2683impl<'a, C> ProjectLocationNodeListCall<'a, C>
2684where
2685    C: common::Connector,
2686{
2687    /// Perform the operation you have build so far.
2688    pub async fn doit(mut self) -> common::Result<(common::Response, ListNodesResponse)> {
2689        use std::borrow::Cow;
2690        use std::io::{Read, Seek};
2691
2692        use common::{url::Params, ToParts};
2693        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2694
2695        let mut dd = common::DefaultDelegate;
2696        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2697        dlg.begin(common::MethodInfo {
2698            id: "tpu.projects.locations.nodes.list",
2699            http_method: hyper::Method::GET,
2700        });
2701
2702        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2703            if self._additional_params.contains_key(field) {
2704                dlg.finished(false);
2705                return Err(common::Error::FieldClash(field));
2706            }
2707        }
2708
2709        let mut params = Params::with_capacity(5 + self._additional_params.len());
2710        params.push("parent", self._parent);
2711        if let Some(value) = self._page_token.as_ref() {
2712            params.push("pageToken", value);
2713        }
2714        if let Some(value) = self._page_size.as_ref() {
2715            params.push("pageSize", value.to_string());
2716        }
2717
2718        params.extend(self._additional_params.iter());
2719
2720        params.push("alt", "json");
2721        let mut url = self.hub._base_url.clone() + "v1/{+parent}/nodes";
2722        if self._scopes.is_empty() {
2723            self._scopes
2724                .insert(Scope::CloudPlatform.as_ref().to_string());
2725        }
2726
2727        #[allow(clippy::single_element_loop)]
2728        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2729            url = params.uri_replacement(url, param_name, find_this, true);
2730        }
2731        {
2732            let to_remove = ["parent"];
2733            params.remove_params(&to_remove);
2734        }
2735
2736        let url = params.parse_with_url(&url);
2737
2738        loop {
2739            let token = match self
2740                .hub
2741                .auth
2742                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2743                .await
2744            {
2745                Ok(token) => token,
2746                Err(e) => match dlg.token(e) {
2747                    Ok(token) => token,
2748                    Err(e) => {
2749                        dlg.finished(false);
2750                        return Err(common::Error::MissingToken(e));
2751                    }
2752                },
2753            };
2754            let mut req_result = {
2755                let client = &self.hub.client;
2756                dlg.pre_request();
2757                let mut req_builder = hyper::Request::builder()
2758                    .method(hyper::Method::GET)
2759                    .uri(url.as_str())
2760                    .header(USER_AGENT, self.hub._user_agent.clone());
2761
2762                if let Some(token) = token.as_ref() {
2763                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2764                }
2765
2766                let request = req_builder
2767                    .header(CONTENT_LENGTH, 0_u64)
2768                    .body(common::to_body::<String>(None));
2769
2770                client.request(request.unwrap()).await
2771            };
2772
2773            match req_result {
2774                Err(err) => {
2775                    if let common::Retry::After(d) = dlg.http_error(&err) {
2776                        sleep(d).await;
2777                        continue;
2778                    }
2779                    dlg.finished(false);
2780                    return Err(common::Error::HttpError(err));
2781                }
2782                Ok(res) => {
2783                    let (mut parts, body) = res.into_parts();
2784                    let mut body = common::Body::new(body);
2785                    if !parts.status.is_success() {
2786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2787                        let error = serde_json::from_str(&common::to_string(&bytes));
2788                        let response = common::to_response(parts, bytes.into());
2789
2790                        if let common::Retry::After(d) =
2791                            dlg.http_failure(&response, error.as_ref().ok())
2792                        {
2793                            sleep(d).await;
2794                            continue;
2795                        }
2796
2797                        dlg.finished(false);
2798
2799                        return Err(match error {
2800                            Ok(value) => common::Error::BadRequest(value),
2801                            _ => common::Error::Failure(response),
2802                        });
2803                    }
2804                    let response = {
2805                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2806                        let encoded = common::to_string(&bytes);
2807                        match serde_json::from_str(&encoded) {
2808                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2809                            Err(error) => {
2810                                dlg.response_json_decode_error(&encoded, &error);
2811                                return Err(common::Error::JsonDecodeError(
2812                                    encoded.to_string(),
2813                                    error,
2814                                ));
2815                            }
2816                        }
2817                    };
2818
2819                    dlg.finished(true);
2820                    return Ok(response);
2821                }
2822            }
2823        }
2824    }
2825
2826    /// Required. The parent resource name.
2827    ///
2828    /// Sets the *parent* path property to the given value.
2829    ///
2830    /// Even though the property as already been set when instantiating this call,
2831    /// we provide this method for API completeness.
2832    pub fn parent(mut self, new_value: &str) -> ProjectLocationNodeListCall<'a, C> {
2833        self._parent = new_value.to_string();
2834        self
2835    }
2836    /// The next_page_token value returned from a previous List request, if any.
2837    ///
2838    /// Sets the *page token* query property to the given value.
2839    pub fn page_token(mut self, new_value: &str) -> ProjectLocationNodeListCall<'a, C> {
2840        self._page_token = Some(new_value.to_string());
2841        self
2842    }
2843    /// The maximum number of items to return.
2844    ///
2845    /// Sets the *page size* query property to the given value.
2846    pub fn page_size(mut self, new_value: i32) -> ProjectLocationNodeListCall<'a, C> {
2847        self._page_size = Some(new_value);
2848        self
2849    }
2850    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2851    /// while executing the actual API request.
2852    ///
2853    /// ````text
2854    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2855    /// ````
2856    ///
2857    /// Sets the *delegate* property to the given value.
2858    pub fn delegate(
2859        mut self,
2860        new_value: &'a mut dyn common::Delegate,
2861    ) -> ProjectLocationNodeListCall<'a, C> {
2862        self._delegate = Some(new_value);
2863        self
2864    }
2865
2866    /// Set any additional parameter of the query string used in the request.
2867    /// It should be used to set parameters which are not yet available through their own
2868    /// setters.
2869    ///
2870    /// Please note that this method must not be used to set any of the known parameters
2871    /// which have their own setter method. If done anyway, the request will fail.
2872    ///
2873    /// # Additional Parameters
2874    ///
2875    /// * *$.xgafv* (query-string) - V1 error format.
2876    /// * *access_token* (query-string) - OAuth access token.
2877    /// * *alt* (query-string) - Data format for response.
2878    /// * *callback* (query-string) - JSONP
2879    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2880    /// * *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.
2881    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2882    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2883    /// * *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.
2884    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2885    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2886    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeListCall<'a, C>
2887    where
2888        T: AsRef<str>,
2889    {
2890        self._additional_params
2891            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2892        self
2893    }
2894
2895    /// Identifies the authorization scope for the method you are building.
2896    ///
2897    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2898    /// [`Scope::CloudPlatform`].
2899    ///
2900    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2901    /// tokens for more than one scope.
2902    ///
2903    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2904    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2905    /// sufficient, a read-write scope will do as well.
2906    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeListCall<'a, C>
2907    where
2908        St: AsRef<str>,
2909    {
2910        self._scopes.insert(String::from(scope.as_ref()));
2911        self
2912    }
2913    /// Identifies the authorization scope(s) for the method you are building.
2914    ///
2915    /// See [`Self::add_scope()`] for details.
2916    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeListCall<'a, C>
2917    where
2918        I: IntoIterator<Item = St>,
2919        St: AsRef<str>,
2920    {
2921        self._scopes
2922            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2923        self
2924    }
2925
2926    /// Removes all scopes, and no default scope will be used either.
2927    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2928    /// for details).
2929    pub fn clear_scopes(mut self) -> ProjectLocationNodeListCall<'a, C> {
2930        self._scopes.clear();
2931        self
2932    }
2933}
2934
2935/// Reimages a node's OS.
2936///
2937/// A builder for the *locations.nodes.reimage* method supported by a *project* resource.
2938/// It is not used directly, but through a [`ProjectMethods`] instance.
2939///
2940/// # Example
2941///
2942/// Instantiate a resource method builder
2943///
2944/// ```test_harness,no_run
2945/// # extern crate hyper;
2946/// # extern crate hyper_rustls;
2947/// # extern crate google_tpu1 as tpu1;
2948/// use tpu1::api::ReimageNodeRequest;
2949/// # async fn dox() {
2950/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2951///
2952/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2953/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2954/// #     .with_native_roots()
2955/// #     .unwrap()
2956/// #     .https_only()
2957/// #     .enable_http2()
2958/// #     .build();
2959///
2960/// # let executor = hyper_util::rt::TokioExecutor::new();
2961/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2962/// #     secret,
2963/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2964/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2965/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2966/// #     ),
2967/// # ).build().await.unwrap();
2968///
2969/// # let client = hyper_util::client::legacy::Client::builder(
2970/// #     hyper_util::rt::TokioExecutor::new()
2971/// # )
2972/// # .build(
2973/// #     hyper_rustls::HttpsConnectorBuilder::new()
2974/// #         .with_native_roots()
2975/// #         .unwrap()
2976/// #         .https_or_http()
2977/// #         .enable_http2()
2978/// #         .build()
2979/// # );
2980/// # let mut hub = TPU::new(client, auth);
2981/// // As the method needs a request, you would usually fill it with the desired information
2982/// // into the respective structure. Some of the parts shown here might not be applicable !
2983/// // Values shown here are possibly random and not representative !
2984/// let mut req = ReimageNodeRequest::default();
2985///
2986/// // You can configure optional parameters by calling the respective setters at will, and
2987/// // execute the final call using `doit()`.
2988/// // Values shown here are possibly random and not representative !
2989/// let result = hub.projects().locations_nodes_reimage(req, "name")
2990///              .doit().await;
2991/// # }
2992/// ```
2993pub struct ProjectLocationNodeReimageCall<'a, C>
2994where
2995    C: 'a,
2996{
2997    hub: &'a TPU<C>,
2998    _request: ReimageNodeRequest,
2999    _name: String,
3000    _delegate: Option<&'a mut dyn common::Delegate>,
3001    _additional_params: HashMap<String, String>,
3002    _scopes: BTreeSet<String>,
3003}
3004
3005impl<'a, C> common::CallBuilder for ProjectLocationNodeReimageCall<'a, C> {}
3006
3007impl<'a, C> ProjectLocationNodeReimageCall<'a, C>
3008where
3009    C: common::Connector,
3010{
3011    /// Perform the operation you have build so far.
3012    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3013        use std::borrow::Cow;
3014        use std::io::{Read, Seek};
3015
3016        use common::{url::Params, ToParts};
3017        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3018
3019        let mut dd = common::DefaultDelegate;
3020        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3021        dlg.begin(common::MethodInfo {
3022            id: "tpu.projects.locations.nodes.reimage",
3023            http_method: hyper::Method::POST,
3024        });
3025
3026        for &field in ["alt", "name"].iter() {
3027            if self._additional_params.contains_key(field) {
3028                dlg.finished(false);
3029                return Err(common::Error::FieldClash(field));
3030            }
3031        }
3032
3033        let mut params = Params::with_capacity(4 + self._additional_params.len());
3034        params.push("name", self._name);
3035
3036        params.extend(self._additional_params.iter());
3037
3038        params.push("alt", "json");
3039        let mut url = self.hub._base_url.clone() + "v1/{+name}:reimage";
3040        if self._scopes.is_empty() {
3041            self._scopes
3042                .insert(Scope::CloudPlatform.as_ref().to_string());
3043        }
3044
3045        #[allow(clippy::single_element_loop)]
3046        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3047            url = params.uri_replacement(url, param_name, find_this, true);
3048        }
3049        {
3050            let to_remove = ["name"];
3051            params.remove_params(&to_remove);
3052        }
3053
3054        let url = params.parse_with_url(&url);
3055
3056        let mut json_mime_type = mime::APPLICATION_JSON;
3057        let mut request_value_reader = {
3058            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3059            common::remove_json_null_values(&mut value);
3060            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3061            serde_json::to_writer(&mut dst, &value).unwrap();
3062            dst
3063        };
3064        let request_size = request_value_reader
3065            .seek(std::io::SeekFrom::End(0))
3066            .unwrap();
3067        request_value_reader
3068            .seek(std::io::SeekFrom::Start(0))
3069            .unwrap();
3070
3071        loop {
3072            let token = match self
3073                .hub
3074                .auth
3075                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3076                .await
3077            {
3078                Ok(token) => token,
3079                Err(e) => match dlg.token(e) {
3080                    Ok(token) => token,
3081                    Err(e) => {
3082                        dlg.finished(false);
3083                        return Err(common::Error::MissingToken(e));
3084                    }
3085                },
3086            };
3087            request_value_reader
3088                .seek(std::io::SeekFrom::Start(0))
3089                .unwrap();
3090            let mut req_result = {
3091                let client = &self.hub.client;
3092                dlg.pre_request();
3093                let mut req_builder = hyper::Request::builder()
3094                    .method(hyper::Method::POST)
3095                    .uri(url.as_str())
3096                    .header(USER_AGENT, self.hub._user_agent.clone());
3097
3098                if let Some(token) = token.as_ref() {
3099                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3100                }
3101
3102                let request = req_builder
3103                    .header(CONTENT_TYPE, json_mime_type.to_string())
3104                    .header(CONTENT_LENGTH, request_size as u64)
3105                    .body(common::to_body(
3106                        request_value_reader.get_ref().clone().into(),
3107                    ));
3108
3109                client.request(request.unwrap()).await
3110            };
3111
3112            match req_result {
3113                Err(err) => {
3114                    if let common::Retry::After(d) = dlg.http_error(&err) {
3115                        sleep(d).await;
3116                        continue;
3117                    }
3118                    dlg.finished(false);
3119                    return Err(common::Error::HttpError(err));
3120                }
3121                Ok(res) => {
3122                    let (mut parts, body) = res.into_parts();
3123                    let mut body = common::Body::new(body);
3124                    if !parts.status.is_success() {
3125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3126                        let error = serde_json::from_str(&common::to_string(&bytes));
3127                        let response = common::to_response(parts, bytes.into());
3128
3129                        if let common::Retry::After(d) =
3130                            dlg.http_failure(&response, error.as_ref().ok())
3131                        {
3132                            sleep(d).await;
3133                            continue;
3134                        }
3135
3136                        dlg.finished(false);
3137
3138                        return Err(match error {
3139                            Ok(value) => common::Error::BadRequest(value),
3140                            _ => common::Error::Failure(response),
3141                        });
3142                    }
3143                    let response = {
3144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3145                        let encoded = common::to_string(&bytes);
3146                        match serde_json::from_str(&encoded) {
3147                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3148                            Err(error) => {
3149                                dlg.response_json_decode_error(&encoded, &error);
3150                                return Err(common::Error::JsonDecodeError(
3151                                    encoded.to_string(),
3152                                    error,
3153                                ));
3154                            }
3155                        }
3156                    };
3157
3158                    dlg.finished(true);
3159                    return Ok(response);
3160                }
3161            }
3162        }
3163    }
3164
3165    ///
3166    /// Sets the *request* property to the given value.
3167    ///
3168    /// Even though the property as already been set when instantiating this call,
3169    /// we provide this method for API completeness.
3170    pub fn request(
3171        mut self,
3172        new_value: ReimageNodeRequest,
3173    ) -> ProjectLocationNodeReimageCall<'a, C> {
3174        self._request = new_value;
3175        self
3176    }
3177    /// The resource name.
3178    ///
3179    /// Sets the *name* path property to the given value.
3180    ///
3181    /// Even though the property as already been set when instantiating this call,
3182    /// we provide this method for API completeness.
3183    pub fn name(mut self, new_value: &str) -> ProjectLocationNodeReimageCall<'a, C> {
3184        self._name = new_value.to_string();
3185        self
3186    }
3187    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3188    /// while executing the actual API request.
3189    ///
3190    /// ````text
3191    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3192    /// ````
3193    ///
3194    /// Sets the *delegate* property to the given value.
3195    pub fn delegate(
3196        mut self,
3197        new_value: &'a mut dyn common::Delegate,
3198    ) -> ProjectLocationNodeReimageCall<'a, C> {
3199        self._delegate = Some(new_value);
3200        self
3201    }
3202
3203    /// Set any additional parameter of the query string used in the request.
3204    /// It should be used to set parameters which are not yet available through their own
3205    /// setters.
3206    ///
3207    /// Please note that this method must not be used to set any of the known parameters
3208    /// which have their own setter method. If done anyway, the request will fail.
3209    ///
3210    /// # Additional Parameters
3211    ///
3212    /// * *$.xgafv* (query-string) - V1 error format.
3213    /// * *access_token* (query-string) - OAuth access token.
3214    /// * *alt* (query-string) - Data format for response.
3215    /// * *callback* (query-string) - JSONP
3216    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3217    /// * *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.
3218    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3219    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3220    /// * *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.
3221    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3222    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3223    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeReimageCall<'a, C>
3224    where
3225        T: AsRef<str>,
3226    {
3227        self._additional_params
3228            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3229        self
3230    }
3231
3232    /// Identifies the authorization scope for the method you are building.
3233    ///
3234    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3235    /// [`Scope::CloudPlatform`].
3236    ///
3237    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3238    /// tokens for more than one scope.
3239    ///
3240    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3241    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3242    /// sufficient, a read-write scope will do as well.
3243    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeReimageCall<'a, C>
3244    where
3245        St: AsRef<str>,
3246    {
3247        self._scopes.insert(String::from(scope.as_ref()));
3248        self
3249    }
3250    /// Identifies the authorization scope(s) for the method you are building.
3251    ///
3252    /// See [`Self::add_scope()`] for details.
3253    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeReimageCall<'a, C>
3254    where
3255        I: IntoIterator<Item = St>,
3256        St: AsRef<str>,
3257    {
3258        self._scopes
3259            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3260        self
3261    }
3262
3263    /// Removes all scopes, and no default scope will be used either.
3264    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3265    /// for details).
3266    pub fn clear_scopes(mut self) -> ProjectLocationNodeReimageCall<'a, C> {
3267        self._scopes.clear();
3268        self
3269    }
3270}
3271
3272/// Starts a node.
3273///
3274/// A builder for the *locations.nodes.start* method supported by a *project* resource.
3275/// It is not used directly, but through a [`ProjectMethods`] instance.
3276///
3277/// # Example
3278///
3279/// Instantiate a resource method builder
3280///
3281/// ```test_harness,no_run
3282/// # extern crate hyper;
3283/// # extern crate hyper_rustls;
3284/// # extern crate google_tpu1 as tpu1;
3285/// use tpu1::api::StartNodeRequest;
3286/// # async fn dox() {
3287/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3288///
3289/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3290/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3291/// #     .with_native_roots()
3292/// #     .unwrap()
3293/// #     .https_only()
3294/// #     .enable_http2()
3295/// #     .build();
3296///
3297/// # let executor = hyper_util::rt::TokioExecutor::new();
3298/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3299/// #     secret,
3300/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3301/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3302/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3303/// #     ),
3304/// # ).build().await.unwrap();
3305///
3306/// # let client = hyper_util::client::legacy::Client::builder(
3307/// #     hyper_util::rt::TokioExecutor::new()
3308/// # )
3309/// # .build(
3310/// #     hyper_rustls::HttpsConnectorBuilder::new()
3311/// #         .with_native_roots()
3312/// #         .unwrap()
3313/// #         .https_or_http()
3314/// #         .enable_http2()
3315/// #         .build()
3316/// # );
3317/// # let mut hub = TPU::new(client, auth);
3318/// // As the method needs a request, you would usually fill it with the desired information
3319/// // into the respective structure. Some of the parts shown here might not be applicable !
3320/// // Values shown here are possibly random and not representative !
3321/// let mut req = StartNodeRequest::default();
3322///
3323/// // You can configure optional parameters by calling the respective setters at will, and
3324/// // execute the final call using `doit()`.
3325/// // Values shown here are possibly random and not representative !
3326/// let result = hub.projects().locations_nodes_start(req, "name")
3327///              .doit().await;
3328/// # }
3329/// ```
3330pub struct ProjectLocationNodeStartCall<'a, C>
3331where
3332    C: 'a,
3333{
3334    hub: &'a TPU<C>,
3335    _request: StartNodeRequest,
3336    _name: String,
3337    _delegate: Option<&'a mut dyn common::Delegate>,
3338    _additional_params: HashMap<String, String>,
3339    _scopes: BTreeSet<String>,
3340}
3341
3342impl<'a, C> common::CallBuilder for ProjectLocationNodeStartCall<'a, C> {}
3343
3344impl<'a, C> ProjectLocationNodeStartCall<'a, C>
3345where
3346    C: common::Connector,
3347{
3348    /// Perform the operation you have build so far.
3349    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3350        use std::borrow::Cow;
3351        use std::io::{Read, Seek};
3352
3353        use common::{url::Params, ToParts};
3354        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3355
3356        let mut dd = common::DefaultDelegate;
3357        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3358        dlg.begin(common::MethodInfo {
3359            id: "tpu.projects.locations.nodes.start",
3360            http_method: hyper::Method::POST,
3361        });
3362
3363        for &field in ["alt", "name"].iter() {
3364            if self._additional_params.contains_key(field) {
3365                dlg.finished(false);
3366                return Err(common::Error::FieldClash(field));
3367            }
3368        }
3369
3370        let mut params = Params::with_capacity(4 + self._additional_params.len());
3371        params.push("name", self._name);
3372
3373        params.extend(self._additional_params.iter());
3374
3375        params.push("alt", "json");
3376        let mut url = self.hub._base_url.clone() + "v1/{+name}:start";
3377        if self._scopes.is_empty() {
3378            self._scopes
3379                .insert(Scope::CloudPlatform.as_ref().to_string());
3380        }
3381
3382        #[allow(clippy::single_element_loop)]
3383        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3384            url = params.uri_replacement(url, param_name, find_this, true);
3385        }
3386        {
3387            let to_remove = ["name"];
3388            params.remove_params(&to_remove);
3389        }
3390
3391        let url = params.parse_with_url(&url);
3392
3393        let mut json_mime_type = mime::APPLICATION_JSON;
3394        let mut request_value_reader = {
3395            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3396            common::remove_json_null_values(&mut value);
3397            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3398            serde_json::to_writer(&mut dst, &value).unwrap();
3399            dst
3400        };
3401        let request_size = request_value_reader
3402            .seek(std::io::SeekFrom::End(0))
3403            .unwrap();
3404        request_value_reader
3405            .seek(std::io::SeekFrom::Start(0))
3406            .unwrap();
3407
3408        loop {
3409            let token = match self
3410                .hub
3411                .auth
3412                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3413                .await
3414            {
3415                Ok(token) => token,
3416                Err(e) => match dlg.token(e) {
3417                    Ok(token) => token,
3418                    Err(e) => {
3419                        dlg.finished(false);
3420                        return Err(common::Error::MissingToken(e));
3421                    }
3422                },
3423            };
3424            request_value_reader
3425                .seek(std::io::SeekFrom::Start(0))
3426                .unwrap();
3427            let mut req_result = {
3428                let client = &self.hub.client;
3429                dlg.pre_request();
3430                let mut req_builder = hyper::Request::builder()
3431                    .method(hyper::Method::POST)
3432                    .uri(url.as_str())
3433                    .header(USER_AGENT, self.hub._user_agent.clone());
3434
3435                if let Some(token) = token.as_ref() {
3436                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3437                }
3438
3439                let request = req_builder
3440                    .header(CONTENT_TYPE, json_mime_type.to_string())
3441                    .header(CONTENT_LENGTH, request_size as u64)
3442                    .body(common::to_body(
3443                        request_value_reader.get_ref().clone().into(),
3444                    ));
3445
3446                client.request(request.unwrap()).await
3447            };
3448
3449            match req_result {
3450                Err(err) => {
3451                    if let common::Retry::After(d) = dlg.http_error(&err) {
3452                        sleep(d).await;
3453                        continue;
3454                    }
3455                    dlg.finished(false);
3456                    return Err(common::Error::HttpError(err));
3457                }
3458                Ok(res) => {
3459                    let (mut parts, body) = res.into_parts();
3460                    let mut body = common::Body::new(body);
3461                    if !parts.status.is_success() {
3462                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3463                        let error = serde_json::from_str(&common::to_string(&bytes));
3464                        let response = common::to_response(parts, bytes.into());
3465
3466                        if let common::Retry::After(d) =
3467                            dlg.http_failure(&response, error.as_ref().ok())
3468                        {
3469                            sleep(d).await;
3470                            continue;
3471                        }
3472
3473                        dlg.finished(false);
3474
3475                        return Err(match error {
3476                            Ok(value) => common::Error::BadRequest(value),
3477                            _ => common::Error::Failure(response),
3478                        });
3479                    }
3480                    let response = {
3481                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3482                        let encoded = common::to_string(&bytes);
3483                        match serde_json::from_str(&encoded) {
3484                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3485                            Err(error) => {
3486                                dlg.response_json_decode_error(&encoded, &error);
3487                                return Err(common::Error::JsonDecodeError(
3488                                    encoded.to_string(),
3489                                    error,
3490                                ));
3491                            }
3492                        }
3493                    };
3494
3495                    dlg.finished(true);
3496                    return Ok(response);
3497                }
3498            }
3499        }
3500    }
3501
3502    ///
3503    /// Sets the *request* property to the given value.
3504    ///
3505    /// Even though the property as already been set when instantiating this call,
3506    /// we provide this method for API completeness.
3507    pub fn request(mut self, new_value: StartNodeRequest) -> ProjectLocationNodeStartCall<'a, C> {
3508        self._request = new_value;
3509        self
3510    }
3511    /// The resource name.
3512    ///
3513    /// Sets the *name* path property to the given value.
3514    ///
3515    /// Even though the property as already been set when instantiating this call,
3516    /// we provide this method for API completeness.
3517    pub fn name(mut self, new_value: &str) -> ProjectLocationNodeStartCall<'a, C> {
3518        self._name = new_value.to_string();
3519        self
3520    }
3521    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3522    /// while executing the actual API request.
3523    ///
3524    /// ````text
3525    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3526    /// ````
3527    ///
3528    /// Sets the *delegate* property to the given value.
3529    pub fn delegate(
3530        mut self,
3531        new_value: &'a mut dyn common::Delegate,
3532    ) -> ProjectLocationNodeStartCall<'a, C> {
3533        self._delegate = Some(new_value);
3534        self
3535    }
3536
3537    /// Set any additional parameter of the query string used in the request.
3538    /// It should be used to set parameters which are not yet available through their own
3539    /// setters.
3540    ///
3541    /// Please note that this method must not be used to set any of the known parameters
3542    /// which have their own setter method. If done anyway, the request will fail.
3543    ///
3544    /// # Additional Parameters
3545    ///
3546    /// * *$.xgafv* (query-string) - V1 error format.
3547    /// * *access_token* (query-string) - OAuth access token.
3548    /// * *alt* (query-string) - Data format for response.
3549    /// * *callback* (query-string) - JSONP
3550    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3551    /// * *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.
3552    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3553    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3554    /// * *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.
3555    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3556    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3557    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeStartCall<'a, C>
3558    where
3559        T: AsRef<str>,
3560    {
3561        self._additional_params
3562            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3563        self
3564    }
3565
3566    /// Identifies the authorization scope for the method you are building.
3567    ///
3568    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3569    /// [`Scope::CloudPlatform`].
3570    ///
3571    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3572    /// tokens for more than one scope.
3573    ///
3574    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3575    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3576    /// sufficient, a read-write scope will do as well.
3577    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeStartCall<'a, C>
3578    where
3579        St: AsRef<str>,
3580    {
3581        self._scopes.insert(String::from(scope.as_ref()));
3582        self
3583    }
3584    /// Identifies the authorization scope(s) for the method you are building.
3585    ///
3586    /// See [`Self::add_scope()`] for details.
3587    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeStartCall<'a, C>
3588    where
3589        I: IntoIterator<Item = St>,
3590        St: AsRef<str>,
3591    {
3592        self._scopes
3593            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3594        self
3595    }
3596
3597    /// Removes all scopes, and no default scope will be used either.
3598    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3599    /// for details).
3600    pub fn clear_scopes(mut self) -> ProjectLocationNodeStartCall<'a, C> {
3601        self._scopes.clear();
3602        self
3603    }
3604}
3605
3606/// Stops a node, this operation is only available with single TPU nodes.
3607///
3608/// A builder for the *locations.nodes.stop* method supported by a *project* resource.
3609/// It is not used directly, but through a [`ProjectMethods`] instance.
3610///
3611/// # Example
3612///
3613/// Instantiate a resource method builder
3614///
3615/// ```test_harness,no_run
3616/// # extern crate hyper;
3617/// # extern crate hyper_rustls;
3618/// # extern crate google_tpu1 as tpu1;
3619/// use tpu1::api::StopNodeRequest;
3620/// # async fn dox() {
3621/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3622///
3623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3624/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3625/// #     .with_native_roots()
3626/// #     .unwrap()
3627/// #     .https_only()
3628/// #     .enable_http2()
3629/// #     .build();
3630///
3631/// # let executor = hyper_util::rt::TokioExecutor::new();
3632/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3633/// #     secret,
3634/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3635/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3636/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3637/// #     ),
3638/// # ).build().await.unwrap();
3639///
3640/// # let client = hyper_util::client::legacy::Client::builder(
3641/// #     hyper_util::rt::TokioExecutor::new()
3642/// # )
3643/// # .build(
3644/// #     hyper_rustls::HttpsConnectorBuilder::new()
3645/// #         .with_native_roots()
3646/// #         .unwrap()
3647/// #         .https_or_http()
3648/// #         .enable_http2()
3649/// #         .build()
3650/// # );
3651/// # let mut hub = TPU::new(client, auth);
3652/// // As the method needs a request, you would usually fill it with the desired information
3653/// // into the respective structure. Some of the parts shown here might not be applicable !
3654/// // Values shown here are possibly random and not representative !
3655/// let mut req = StopNodeRequest::default();
3656///
3657/// // You can configure optional parameters by calling the respective setters at will, and
3658/// // execute the final call using `doit()`.
3659/// // Values shown here are possibly random and not representative !
3660/// let result = hub.projects().locations_nodes_stop(req, "name")
3661///              .doit().await;
3662/// # }
3663/// ```
3664pub struct ProjectLocationNodeStopCall<'a, C>
3665where
3666    C: 'a,
3667{
3668    hub: &'a TPU<C>,
3669    _request: StopNodeRequest,
3670    _name: String,
3671    _delegate: Option<&'a mut dyn common::Delegate>,
3672    _additional_params: HashMap<String, String>,
3673    _scopes: BTreeSet<String>,
3674}
3675
3676impl<'a, C> common::CallBuilder for ProjectLocationNodeStopCall<'a, C> {}
3677
3678impl<'a, C> ProjectLocationNodeStopCall<'a, C>
3679where
3680    C: common::Connector,
3681{
3682    /// Perform the operation you have build so far.
3683    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3684        use std::borrow::Cow;
3685        use std::io::{Read, Seek};
3686
3687        use common::{url::Params, ToParts};
3688        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3689
3690        let mut dd = common::DefaultDelegate;
3691        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3692        dlg.begin(common::MethodInfo {
3693            id: "tpu.projects.locations.nodes.stop",
3694            http_method: hyper::Method::POST,
3695        });
3696
3697        for &field in ["alt", "name"].iter() {
3698            if self._additional_params.contains_key(field) {
3699                dlg.finished(false);
3700                return Err(common::Error::FieldClash(field));
3701            }
3702        }
3703
3704        let mut params = Params::with_capacity(4 + self._additional_params.len());
3705        params.push("name", self._name);
3706
3707        params.extend(self._additional_params.iter());
3708
3709        params.push("alt", "json");
3710        let mut url = self.hub._base_url.clone() + "v1/{+name}:stop";
3711        if self._scopes.is_empty() {
3712            self._scopes
3713                .insert(Scope::CloudPlatform.as_ref().to_string());
3714        }
3715
3716        #[allow(clippy::single_element_loop)]
3717        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3718            url = params.uri_replacement(url, param_name, find_this, true);
3719        }
3720        {
3721            let to_remove = ["name"];
3722            params.remove_params(&to_remove);
3723        }
3724
3725        let url = params.parse_with_url(&url);
3726
3727        let mut json_mime_type = mime::APPLICATION_JSON;
3728        let mut request_value_reader = {
3729            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3730            common::remove_json_null_values(&mut value);
3731            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3732            serde_json::to_writer(&mut dst, &value).unwrap();
3733            dst
3734        };
3735        let request_size = request_value_reader
3736            .seek(std::io::SeekFrom::End(0))
3737            .unwrap();
3738        request_value_reader
3739            .seek(std::io::SeekFrom::Start(0))
3740            .unwrap();
3741
3742        loop {
3743            let token = match self
3744                .hub
3745                .auth
3746                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3747                .await
3748            {
3749                Ok(token) => token,
3750                Err(e) => match dlg.token(e) {
3751                    Ok(token) => token,
3752                    Err(e) => {
3753                        dlg.finished(false);
3754                        return Err(common::Error::MissingToken(e));
3755                    }
3756                },
3757            };
3758            request_value_reader
3759                .seek(std::io::SeekFrom::Start(0))
3760                .unwrap();
3761            let mut req_result = {
3762                let client = &self.hub.client;
3763                dlg.pre_request();
3764                let mut req_builder = hyper::Request::builder()
3765                    .method(hyper::Method::POST)
3766                    .uri(url.as_str())
3767                    .header(USER_AGENT, self.hub._user_agent.clone());
3768
3769                if let Some(token) = token.as_ref() {
3770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3771                }
3772
3773                let request = req_builder
3774                    .header(CONTENT_TYPE, json_mime_type.to_string())
3775                    .header(CONTENT_LENGTH, request_size as u64)
3776                    .body(common::to_body(
3777                        request_value_reader.get_ref().clone().into(),
3778                    ));
3779
3780                client.request(request.unwrap()).await
3781            };
3782
3783            match req_result {
3784                Err(err) => {
3785                    if let common::Retry::After(d) = dlg.http_error(&err) {
3786                        sleep(d).await;
3787                        continue;
3788                    }
3789                    dlg.finished(false);
3790                    return Err(common::Error::HttpError(err));
3791                }
3792                Ok(res) => {
3793                    let (mut parts, body) = res.into_parts();
3794                    let mut body = common::Body::new(body);
3795                    if !parts.status.is_success() {
3796                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3797                        let error = serde_json::from_str(&common::to_string(&bytes));
3798                        let response = common::to_response(parts, bytes.into());
3799
3800                        if let common::Retry::After(d) =
3801                            dlg.http_failure(&response, error.as_ref().ok())
3802                        {
3803                            sleep(d).await;
3804                            continue;
3805                        }
3806
3807                        dlg.finished(false);
3808
3809                        return Err(match error {
3810                            Ok(value) => common::Error::BadRequest(value),
3811                            _ => common::Error::Failure(response),
3812                        });
3813                    }
3814                    let response = {
3815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3816                        let encoded = common::to_string(&bytes);
3817                        match serde_json::from_str(&encoded) {
3818                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3819                            Err(error) => {
3820                                dlg.response_json_decode_error(&encoded, &error);
3821                                return Err(common::Error::JsonDecodeError(
3822                                    encoded.to_string(),
3823                                    error,
3824                                ));
3825                            }
3826                        }
3827                    };
3828
3829                    dlg.finished(true);
3830                    return Ok(response);
3831                }
3832            }
3833        }
3834    }
3835
3836    ///
3837    /// Sets the *request* property to the given value.
3838    ///
3839    /// Even though the property as already been set when instantiating this call,
3840    /// we provide this method for API completeness.
3841    pub fn request(mut self, new_value: StopNodeRequest) -> ProjectLocationNodeStopCall<'a, C> {
3842        self._request = new_value;
3843        self
3844    }
3845    /// The resource name.
3846    ///
3847    /// Sets the *name* path property to the given value.
3848    ///
3849    /// Even though the property as already been set when instantiating this call,
3850    /// we provide this method for API completeness.
3851    pub fn name(mut self, new_value: &str) -> ProjectLocationNodeStopCall<'a, C> {
3852        self._name = new_value.to_string();
3853        self
3854    }
3855    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3856    /// while executing the actual API request.
3857    ///
3858    /// ````text
3859    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3860    /// ````
3861    ///
3862    /// Sets the *delegate* property to the given value.
3863    pub fn delegate(
3864        mut self,
3865        new_value: &'a mut dyn common::Delegate,
3866    ) -> ProjectLocationNodeStopCall<'a, C> {
3867        self._delegate = Some(new_value);
3868        self
3869    }
3870
3871    /// Set any additional parameter of the query string used in the request.
3872    /// It should be used to set parameters which are not yet available through their own
3873    /// setters.
3874    ///
3875    /// Please note that this method must not be used to set any of the known parameters
3876    /// which have their own setter method. If done anyway, the request will fail.
3877    ///
3878    /// # Additional Parameters
3879    ///
3880    /// * *$.xgafv* (query-string) - V1 error format.
3881    /// * *access_token* (query-string) - OAuth access token.
3882    /// * *alt* (query-string) - Data format for response.
3883    /// * *callback* (query-string) - JSONP
3884    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3885    /// * *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.
3886    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3887    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3888    /// * *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.
3889    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3890    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3891    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNodeStopCall<'a, C>
3892    where
3893        T: AsRef<str>,
3894    {
3895        self._additional_params
3896            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3897        self
3898    }
3899
3900    /// Identifies the authorization scope for the method you are building.
3901    ///
3902    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3903    /// [`Scope::CloudPlatform`].
3904    ///
3905    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3906    /// tokens for more than one scope.
3907    ///
3908    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3909    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3910    /// sufficient, a read-write scope will do as well.
3911    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNodeStopCall<'a, C>
3912    where
3913        St: AsRef<str>,
3914    {
3915        self._scopes.insert(String::from(scope.as_ref()));
3916        self
3917    }
3918    /// Identifies the authorization scope(s) for the method you are building.
3919    ///
3920    /// See [`Self::add_scope()`] for details.
3921    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNodeStopCall<'a, C>
3922    where
3923        I: IntoIterator<Item = St>,
3924        St: AsRef<str>,
3925    {
3926        self._scopes
3927            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3928        self
3929    }
3930
3931    /// Removes all scopes, and no default scope will be used either.
3932    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3933    /// for details).
3934    pub fn clear_scopes(mut self) -> ProjectLocationNodeStopCall<'a, C> {
3935        self._scopes.clear();
3936        self
3937    }
3938}
3939
3940/// 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`.
3941///
3942/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
3943/// It is not used directly, but through a [`ProjectMethods`] instance.
3944///
3945/// # Example
3946///
3947/// Instantiate a resource method builder
3948///
3949/// ```test_harness,no_run
3950/// # extern crate hyper;
3951/// # extern crate hyper_rustls;
3952/// # extern crate google_tpu1 as tpu1;
3953/// # async fn dox() {
3954/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3955///
3956/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3957/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3958/// #     .with_native_roots()
3959/// #     .unwrap()
3960/// #     .https_only()
3961/// #     .enable_http2()
3962/// #     .build();
3963///
3964/// # let executor = hyper_util::rt::TokioExecutor::new();
3965/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3966/// #     secret,
3967/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3968/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3969/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3970/// #     ),
3971/// # ).build().await.unwrap();
3972///
3973/// # let client = hyper_util::client::legacy::Client::builder(
3974/// #     hyper_util::rt::TokioExecutor::new()
3975/// # )
3976/// # .build(
3977/// #     hyper_rustls::HttpsConnectorBuilder::new()
3978/// #         .with_native_roots()
3979/// #         .unwrap()
3980/// #         .https_or_http()
3981/// #         .enable_http2()
3982/// #         .build()
3983/// # );
3984/// # let mut hub = TPU::new(client, auth);
3985/// // You can configure optional parameters by calling the respective setters at will, and
3986/// // execute the final call using `doit()`.
3987/// // Values shown here are possibly random and not representative !
3988/// let result = hub.projects().locations_operations_cancel("name")
3989///              .doit().await;
3990/// # }
3991/// ```
3992pub struct ProjectLocationOperationCancelCall<'a, C>
3993where
3994    C: 'a,
3995{
3996    hub: &'a TPU<C>,
3997    _name: String,
3998    _delegate: Option<&'a mut dyn common::Delegate>,
3999    _additional_params: HashMap<String, String>,
4000    _scopes: BTreeSet<String>,
4001}
4002
4003impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
4004
4005impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
4006where
4007    C: common::Connector,
4008{
4009    /// Perform the operation you have build so far.
4010    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4011        use std::borrow::Cow;
4012        use std::io::{Read, Seek};
4013
4014        use common::{url::Params, ToParts};
4015        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4016
4017        let mut dd = common::DefaultDelegate;
4018        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4019        dlg.begin(common::MethodInfo {
4020            id: "tpu.projects.locations.operations.cancel",
4021            http_method: hyper::Method::POST,
4022        });
4023
4024        for &field in ["alt", "name"].iter() {
4025            if self._additional_params.contains_key(field) {
4026                dlg.finished(false);
4027                return Err(common::Error::FieldClash(field));
4028            }
4029        }
4030
4031        let mut params = Params::with_capacity(3 + self._additional_params.len());
4032        params.push("name", self._name);
4033
4034        params.extend(self._additional_params.iter());
4035
4036        params.push("alt", "json");
4037        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
4038        if self._scopes.is_empty() {
4039            self._scopes
4040                .insert(Scope::CloudPlatform.as_ref().to_string());
4041        }
4042
4043        #[allow(clippy::single_element_loop)]
4044        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4045            url = params.uri_replacement(url, param_name, find_this, true);
4046        }
4047        {
4048            let to_remove = ["name"];
4049            params.remove_params(&to_remove);
4050        }
4051
4052        let url = params.parse_with_url(&url);
4053
4054        loop {
4055            let token = match self
4056                .hub
4057                .auth
4058                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4059                .await
4060            {
4061                Ok(token) => token,
4062                Err(e) => match dlg.token(e) {
4063                    Ok(token) => token,
4064                    Err(e) => {
4065                        dlg.finished(false);
4066                        return Err(common::Error::MissingToken(e));
4067                    }
4068                },
4069            };
4070            let mut req_result = {
4071                let client = &self.hub.client;
4072                dlg.pre_request();
4073                let mut req_builder = hyper::Request::builder()
4074                    .method(hyper::Method::POST)
4075                    .uri(url.as_str())
4076                    .header(USER_AGENT, self.hub._user_agent.clone());
4077
4078                if let Some(token) = token.as_ref() {
4079                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4080                }
4081
4082                let request = req_builder
4083                    .header(CONTENT_LENGTH, 0_u64)
4084                    .body(common::to_body::<String>(None));
4085
4086                client.request(request.unwrap()).await
4087            };
4088
4089            match req_result {
4090                Err(err) => {
4091                    if let common::Retry::After(d) = dlg.http_error(&err) {
4092                        sleep(d).await;
4093                        continue;
4094                    }
4095                    dlg.finished(false);
4096                    return Err(common::Error::HttpError(err));
4097                }
4098                Ok(res) => {
4099                    let (mut parts, body) = res.into_parts();
4100                    let mut body = common::Body::new(body);
4101                    if !parts.status.is_success() {
4102                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4103                        let error = serde_json::from_str(&common::to_string(&bytes));
4104                        let response = common::to_response(parts, bytes.into());
4105
4106                        if let common::Retry::After(d) =
4107                            dlg.http_failure(&response, error.as_ref().ok())
4108                        {
4109                            sleep(d).await;
4110                            continue;
4111                        }
4112
4113                        dlg.finished(false);
4114
4115                        return Err(match error {
4116                            Ok(value) => common::Error::BadRequest(value),
4117                            _ => common::Error::Failure(response),
4118                        });
4119                    }
4120                    let response = {
4121                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4122                        let encoded = common::to_string(&bytes);
4123                        match serde_json::from_str(&encoded) {
4124                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4125                            Err(error) => {
4126                                dlg.response_json_decode_error(&encoded, &error);
4127                                return Err(common::Error::JsonDecodeError(
4128                                    encoded.to_string(),
4129                                    error,
4130                                ));
4131                            }
4132                        }
4133                    };
4134
4135                    dlg.finished(true);
4136                    return Ok(response);
4137                }
4138            }
4139        }
4140    }
4141
4142    /// The name of the operation resource to be cancelled.
4143    ///
4144    /// Sets the *name* path property to the given value.
4145    ///
4146    /// Even though the property as already been set when instantiating this call,
4147    /// we provide this method for API completeness.
4148    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
4149        self._name = new_value.to_string();
4150        self
4151    }
4152    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4153    /// while executing the actual API request.
4154    ///
4155    /// ````text
4156    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4157    /// ````
4158    ///
4159    /// Sets the *delegate* property to the given value.
4160    pub fn delegate(
4161        mut self,
4162        new_value: &'a mut dyn common::Delegate,
4163    ) -> ProjectLocationOperationCancelCall<'a, C> {
4164        self._delegate = Some(new_value);
4165        self
4166    }
4167
4168    /// Set any additional parameter of the query string used in the request.
4169    /// It should be used to set parameters which are not yet available through their own
4170    /// setters.
4171    ///
4172    /// Please note that this method must not be used to set any of the known parameters
4173    /// which have their own setter method. If done anyway, the request will fail.
4174    ///
4175    /// # Additional Parameters
4176    ///
4177    /// * *$.xgafv* (query-string) - V1 error format.
4178    /// * *access_token* (query-string) - OAuth access token.
4179    /// * *alt* (query-string) - Data format for response.
4180    /// * *callback* (query-string) - JSONP
4181    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4182    /// * *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.
4183    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4184    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4185    /// * *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.
4186    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4187    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4188    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
4189    where
4190        T: AsRef<str>,
4191    {
4192        self._additional_params
4193            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4194        self
4195    }
4196
4197    /// Identifies the authorization scope for the method you are building.
4198    ///
4199    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4200    /// [`Scope::CloudPlatform`].
4201    ///
4202    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4203    /// tokens for more than one scope.
4204    ///
4205    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4206    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4207    /// sufficient, a read-write scope will do as well.
4208    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
4209    where
4210        St: AsRef<str>,
4211    {
4212        self._scopes.insert(String::from(scope.as_ref()));
4213        self
4214    }
4215    /// Identifies the authorization scope(s) for the method you are building.
4216    ///
4217    /// See [`Self::add_scope()`] for details.
4218    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
4219    where
4220        I: IntoIterator<Item = St>,
4221        St: AsRef<str>,
4222    {
4223        self._scopes
4224            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4225        self
4226    }
4227
4228    /// Removes all scopes, and no default scope will be used either.
4229    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4230    /// for details).
4231    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
4232        self._scopes.clear();
4233        self
4234    }
4235}
4236
4237/// 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`.
4238///
4239/// A builder for the *locations.operations.delete* method supported by a *project* resource.
4240/// It is not used directly, but through a [`ProjectMethods`] instance.
4241///
4242/// # Example
4243///
4244/// Instantiate a resource method builder
4245///
4246/// ```test_harness,no_run
4247/// # extern crate hyper;
4248/// # extern crate hyper_rustls;
4249/// # extern crate google_tpu1 as tpu1;
4250/// # async fn dox() {
4251/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4252///
4253/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4254/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4255/// #     .with_native_roots()
4256/// #     .unwrap()
4257/// #     .https_only()
4258/// #     .enable_http2()
4259/// #     .build();
4260///
4261/// # let executor = hyper_util::rt::TokioExecutor::new();
4262/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4263/// #     secret,
4264/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4265/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4266/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4267/// #     ),
4268/// # ).build().await.unwrap();
4269///
4270/// # let client = hyper_util::client::legacy::Client::builder(
4271/// #     hyper_util::rt::TokioExecutor::new()
4272/// # )
4273/// # .build(
4274/// #     hyper_rustls::HttpsConnectorBuilder::new()
4275/// #         .with_native_roots()
4276/// #         .unwrap()
4277/// #         .https_or_http()
4278/// #         .enable_http2()
4279/// #         .build()
4280/// # );
4281/// # let mut hub = TPU::new(client, auth);
4282/// // You can configure optional parameters by calling the respective setters at will, and
4283/// // execute the final call using `doit()`.
4284/// // Values shown here are possibly random and not representative !
4285/// let result = hub.projects().locations_operations_delete("name")
4286///              .doit().await;
4287/// # }
4288/// ```
4289pub struct ProjectLocationOperationDeleteCall<'a, C>
4290where
4291    C: 'a,
4292{
4293    hub: &'a TPU<C>,
4294    _name: String,
4295    _delegate: Option<&'a mut dyn common::Delegate>,
4296    _additional_params: HashMap<String, String>,
4297    _scopes: BTreeSet<String>,
4298}
4299
4300impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
4301
4302impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
4303where
4304    C: common::Connector,
4305{
4306    /// Perform the operation you have build so far.
4307    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4308        use std::borrow::Cow;
4309        use std::io::{Read, Seek};
4310
4311        use common::{url::Params, ToParts};
4312        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4313
4314        let mut dd = common::DefaultDelegate;
4315        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4316        dlg.begin(common::MethodInfo {
4317            id: "tpu.projects.locations.operations.delete",
4318            http_method: hyper::Method::DELETE,
4319        });
4320
4321        for &field in ["alt", "name"].iter() {
4322            if self._additional_params.contains_key(field) {
4323                dlg.finished(false);
4324                return Err(common::Error::FieldClash(field));
4325            }
4326        }
4327
4328        let mut params = Params::with_capacity(3 + self._additional_params.len());
4329        params.push("name", self._name);
4330
4331        params.extend(self._additional_params.iter());
4332
4333        params.push("alt", "json");
4334        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4335        if self._scopes.is_empty() {
4336            self._scopes
4337                .insert(Scope::CloudPlatform.as_ref().to_string());
4338        }
4339
4340        #[allow(clippy::single_element_loop)]
4341        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4342            url = params.uri_replacement(url, param_name, find_this, true);
4343        }
4344        {
4345            let to_remove = ["name"];
4346            params.remove_params(&to_remove);
4347        }
4348
4349        let url = params.parse_with_url(&url);
4350
4351        loop {
4352            let token = match self
4353                .hub
4354                .auth
4355                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4356                .await
4357            {
4358                Ok(token) => token,
4359                Err(e) => match dlg.token(e) {
4360                    Ok(token) => token,
4361                    Err(e) => {
4362                        dlg.finished(false);
4363                        return Err(common::Error::MissingToken(e));
4364                    }
4365                },
4366            };
4367            let mut req_result = {
4368                let client = &self.hub.client;
4369                dlg.pre_request();
4370                let mut req_builder = hyper::Request::builder()
4371                    .method(hyper::Method::DELETE)
4372                    .uri(url.as_str())
4373                    .header(USER_AGENT, self.hub._user_agent.clone());
4374
4375                if let Some(token) = token.as_ref() {
4376                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4377                }
4378
4379                let request = req_builder
4380                    .header(CONTENT_LENGTH, 0_u64)
4381                    .body(common::to_body::<String>(None));
4382
4383                client.request(request.unwrap()).await
4384            };
4385
4386            match req_result {
4387                Err(err) => {
4388                    if let common::Retry::After(d) = dlg.http_error(&err) {
4389                        sleep(d).await;
4390                        continue;
4391                    }
4392                    dlg.finished(false);
4393                    return Err(common::Error::HttpError(err));
4394                }
4395                Ok(res) => {
4396                    let (mut parts, body) = res.into_parts();
4397                    let mut body = common::Body::new(body);
4398                    if !parts.status.is_success() {
4399                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4400                        let error = serde_json::from_str(&common::to_string(&bytes));
4401                        let response = common::to_response(parts, bytes.into());
4402
4403                        if let common::Retry::After(d) =
4404                            dlg.http_failure(&response, error.as_ref().ok())
4405                        {
4406                            sleep(d).await;
4407                            continue;
4408                        }
4409
4410                        dlg.finished(false);
4411
4412                        return Err(match error {
4413                            Ok(value) => common::Error::BadRequest(value),
4414                            _ => common::Error::Failure(response),
4415                        });
4416                    }
4417                    let response = {
4418                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4419                        let encoded = common::to_string(&bytes);
4420                        match serde_json::from_str(&encoded) {
4421                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4422                            Err(error) => {
4423                                dlg.response_json_decode_error(&encoded, &error);
4424                                return Err(common::Error::JsonDecodeError(
4425                                    encoded.to_string(),
4426                                    error,
4427                                ));
4428                            }
4429                        }
4430                    };
4431
4432                    dlg.finished(true);
4433                    return Ok(response);
4434                }
4435            }
4436        }
4437    }
4438
4439    /// The name of the operation resource to be deleted.
4440    ///
4441    /// Sets the *name* path property to the given value.
4442    ///
4443    /// Even though the property as already been set when instantiating this call,
4444    /// we provide this method for API completeness.
4445    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
4446        self._name = new_value.to_string();
4447        self
4448    }
4449    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4450    /// while executing the actual API request.
4451    ///
4452    /// ````text
4453    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4454    /// ````
4455    ///
4456    /// Sets the *delegate* property to the given value.
4457    pub fn delegate(
4458        mut self,
4459        new_value: &'a mut dyn common::Delegate,
4460    ) -> ProjectLocationOperationDeleteCall<'a, C> {
4461        self._delegate = Some(new_value);
4462        self
4463    }
4464
4465    /// Set any additional parameter of the query string used in the request.
4466    /// It should be used to set parameters which are not yet available through their own
4467    /// setters.
4468    ///
4469    /// Please note that this method must not be used to set any of the known parameters
4470    /// which have their own setter method. If done anyway, the request will fail.
4471    ///
4472    /// # Additional Parameters
4473    ///
4474    /// * *$.xgafv* (query-string) - V1 error format.
4475    /// * *access_token* (query-string) - OAuth access token.
4476    /// * *alt* (query-string) - Data format for response.
4477    /// * *callback* (query-string) - JSONP
4478    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4479    /// * *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.
4480    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4481    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4482    /// * *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.
4483    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4484    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4485    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
4486    where
4487        T: AsRef<str>,
4488    {
4489        self._additional_params
4490            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4491        self
4492    }
4493
4494    /// Identifies the authorization scope for the method you are building.
4495    ///
4496    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4497    /// [`Scope::CloudPlatform`].
4498    ///
4499    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4500    /// tokens for more than one scope.
4501    ///
4502    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4503    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4504    /// sufficient, a read-write scope will do as well.
4505    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
4506    where
4507        St: AsRef<str>,
4508    {
4509        self._scopes.insert(String::from(scope.as_ref()));
4510        self
4511    }
4512    /// Identifies the authorization scope(s) for the method you are building.
4513    ///
4514    /// See [`Self::add_scope()`] for details.
4515    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
4516    where
4517        I: IntoIterator<Item = St>,
4518        St: AsRef<str>,
4519    {
4520        self._scopes
4521            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4522        self
4523    }
4524
4525    /// Removes all scopes, and no default scope will be used either.
4526    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4527    /// for details).
4528    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
4529        self._scopes.clear();
4530        self
4531    }
4532}
4533
4534/// 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.
4535///
4536/// A builder for the *locations.operations.get* method supported by a *project* resource.
4537/// It is not used directly, but through a [`ProjectMethods`] instance.
4538///
4539/// # Example
4540///
4541/// Instantiate a resource method builder
4542///
4543/// ```test_harness,no_run
4544/// # extern crate hyper;
4545/// # extern crate hyper_rustls;
4546/// # extern crate google_tpu1 as tpu1;
4547/// # async fn dox() {
4548/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4549///
4550/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4551/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4552/// #     .with_native_roots()
4553/// #     .unwrap()
4554/// #     .https_only()
4555/// #     .enable_http2()
4556/// #     .build();
4557///
4558/// # let executor = hyper_util::rt::TokioExecutor::new();
4559/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4560/// #     secret,
4561/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4562/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4563/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4564/// #     ),
4565/// # ).build().await.unwrap();
4566///
4567/// # let client = hyper_util::client::legacy::Client::builder(
4568/// #     hyper_util::rt::TokioExecutor::new()
4569/// # )
4570/// # .build(
4571/// #     hyper_rustls::HttpsConnectorBuilder::new()
4572/// #         .with_native_roots()
4573/// #         .unwrap()
4574/// #         .https_or_http()
4575/// #         .enable_http2()
4576/// #         .build()
4577/// # );
4578/// # let mut hub = TPU::new(client, auth);
4579/// // You can configure optional parameters by calling the respective setters at will, and
4580/// // execute the final call using `doit()`.
4581/// // Values shown here are possibly random and not representative !
4582/// let result = hub.projects().locations_operations_get("name")
4583///              .doit().await;
4584/// # }
4585/// ```
4586pub struct ProjectLocationOperationGetCall<'a, C>
4587where
4588    C: 'a,
4589{
4590    hub: &'a TPU<C>,
4591    _name: String,
4592    _delegate: Option<&'a mut dyn common::Delegate>,
4593    _additional_params: HashMap<String, String>,
4594    _scopes: BTreeSet<String>,
4595}
4596
4597impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
4598
4599impl<'a, C> ProjectLocationOperationGetCall<'a, C>
4600where
4601    C: common::Connector,
4602{
4603    /// Perform the operation you have build so far.
4604    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4605        use std::borrow::Cow;
4606        use std::io::{Read, Seek};
4607
4608        use common::{url::Params, ToParts};
4609        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4610
4611        let mut dd = common::DefaultDelegate;
4612        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4613        dlg.begin(common::MethodInfo {
4614            id: "tpu.projects.locations.operations.get",
4615            http_method: hyper::Method::GET,
4616        });
4617
4618        for &field in ["alt", "name"].iter() {
4619            if self._additional_params.contains_key(field) {
4620                dlg.finished(false);
4621                return Err(common::Error::FieldClash(field));
4622            }
4623        }
4624
4625        let mut params = Params::with_capacity(3 + self._additional_params.len());
4626        params.push("name", self._name);
4627
4628        params.extend(self._additional_params.iter());
4629
4630        params.push("alt", "json");
4631        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4632        if self._scopes.is_empty() {
4633            self._scopes
4634                .insert(Scope::CloudPlatform.as_ref().to_string());
4635        }
4636
4637        #[allow(clippy::single_element_loop)]
4638        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4639            url = params.uri_replacement(url, param_name, find_this, true);
4640        }
4641        {
4642            let to_remove = ["name"];
4643            params.remove_params(&to_remove);
4644        }
4645
4646        let url = params.parse_with_url(&url);
4647
4648        loop {
4649            let token = match self
4650                .hub
4651                .auth
4652                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4653                .await
4654            {
4655                Ok(token) => token,
4656                Err(e) => match dlg.token(e) {
4657                    Ok(token) => token,
4658                    Err(e) => {
4659                        dlg.finished(false);
4660                        return Err(common::Error::MissingToken(e));
4661                    }
4662                },
4663            };
4664            let mut req_result = {
4665                let client = &self.hub.client;
4666                dlg.pre_request();
4667                let mut req_builder = hyper::Request::builder()
4668                    .method(hyper::Method::GET)
4669                    .uri(url.as_str())
4670                    .header(USER_AGENT, self.hub._user_agent.clone());
4671
4672                if let Some(token) = token.as_ref() {
4673                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4674                }
4675
4676                let request = req_builder
4677                    .header(CONTENT_LENGTH, 0_u64)
4678                    .body(common::to_body::<String>(None));
4679
4680                client.request(request.unwrap()).await
4681            };
4682
4683            match req_result {
4684                Err(err) => {
4685                    if let common::Retry::After(d) = dlg.http_error(&err) {
4686                        sleep(d).await;
4687                        continue;
4688                    }
4689                    dlg.finished(false);
4690                    return Err(common::Error::HttpError(err));
4691                }
4692                Ok(res) => {
4693                    let (mut parts, body) = res.into_parts();
4694                    let mut body = common::Body::new(body);
4695                    if !parts.status.is_success() {
4696                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4697                        let error = serde_json::from_str(&common::to_string(&bytes));
4698                        let response = common::to_response(parts, bytes.into());
4699
4700                        if let common::Retry::After(d) =
4701                            dlg.http_failure(&response, error.as_ref().ok())
4702                        {
4703                            sleep(d).await;
4704                            continue;
4705                        }
4706
4707                        dlg.finished(false);
4708
4709                        return Err(match error {
4710                            Ok(value) => common::Error::BadRequest(value),
4711                            _ => common::Error::Failure(response),
4712                        });
4713                    }
4714                    let response = {
4715                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4716                        let encoded = common::to_string(&bytes);
4717                        match serde_json::from_str(&encoded) {
4718                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4719                            Err(error) => {
4720                                dlg.response_json_decode_error(&encoded, &error);
4721                                return Err(common::Error::JsonDecodeError(
4722                                    encoded.to_string(),
4723                                    error,
4724                                ));
4725                            }
4726                        }
4727                    };
4728
4729                    dlg.finished(true);
4730                    return Ok(response);
4731                }
4732            }
4733        }
4734    }
4735
4736    /// The name of the operation resource.
4737    ///
4738    /// Sets the *name* path property to the given value.
4739    ///
4740    /// Even though the property as already been set when instantiating this call,
4741    /// we provide this method for API completeness.
4742    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
4743        self._name = new_value.to_string();
4744        self
4745    }
4746    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4747    /// while executing the actual API request.
4748    ///
4749    /// ````text
4750    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4751    /// ````
4752    ///
4753    /// Sets the *delegate* property to the given value.
4754    pub fn delegate(
4755        mut self,
4756        new_value: &'a mut dyn common::Delegate,
4757    ) -> ProjectLocationOperationGetCall<'a, C> {
4758        self._delegate = Some(new_value);
4759        self
4760    }
4761
4762    /// Set any additional parameter of the query string used in the request.
4763    /// It should be used to set parameters which are not yet available through their own
4764    /// setters.
4765    ///
4766    /// Please note that this method must not be used to set any of the known parameters
4767    /// which have their own setter method. If done anyway, the request will fail.
4768    ///
4769    /// # Additional Parameters
4770    ///
4771    /// * *$.xgafv* (query-string) - V1 error format.
4772    /// * *access_token* (query-string) - OAuth access token.
4773    /// * *alt* (query-string) - Data format for response.
4774    /// * *callback* (query-string) - JSONP
4775    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4776    /// * *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.
4777    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4778    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4779    /// * *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.
4780    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4781    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4782    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
4783    where
4784        T: AsRef<str>,
4785    {
4786        self._additional_params
4787            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4788        self
4789    }
4790
4791    /// Identifies the authorization scope for the method you are building.
4792    ///
4793    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4794    /// [`Scope::CloudPlatform`].
4795    ///
4796    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4797    /// tokens for more than one scope.
4798    ///
4799    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4800    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4801    /// sufficient, a read-write scope will do as well.
4802    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
4803    where
4804        St: AsRef<str>,
4805    {
4806        self._scopes.insert(String::from(scope.as_ref()));
4807        self
4808    }
4809    /// Identifies the authorization scope(s) for the method you are building.
4810    ///
4811    /// See [`Self::add_scope()`] for details.
4812    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
4813    where
4814        I: IntoIterator<Item = St>,
4815        St: AsRef<str>,
4816    {
4817        self._scopes
4818            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4819        self
4820    }
4821
4822    /// Removes all scopes, and no default scope will be used either.
4823    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4824    /// for details).
4825    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
4826        self._scopes.clear();
4827        self
4828    }
4829}
4830
4831/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4832///
4833/// A builder for the *locations.operations.list* method supported by a *project* resource.
4834/// It is not used directly, but through a [`ProjectMethods`] instance.
4835///
4836/// # Example
4837///
4838/// Instantiate a resource method builder
4839///
4840/// ```test_harness,no_run
4841/// # extern crate hyper;
4842/// # extern crate hyper_rustls;
4843/// # extern crate google_tpu1 as tpu1;
4844/// # async fn dox() {
4845/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4846///
4847/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4848/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4849/// #     .with_native_roots()
4850/// #     .unwrap()
4851/// #     .https_only()
4852/// #     .enable_http2()
4853/// #     .build();
4854///
4855/// # let executor = hyper_util::rt::TokioExecutor::new();
4856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4857/// #     secret,
4858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4859/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4860/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4861/// #     ),
4862/// # ).build().await.unwrap();
4863///
4864/// # let client = hyper_util::client::legacy::Client::builder(
4865/// #     hyper_util::rt::TokioExecutor::new()
4866/// # )
4867/// # .build(
4868/// #     hyper_rustls::HttpsConnectorBuilder::new()
4869/// #         .with_native_roots()
4870/// #         .unwrap()
4871/// #         .https_or_http()
4872/// #         .enable_http2()
4873/// #         .build()
4874/// # );
4875/// # let mut hub = TPU::new(client, auth);
4876/// // You can configure optional parameters by calling the respective setters at will, and
4877/// // execute the final call using `doit()`.
4878/// // Values shown here are possibly random and not representative !
4879/// let result = hub.projects().locations_operations_list("name")
4880///              .return_partial_success(true)
4881///              .page_token("ipsum")
4882///              .page_size(-50)
4883///              .filter("est")
4884///              .doit().await;
4885/// # }
4886/// ```
4887pub struct ProjectLocationOperationListCall<'a, C>
4888where
4889    C: 'a,
4890{
4891    hub: &'a TPU<C>,
4892    _name: String,
4893    _return_partial_success: Option<bool>,
4894    _page_token: Option<String>,
4895    _page_size: Option<i32>,
4896    _filter: Option<String>,
4897    _delegate: Option<&'a mut dyn common::Delegate>,
4898    _additional_params: HashMap<String, String>,
4899    _scopes: BTreeSet<String>,
4900}
4901
4902impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
4903
4904impl<'a, C> ProjectLocationOperationListCall<'a, C>
4905where
4906    C: common::Connector,
4907{
4908    /// Perform the operation you have build so far.
4909    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
4910        use std::borrow::Cow;
4911        use std::io::{Read, Seek};
4912
4913        use common::{url::Params, ToParts};
4914        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4915
4916        let mut dd = common::DefaultDelegate;
4917        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4918        dlg.begin(common::MethodInfo {
4919            id: "tpu.projects.locations.operations.list",
4920            http_method: hyper::Method::GET,
4921        });
4922
4923        for &field in [
4924            "alt",
4925            "name",
4926            "returnPartialSuccess",
4927            "pageToken",
4928            "pageSize",
4929            "filter",
4930        ]
4931        .iter()
4932        {
4933            if self._additional_params.contains_key(field) {
4934                dlg.finished(false);
4935                return Err(common::Error::FieldClash(field));
4936            }
4937        }
4938
4939        let mut params = Params::with_capacity(7 + self._additional_params.len());
4940        params.push("name", self._name);
4941        if let Some(value) = self._return_partial_success.as_ref() {
4942            params.push("returnPartialSuccess", value.to_string());
4943        }
4944        if let Some(value) = self._page_token.as_ref() {
4945            params.push("pageToken", value);
4946        }
4947        if let Some(value) = self._page_size.as_ref() {
4948            params.push("pageSize", value.to_string());
4949        }
4950        if let Some(value) = self._filter.as_ref() {
4951            params.push("filter", value);
4952        }
4953
4954        params.extend(self._additional_params.iter());
4955
4956        params.push("alt", "json");
4957        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
4958        if self._scopes.is_empty() {
4959            self._scopes
4960                .insert(Scope::CloudPlatform.as_ref().to_string());
4961        }
4962
4963        #[allow(clippy::single_element_loop)]
4964        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4965            url = params.uri_replacement(url, param_name, find_this, true);
4966        }
4967        {
4968            let to_remove = ["name"];
4969            params.remove_params(&to_remove);
4970        }
4971
4972        let url = params.parse_with_url(&url);
4973
4974        loop {
4975            let token = match self
4976                .hub
4977                .auth
4978                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4979                .await
4980            {
4981                Ok(token) => token,
4982                Err(e) => match dlg.token(e) {
4983                    Ok(token) => token,
4984                    Err(e) => {
4985                        dlg.finished(false);
4986                        return Err(common::Error::MissingToken(e));
4987                    }
4988                },
4989            };
4990            let mut req_result = {
4991                let client = &self.hub.client;
4992                dlg.pre_request();
4993                let mut req_builder = hyper::Request::builder()
4994                    .method(hyper::Method::GET)
4995                    .uri(url.as_str())
4996                    .header(USER_AGENT, self.hub._user_agent.clone());
4997
4998                if let Some(token) = token.as_ref() {
4999                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5000                }
5001
5002                let request = req_builder
5003                    .header(CONTENT_LENGTH, 0_u64)
5004                    .body(common::to_body::<String>(None));
5005
5006                client.request(request.unwrap()).await
5007            };
5008
5009            match req_result {
5010                Err(err) => {
5011                    if let common::Retry::After(d) = dlg.http_error(&err) {
5012                        sleep(d).await;
5013                        continue;
5014                    }
5015                    dlg.finished(false);
5016                    return Err(common::Error::HttpError(err));
5017                }
5018                Ok(res) => {
5019                    let (mut parts, body) = res.into_parts();
5020                    let mut body = common::Body::new(body);
5021                    if !parts.status.is_success() {
5022                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5023                        let error = serde_json::from_str(&common::to_string(&bytes));
5024                        let response = common::to_response(parts, bytes.into());
5025
5026                        if let common::Retry::After(d) =
5027                            dlg.http_failure(&response, error.as_ref().ok())
5028                        {
5029                            sleep(d).await;
5030                            continue;
5031                        }
5032
5033                        dlg.finished(false);
5034
5035                        return Err(match error {
5036                            Ok(value) => common::Error::BadRequest(value),
5037                            _ => common::Error::Failure(response),
5038                        });
5039                    }
5040                    let response = {
5041                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5042                        let encoded = common::to_string(&bytes);
5043                        match serde_json::from_str(&encoded) {
5044                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5045                            Err(error) => {
5046                                dlg.response_json_decode_error(&encoded, &error);
5047                                return Err(common::Error::JsonDecodeError(
5048                                    encoded.to_string(),
5049                                    error,
5050                                ));
5051                            }
5052                        }
5053                    };
5054
5055                    dlg.finished(true);
5056                    return Ok(response);
5057                }
5058            }
5059        }
5060    }
5061
5062    /// The name of the operation's parent resource.
5063    ///
5064    /// Sets the *name* path property to the given value.
5065    ///
5066    /// Even though the property as already been set when instantiating this call,
5067    /// we provide this method for API completeness.
5068    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5069        self._name = new_value.to_string();
5070        self
5071    }
5072    /// 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.
5073    ///
5074    /// Sets the *return partial success* query property to the given value.
5075    pub fn return_partial_success(
5076        mut self,
5077        new_value: bool,
5078    ) -> ProjectLocationOperationListCall<'a, C> {
5079        self._return_partial_success = Some(new_value);
5080        self
5081    }
5082    /// The standard list page token.
5083    ///
5084    /// Sets the *page token* query property to the given value.
5085    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5086        self._page_token = Some(new_value.to_string());
5087        self
5088    }
5089    /// The standard list page size.
5090    ///
5091    /// Sets the *page size* query property to the given value.
5092    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
5093        self._page_size = Some(new_value);
5094        self
5095    }
5096    /// The standard list filter.
5097    ///
5098    /// Sets the *filter* query property to the given value.
5099    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5100        self._filter = Some(new_value.to_string());
5101        self
5102    }
5103    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5104    /// while executing the actual API request.
5105    ///
5106    /// ````text
5107    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5108    /// ````
5109    ///
5110    /// Sets the *delegate* property to the given value.
5111    pub fn delegate(
5112        mut self,
5113        new_value: &'a mut dyn common::Delegate,
5114    ) -> ProjectLocationOperationListCall<'a, C> {
5115        self._delegate = Some(new_value);
5116        self
5117    }
5118
5119    /// Set any additional parameter of the query string used in the request.
5120    /// It should be used to set parameters which are not yet available through their own
5121    /// setters.
5122    ///
5123    /// Please note that this method must not be used to set any of the known parameters
5124    /// which have their own setter method. If done anyway, the request will fail.
5125    ///
5126    /// # Additional Parameters
5127    ///
5128    /// * *$.xgafv* (query-string) - V1 error format.
5129    /// * *access_token* (query-string) - OAuth access token.
5130    /// * *alt* (query-string) - Data format for response.
5131    /// * *callback* (query-string) - JSONP
5132    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5133    /// * *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.
5134    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5135    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5136    /// * *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.
5137    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5138    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5139    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
5140    where
5141        T: AsRef<str>,
5142    {
5143        self._additional_params
5144            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5145        self
5146    }
5147
5148    /// Identifies the authorization scope for the method you are building.
5149    ///
5150    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5151    /// [`Scope::CloudPlatform`].
5152    ///
5153    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5154    /// tokens for more than one scope.
5155    ///
5156    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5157    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5158    /// sufficient, a read-write scope will do as well.
5159    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
5160    where
5161        St: AsRef<str>,
5162    {
5163        self._scopes.insert(String::from(scope.as_ref()));
5164        self
5165    }
5166    /// Identifies the authorization scope(s) for the method you are building.
5167    ///
5168    /// See [`Self::add_scope()`] for details.
5169    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
5170    where
5171        I: IntoIterator<Item = St>,
5172        St: AsRef<str>,
5173    {
5174        self._scopes
5175            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5176        self
5177    }
5178
5179    /// Removes all scopes, and no default scope will be used either.
5180    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5181    /// for details).
5182    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
5183        self._scopes.clear();
5184        self
5185    }
5186}
5187
5188/// Gets TensorFlow Version.
5189///
5190/// A builder for the *locations.tensorflowVersions.get* method supported by a *project* resource.
5191/// It is not used directly, but through a [`ProjectMethods`] instance.
5192///
5193/// # Example
5194///
5195/// Instantiate a resource method builder
5196///
5197/// ```test_harness,no_run
5198/// # extern crate hyper;
5199/// # extern crate hyper_rustls;
5200/// # extern crate google_tpu1 as tpu1;
5201/// # async fn dox() {
5202/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5203///
5204/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5205/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5206/// #     .with_native_roots()
5207/// #     .unwrap()
5208/// #     .https_only()
5209/// #     .enable_http2()
5210/// #     .build();
5211///
5212/// # let executor = hyper_util::rt::TokioExecutor::new();
5213/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5214/// #     secret,
5215/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5216/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5217/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5218/// #     ),
5219/// # ).build().await.unwrap();
5220///
5221/// # let client = hyper_util::client::legacy::Client::builder(
5222/// #     hyper_util::rt::TokioExecutor::new()
5223/// # )
5224/// # .build(
5225/// #     hyper_rustls::HttpsConnectorBuilder::new()
5226/// #         .with_native_roots()
5227/// #         .unwrap()
5228/// #         .https_or_http()
5229/// #         .enable_http2()
5230/// #         .build()
5231/// # );
5232/// # let mut hub = TPU::new(client, auth);
5233/// // You can configure optional parameters by calling the respective setters at will, and
5234/// // execute the final call using `doit()`.
5235/// // Values shown here are possibly random and not representative !
5236/// let result = hub.projects().locations_tensorflow_versions_get("name")
5237///              .doit().await;
5238/// # }
5239/// ```
5240pub struct ProjectLocationTensorflowVersionGetCall<'a, C>
5241where
5242    C: 'a,
5243{
5244    hub: &'a TPU<C>,
5245    _name: String,
5246    _delegate: Option<&'a mut dyn common::Delegate>,
5247    _additional_params: HashMap<String, String>,
5248    _scopes: BTreeSet<String>,
5249}
5250
5251impl<'a, C> common::CallBuilder for ProjectLocationTensorflowVersionGetCall<'a, C> {}
5252
5253impl<'a, C> ProjectLocationTensorflowVersionGetCall<'a, C>
5254where
5255    C: common::Connector,
5256{
5257    /// Perform the operation you have build so far.
5258    pub async fn doit(mut self) -> common::Result<(common::Response, TensorFlowVersion)> {
5259        use std::borrow::Cow;
5260        use std::io::{Read, Seek};
5261
5262        use common::{url::Params, ToParts};
5263        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5264
5265        let mut dd = common::DefaultDelegate;
5266        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5267        dlg.begin(common::MethodInfo {
5268            id: "tpu.projects.locations.tensorflowVersions.get",
5269            http_method: hyper::Method::GET,
5270        });
5271
5272        for &field in ["alt", "name"].iter() {
5273            if self._additional_params.contains_key(field) {
5274                dlg.finished(false);
5275                return Err(common::Error::FieldClash(field));
5276            }
5277        }
5278
5279        let mut params = Params::with_capacity(3 + self._additional_params.len());
5280        params.push("name", self._name);
5281
5282        params.extend(self._additional_params.iter());
5283
5284        params.push("alt", "json");
5285        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5286        if self._scopes.is_empty() {
5287            self._scopes
5288                .insert(Scope::CloudPlatform.as_ref().to_string());
5289        }
5290
5291        #[allow(clippy::single_element_loop)]
5292        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5293            url = params.uri_replacement(url, param_name, find_this, true);
5294        }
5295        {
5296            let to_remove = ["name"];
5297            params.remove_params(&to_remove);
5298        }
5299
5300        let url = params.parse_with_url(&url);
5301
5302        loop {
5303            let token = match self
5304                .hub
5305                .auth
5306                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5307                .await
5308            {
5309                Ok(token) => token,
5310                Err(e) => match dlg.token(e) {
5311                    Ok(token) => token,
5312                    Err(e) => {
5313                        dlg.finished(false);
5314                        return Err(common::Error::MissingToken(e));
5315                    }
5316                },
5317            };
5318            let mut req_result = {
5319                let client = &self.hub.client;
5320                dlg.pre_request();
5321                let mut req_builder = hyper::Request::builder()
5322                    .method(hyper::Method::GET)
5323                    .uri(url.as_str())
5324                    .header(USER_AGENT, self.hub._user_agent.clone());
5325
5326                if let Some(token) = token.as_ref() {
5327                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5328                }
5329
5330                let request = req_builder
5331                    .header(CONTENT_LENGTH, 0_u64)
5332                    .body(common::to_body::<String>(None));
5333
5334                client.request(request.unwrap()).await
5335            };
5336
5337            match req_result {
5338                Err(err) => {
5339                    if let common::Retry::After(d) = dlg.http_error(&err) {
5340                        sleep(d).await;
5341                        continue;
5342                    }
5343                    dlg.finished(false);
5344                    return Err(common::Error::HttpError(err));
5345                }
5346                Ok(res) => {
5347                    let (mut parts, body) = res.into_parts();
5348                    let mut body = common::Body::new(body);
5349                    if !parts.status.is_success() {
5350                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5351                        let error = serde_json::from_str(&common::to_string(&bytes));
5352                        let response = common::to_response(parts, bytes.into());
5353
5354                        if let common::Retry::After(d) =
5355                            dlg.http_failure(&response, error.as_ref().ok())
5356                        {
5357                            sleep(d).await;
5358                            continue;
5359                        }
5360
5361                        dlg.finished(false);
5362
5363                        return Err(match error {
5364                            Ok(value) => common::Error::BadRequest(value),
5365                            _ => common::Error::Failure(response),
5366                        });
5367                    }
5368                    let response = {
5369                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5370                        let encoded = common::to_string(&bytes);
5371                        match serde_json::from_str(&encoded) {
5372                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5373                            Err(error) => {
5374                                dlg.response_json_decode_error(&encoded, &error);
5375                                return Err(common::Error::JsonDecodeError(
5376                                    encoded.to_string(),
5377                                    error,
5378                                ));
5379                            }
5380                        }
5381                    };
5382
5383                    dlg.finished(true);
5384                    return Ok(response);
5385                }
5386            }
5387        }
5388    }
5389
5390    /// Required. The resource name.
5391    ///
5392    /// Sets the *name* path property to the given value.
5393    ///
5394    /// Even though the property as already been set when instantiating this call,
5395    /// we provide this method for API completeness.
5396    pub fn name(mut self, new_value: &str) -> ProjectLocationTensorflowVersionGetCall<'a, C> {
5397        self._name = new_value.to_string();
5398        self
5399    }
5400    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5401    /// while executing the actual API request.
5402    ///
5403    /// ````text
5404    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5405    /// ````
5406    ///
5407    /// Sets the *delegate* property to the given value.
5408    pub fn delegate(
5409        mut self,
5410        new_value: &'a mut dyn common::Delegate,
5411    ) -> ProjectLocationTensorflowVersionGetCall<'a, C> {
5412        self._delegate = Some(new_value);
5413        self
5414    }
5415
5416    /// Set any additional parameter of the query string used in the request.
5417    /// It should be used to set parameters which are not yet available through their own
5418    /// setters.
5419    ///
5420    /// Please note that this method must not be used to set any of the known parameters
5421    /// which have their own setter method. If done anyway, the request will fail.
5422    ///
5423    /// # Additional Parameters
5424    ///
5425    /// * *$.xgafv* (query-string) - V1 error format.
5426    /// * *access_token* (query-string) - OAuth access token.
5427    /// * *alt* (query-string) - Data format for response.
5428    /// * *callback* (query-string) - JSONP
5429    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5430    /// * *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.
5431    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5432    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5433    /// * *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.
5434    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5435    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5436    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTensorflowVersionGetCall<'a, C>
5437    where
5438        T: AsRef<str>,
5439    {
5440        self._additional_params
5441            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5442        self
5443    }
5444
5445    /// Identifies the authorization scope for the method you are building.
5446    ///
5447    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5448    /// [`Scope::CloudPlatform`].
5449    ///
5450    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5451    /// tokens for more than one scope.
5452    ///
5453    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5454    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5455    /// sufficient, a read-write scope will do as well.
5456    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTensorflowVersionGetCall<'a, C>
5457    where
5458        St: AsRef<str>,
5459    {
5460        self._scopes.insert(String::from(scope.as_ref()));
5461        self
5462    }
5463    /// Identifies the authorization scope(s) for the method you are building.
5464    ///
5465    /// See [`Self::add_scope()`] for details.
5466    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTensorflowVersionGetCall<'a, C>
5467    where
5468        I: IntoIterator<Item = St>,
5469        St: AsRef<str>,
5470    {
5471        self._scopes
5472            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5473        self
5474    }
5475
5476    /// Removes all scopes, and no default scope will be used either.
5477    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5478    /// for details).
5479    pub fn clear_scopes(mut self) -> ProjectLocationTensorflowVersionGetCall<'a, C> {
5480        self._scopes.clear();
5481        self
5482    }
5483}
5484
5485/// List TensorFlow versions supported by this API.
5486///
5487/// A builder for the *locations.tensorflowVersions.list* method supported by a *project* resource.
5488/// It is not used directly, but through a [`ProjectMethods`] instance.
5489///
5490/// # Example
5491///
5492/// Instantiate a resource method builder
5493///
5494/// ```test_harness,no_run
5495/// # extern crate hyper;
5496/// # extern crate hyper_rustls;
5497/// # extern crate google_tpu1 as tpu1;
5498/// # async fn dox() {
5499/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5500///
5501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5502/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5503/// #     .with_native_roots()
5504/// #     .unwrap()
5505/// #     .https_only()
5506/// #     .enable_http2()
5507/// #     .build();
5508///
5509/// # let executor = hyper_util::rt::TokioExecutor::new();
5510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5511/// #     secret,
5512/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5513/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5514/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5515/// #     ),
5516/// # ).build().await.unwrap();
5517///
5518/// # let client = hyper_util::client::legacy::Client::builder(
5519/// #     hyper_util::rt::TokioExecutor::new()
5520/// # )
5521/// # .build(
5522/// #     hyper_rustls::HttpsConnectorBuilder::new()
5523/// #         .with_native_roots()
5524/// #         .unwrap()
5525/// #         .https_or_http()
5526/// #         .enable_http2()
5527/// #         .build()
5528/// # );
5529/// # let mut hub = TPU::new(client, auth);
5530/// // You can configure optional parameters by calling the respective setters at will, and
5531/// // execute the final call using `doit()`.
5532/// // Values shown here are possibly random and not representative !
5533/// let result = hub.projects().locations_tensorflow_versions_list("parent")
5534///              .page_token("dolor")
5535///              .page_size(-56)
5536///              .order_by("eos")
5537///              .filter("labore")
5538///              .doit().await;
5539/// # }
5540/// ```
5541pub struct ProjectLocationTensorflowVersionListCall<'a, C>
5542where
5543    C: 'a,
5544{
5545    hub: &'a TPU<C>,
5546    _parent: String,
5547    _page_token: Option<String>,
5548    _page_size: Option<i32>,
5549    _order_by: Option<String>,
5550    _filter: Option<String>,
5551    _delegate: Option<&'a mut dyn common::Delegate>,
5552    _additional_params: HashMap<String, String>,
5553    _scopes: BTreeSet<String>,
5554}
5555
5556impl<'a, C> common::CallBuilder for ProjectLocationTensorflowVersionListCall<'a, C> {}
5557
5558impl<'a, C> ProjectLocationTensorflowVersionListCall<'a, C>
5559where
5560    C: common::Connector,
5561{
5562    /// Perform the operation you have build so far.
5563    pub async fn doit(
5564        mut self,
5565    ) -> common::Result<(common::Response, ListTensorFlowVersionsResponse)> {
5566        use std::borrow::Cow;
5567        use std::io::{Read, Seek};
5568
5569        use common::{url::Params, ToParts};
5570        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5571
5572        let mut dd = common::DefaultDelegate;
5573        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5574        dlg.begin(common::MethodInfo {
5575            id: "tpu.projects.locations.tensorflowVersions.list",
5576            http_method: hyper::Method::GET,
5577        });
5578
5579        for &field in [
5580            "alt",
5581            "parent",
5582            "pageToken",
5583            "pageSize",
5584            "orderBy",
5585            "filter",
5586        ]
5587        .iter()
5588        {
5589            if self._additional_params.contains_key(field) {
5590                dlg.finished(false);
5591                return Err(common::Error::FieldClash(field));
5592            }
5593        }
5594
5595        let mut params = Params::with_capacity(7 + self._additional_params.len());
5596        params.push("parent", self._parent);
5597        if let Some(value) = self._page_token.as_ref() {
5598            params.push("pageToken", value);
5599        }
5600        if let Some(value) = self._page_size.as_ref() {
5601            params.push("pageSize", value.to_string());
5602        }
5603        if let Some(value) = self._order_by.as_ref() {
5604            params.push("orderBy", value);
5605        }
5606        if let Some(value) = self._filter.as_ref() {
5607            params.push("filter", value);
5608        }
5609
5610        params.extend(self._additional_params.iter());
5611
5612        params.push("alt", "json");
5613        let mut url = self.hub._base_url.clone() + "v1/{+parent}/tensorflowVersions";
5614        if self._scopes.is_empty() {
5615            self._scopes
5616                .insert(Scope::CloudPlatform.as_ref().to_string());
5617        }
5618
5619        #[allow(clippy::single_element_loop)]
5620        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5621            url = params.uri_replacement(url, param_name, find_this, true);
5622        }
5623        {
5624            let to_remove = ["parent"];
5625            params.remove_params(&to_remove);
5626        }
5627
5628        let url = params.parse_with_url(&url);
5629
5630        loop {
5631            let token = match self
5632                .hub
5633                .auth
5634                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5635                .await
5636            {
5637                Ok(token) => token,
5638                Err(e) => match dlg.token(e) {
5639                    Ok(token) => token,
5640                    Err(e) => {
5641                        dlg.finished(false);
5642                        return Err(common::Error::MissingToken(e));
5643                    }
5644                },
5645            };
5646            let mut req_result = {
5647                let client = &self.hub.client;
5648                dlg.pre_request();
5649                let mut req_builder = hyper::Request::builder()
5650                    .method(hyper::Method::GET)
5651                    .uri(url.as_str())
5652                    .header(USER_AGENT, self.hub._user_agent.clone());
5653
5654                if let Some(token) = token.as_ref() {
5655                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5656                }
5657
5658                let request = req_builder
5659                    .header(CONTENT_LENGTH, 0_u64)
5660                    .body(common::to_body::<String>(None));
5661
5662                client.request(request.unwrap()).await
5663            };
5664
5665            match req_result {
5666                Err(err) => {
5667                    if let common::Retry::After(d) = dlg.http_error(&err) {
5668                        sleep(d).await;
5669                        continue;
5670                    }
5671                    dlg.finished(false);
5672                    return Err(common::Error::HttpError(err));
5673                }
5674                Ok(res) => {
5675                    let (mut parts, body) = res.into_parts();
5676                    let mut body = common::Body::new(body);
5677                    if !parts.status.is_success() {
5678                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5679                        let error = serde_json::from_str(&common::to_string(&bytes));
5680                        let response = common::to_response(parts, bytes.into());
5681
5682                        if let common::Retry::After(d) =
5683                            dlg.http_failure(&response, error.as_ref().ok())
5684                        {
5685                            sleep(d).await;
5686                            continue;
5687                        }
5688
5689                        dlg.finished(false);
5690
5691                        return Err(match error {
5692                            Ok(value) => common::Error::BadRequest(value),
5693                            _ => common::Error::Failure(response),
5694                        });
5695                    }
5696                    let response = {
5697                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5698                        let encoded = common::to_string(&bytes);
5699                        match serde_json::from_str(&encoded) {
5700                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5701                            Err(error) => {
5702                                dlg.response_json_decode_error(&encoded, &error);
5703                                return Err(common::Error::JsonDecodeError(
5704                                    encoded.to_string(),
5705                                    error,
5706                                ));
5707                            }
5708                        }
5709                    };
5710
5711                    dlg.finished(true);
5712                    return Ok(response);
5713                }
5714            }
5715        }
5716    }
5717
5718    /// Required. The parent resource name.
5719    ///
5720    /// Sets the *parent* path property to the given value.
5721    ///
5722    /// Even though the property as already been set when instantiating this call,
5723    /// we provide this method for API completeness.
5724    pub fn parent(mut self, new_value: &str) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5725        self._parent = new_value.to_string();
5726        self
5727    }
5728    /// The next_page_token value returned from a previous List request, if any.
5729    ///
5730    /// Sets the *page token* query property to the given value.
5731    pub fn page_token(
5732        mut self,
5733        new_value: &str,
5734    ) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5735        self._page_token = Some(new_value.to_string());
5736        self
5737    }
5738    /// The maximum number of items to return.
5739    ///
5740    /// Sets the *page size* query property to the given value.
5741    pub fn page_size(mut self, new_value: i32) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5742        self._page_size = Some(new_value);
5743        self
5744    }
5745    /// Sort results.
5746    ///
5747    /// Sets the *order by* query property to the given value.
5748    pub fn order_by(mut self, new_value: &str) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5749        self._order_by = Some(new_value.to_string());
5750        self
5751    }
5752    /// List filter.
5753    ///
5754    /// Sets the *filter* query property to the given value.
5755    pub fn filter(mut self, new_value: &str) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5756        self._filter = Some(new_value.to_string());
5757        self
5758    }
5759    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5760    /// while executing the actual API request.
5761    ///
5762    /// ````text
5763    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5764    /// ````
5765    ///
5766    /// Sets the *delegate* property to the given value.
5767    pub fn delegate(
5768        mut self,
5769        new_value: &'a mut dyn common::Delegate,
5770    ) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5771        self._delegate = Some(new_value);
5772        self
5773    }
5774
5775    /// Set any additional parameter of the query string used in the request.
5776    /// It should be used to set parameters which are not yet available through their own
5777    /// setters.
5778    ///
5779    /// Please note that this method must not be used to set any of the known parameters
5780    /// which have their own setter method. If done anyway, the request will fail.
5781    ///
5782    /// # Additional Parameters
5783    ///
5784    /// * *$.xgafv* (query-string) - V1 error format.
5785    /// * *access_token* (query-string) - OAuth access token.
5786    /// * *alt* (query-string) - Data format for response.
5787    /// * *callback* (query-string) - JSONP
5788    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5789    /// * *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.
5790    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5791    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5792    /// * *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.
5793    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5794    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5795    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTensorflowVersionListCall<'a, C>
5796    where
5797        T: AsRef<str>,
5798    {
5799        self._additional_params
5800            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5801        self
5802    }
5803
5804    /// Identifies the authorization scope for the method you are building.
5805    ///
5806    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5807    /// [`Scope::CloudPlatform`].
5808    ///
5809    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5810    /// tokens for more than one scope.
5811    ///
5812    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5813    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5814    /// sufficient, a read-write scope will do as well.
5815    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTensorflowVersionListCall<'a, C>
5816    where
5817        St: AsRef<str>,
5818    {
5819        self._scopes.insert(String::from(scope.as_ref()));
5820        self
5821    }
5822    /// Identifies the authorization scope(s) for the method you are building.
5823    ///
5824    /// See [`Self::add_scope()`] for details.
5825    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTensorflowVersionListCall<'a, C>
5826    where
5827        I: IntoIterator<Item = St>,
5828        St: AsRef<str>,
5829    {
5830        self._scopes
5831            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5832        self
5833    }
5834
5835    /// Removes all scopes, and no default scope will be used either.
5836    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5837    /// for details).
5838    pub fn clear_scopes(mut self) -> ProjectLocationTensorflowVersionListCall<'a, C> {
5839        self._scopes.clear();
5840        self
5841    }
5842}
5843
5844/// Gets information about a location.
5845///
5846/// A builder for the *locations.get* method supported by a *project* resource.
5847/// It is not used directly, but through a [`ProjectMethods`] instance.
5848///
5849/// # Example
5850///
5851/// Instantiate a resource method builder
5852///
5853/// ```test_harness,no_run
5854/// # extern crate hyper;
5855/// # extern crate hyper_rustls;
5856/// # extern crate google_tpu1 as tpu1;
5857/// # async fn dox() {
5858/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5859///
5860/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5861/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5862/// #     .with_native_roots()
5863/// #     .unwrap()
5864/// #     .https_only()
5865/// #     .enable_http2()
5866/// #     .build();
5867///
5868/// # let executor = hyper_util::rt::TokioExecutor::new();
5869/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5870/// #     secret,
5871/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5872/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5873/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5874/// #     ),
5875/// # ).build().await.unwrap();
5876///
5877/// # let client = hyper_util::client::legacy::Client::builder(
5878/// #     hyper_util::rt::TokioExecutor::new()
5879/// # )
5880/// # .build(
5881/// #     hyper_rustls::HttpsConnectorBuilder::new()
5882/// #         .with_native_roots()
5883/// #         .unwrap()
5884/// #         .https_or_http()
5885/// #         .enable_http2()
5886/// #         .build()
5887/// # );
5888/// # let mut hub = TPU::new(client, auth);
5889/// // You can configure optional parameters by calling the respective setters at will, and
5890/// // execute the final call using `doit()`.
5891/// // Values shown here are possibly random and not representative !
5892/// let result = hub.projects().locations_get("name")
5893///              .doit().await;
5894/// # }
5895/// ```
5896pub struct ProjectLocationGetCall<'a, C>
5897where
5898    C: 'a,
5899{
5900    hub: &'a TPU<C>,
5901    _name: String,
5902    _delegate: Option<&'a mut dyn common::Delegate>,
5903    _additional_params: HashMap<String, String>,
5904    _scopes: BTreeSet<String>,
5905}
5906
5907impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
5908
5909impl<'a, C> ProjectLocationGetCall<'a, C>
5910where
5911    C: common::Connector,
5912{
5913    /// Perform the operation you have build so far.
5914    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
5915        use std::borrow::Cow;
5916        use std::io::{Read, Seek};
5917
5918        use common::{url::Params, ToParts};
5919        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5920
5921        let mut dd = common::DefaultDelegate;
5922        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5923        dlg.begin(common::MethodInfo {
5924            id: "tpu.projects.locations.get",
5925            http_method: hyper::Method::GET,
5926        });
5927
5928        for &field in ["alt", "name"].iter() {
5929            if self._additional_params.contains_key(field) {
5930                dlg.finished(false);
5931                return Err(common::Error::FieldClash(field));
5932            }
5933        }
5934
5935        let mut params = Params::with_capacity(3 + self._additional_params.len());
5936        params.push("name", self._name);
5937
5938        params.extend(self._additional_params.iter());
5939
5940        params.push("alt", "json");
5941        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5942        if self._scopes.is_empty() {
5943            self._scopes
5944                .insert(Scope::CloudPlatform.as_ref().to_string());
5945        }
5946
5947        #[allow(clippy::single_element_loop)]
5948        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5949            url = params.uri_replacement(url, param_name, find_this, true);
5950        }
5951        {
5952            let to_remove = ["name"];
5953            params.remove_params(&to_remove);
5954        }
5955
5956        let url = params.parse_with_url(&url);
5957
5958        loop {
5959            let token = match self
5960                .hub
5961                .auth
5962                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5963                .await
5964            {
5965                Ok(token) => token,
5966                Err(e) => match dlg.token(e) {
5967                    Ok(token) => token,
5968                    Err(e) => {
5969                        dlg.finished(false);
5970                        return Err(common::Error::MissingToken(e));
5971                    }
5972                },
5973            };
5974            let mut req_result = {
5975                let client = &self.hub.client;
5976                dlg.pre_request();
5977                let mut req_builder = hyper::Request::builder()
5978                    .method(hyper::Method::GET)
5979                    .uri(url.as_str())
5980                    .header(USER_AGENT, self.hub._user_agent.clone());
5981
5982                if let Some(token) = token.as_ref() {
5983                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5984                }
5985
5986                let request = req_builder
5987                    .header(CONTENT_LENGTH, 0_u64)
5988                    .body(common::to_body::<String>(None));
5989
5990                client.request(request.unwrap()).await
5991            };
5992
5993            match req_result {
5994                Err(err) => {
5995                    if let common::Retry::After(d) = dlg.http_error(&err) {
5996                        sleep(d).await;
5997                        continue;
5998                    }
5999                    dlg.finished(false);
6000                    return Err(common::Error::HttpError(err));
6001                }
6002                Ok(res) => {
6003                    let (mut parts, body) = res.into_parts();
6004                    let mut body = common::Body::new(body);
6005                    if !parts.status.is_success() {
6006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6007                        let error = serde_json::from_str(&common::to_string(&bytes));
6008                        let response = common::to_response(parts, bytes.into());
6009
6010                        if let common::Retry::After(d) =
6011                            dlg.http_failure(&response, error.as_ref().ok())
6012                        {
6013                            sleep(d).await;
6014                            continue;
6015                        }
6016
6017                        dlg.finished(false);
6018
6019                        return Err(match error {
6020                            Ok(value) => common::Error::BadRequest(value),
6021                            _ => common::Error::Failure(response),
6022                        });
6023                    }
6024                    let response = {
6025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6026                        let encoded = common::to_string(&bytes);
6027                        match serde_json::from_str(&encoded) {
6028                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6029                            Err(error) => {
6030                                dlg.response_json_decode_error(&encoded, &error);
6031                                return Err(common::Error::JsonDecodeError(
6032                                    encoded.to_string(),
6033                                    error,
6034                                ));
6035                            }
6036                        }
6037                    };
6038
6039                    dlg.finished(true);
6040                    return Ok(response);
6041                }
6042            }
6043        }
6044    }
6045
6046    /// Resource name for the location.
6047    ///
6048    /// Sets the *name* path property to the given value.
6049    ///
6050    /// Even though the property as already been set when instantiating this call,
6051    /// we provide this method for API completeness.
6052    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
6053        self._name = new_value.to_string();
6054        self
6055    }
6056    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6057    /// while executing the actual API request.
6058    ///
6059    /// ````text
6060    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6061    /// ````
6062    ///
6063    /// Sets the *delegate* property to the given value.
6064    pub fn delegate(
6065        mut self,
6066        new_value: &'a mut dyn common::Delegate,
6067    ) -> ProjectLocationGetCall<'a, C> {
6068        self._delegate = Some(new_value);
6069        self
6070    }
6071
6072    /// Set any additional parameter of the query string used in the request.
6073    /// It should be used to set parameters which are not yet available through their own
6074    /// setters.
6075    ///
6076    /// Please note that this method must not be used to set any of the known parameters
6077    /// which have their own setter method. If done anyway, the request will fail.
6078    ///
6079    /// # Additional Parameters
6080    ///
6081    /// * *$.xgafv* (query-string) - V1 error format.
6082    /// * *access_token* (query-string) - OAuth access token.
6083    /// * *alt* (query-string) - Data format for response.
6084    /// * *callback* (query-string) - JSONP
6085    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6086    /// * *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.
6087    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6088    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6089    /// * *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.
6090    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6091    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6092    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
6093    where
6094        T: AsRef<str>,
6095    {
6096        self._additional_params
6097            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6098        self
6099    }
6100
6101    /// Identifies the authorization scope for the method you are building.
6102    ///
6103    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6104    /// [`Scope::CloudPlatform`].
6105    ///
6106    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6107    /// tokens for more than one scope.
6108    ///
6109    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6110    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6111    /// sufficient, a read-write scope will do as well.
6112    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
6113    where
6114        St: AsRef<str>,
6115    {
6116        self._scopes.insert(String::from(scope.as_ref()));
6117        self
6118    }
6119    /// Identifies the authorization scope(s) for the method you are building.
6120    ///
6121    /// See [`Self::add_scope()`] for details.
6122    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
6123    where
6124        I: IntoIterator<Item = St>,
6125        St: AsRef<str>,
6126    {
6127        self._scopes
6128            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6129        self
6130    }
6131
6132    /// Removes all scopes, and no default scope will be used either.
6133    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6134    /// for details).
6135    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
6136        self._scopes.clear();
6137        self
6138    }
6139}
6140
6141/// Lists information about the supported locations for this service.
6142///
6143/// A builder for the *locations.list* method supported by a *project* resource.
6144/// It is not used directly, but through a [`ProjectMethods`] instance.
6145///
6146/// # Example
6147///
6148/// Instantiate a resource method builder
6149///
6150/// ```test_harness,no_run
6151/// # extern crate hyper;
6152/// # extern crate hyper_rustls;
6153/// # extern crate google_tpu1 as tpu1;
6154/// # async fn dox() {
6155/// # use tpu1::{TPU, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6156///
6157/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6158/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6159/// #     .with_native_roots()
6160/// #     .unwrap()
6161/// #     .https_only()
6162/// #     .enable_http2()
6163/// #     .build();
6164///
6165/// # let executor = hyper_util::rt::TokioExecutor::new();
6166/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6167/// #     secret,
6168/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6169/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6170/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6171/// #     ),
6172/// # ).build().await.unwrap();
6173///
6174/// # let client = hyper_util::client::legacy::Client::builder(
6175/// #     hyper_util::rt::TokioExecutor::new()
6176/// # )
6177/// # .build(
6178/// #     hyper_rustls::HttpsConnectorBuilder::new()
6179/// #         .with_native_roots()
6180/// #         .unwrap()
6181/// #         .https_or_http()
6182/// #         .enable_http2()
6183/// #         .build()
6184/// # );
6185/// # let mut hub = TPU::new(client, auth);
6186/// // You can configure optional parameters by calling the respective setters at will, and
6187/// // execute the final call using `doit()`.
6188/// // Values shown here are possibly random and not representative !
6189/// let result = hub.projects().locations_list("name")
6190///              .page_token("sed")
6191///              .page_size(-61)
6192///              .filter("Stet")
6193///              .add_extra_location_types("kasd")
6194///              .doit().await;
6195/// # }
6196/// ```
6197pub struct ProjectLocationListCall<'a, C>
6198where
6199    C: 'a,
6200{
6201    hub: &'a TPU<C>,
6202    _name: String,
6203    _page_token: Option<String>,
6204    _page_size: Option<i32>,
6205    _filter: Option<String>,
6206    _extra_location_types: Vec<String>,
6207    _delegate: Option<&'a mut dyn common::Delegate>,
6208    _additional_params: HashMap<String, String>,
6209    _scopes: BTreeSet<String>,
6210}
6211
6212impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
6213
6214impl<'a, C> ProjectLocationListCall<'a, C>
6215where
6216    C: common::Connector,
6217{
6218    /// Perform the operation you have build so far.
6219    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
6220        use std::borrow::Cow;
6221        use std::io::{Read, Seek};
6222
6223        use common::{url::Params, ToParts};
6224        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6225
6226        let mut dd = common::DefaultDelegate;
6227        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6228        dlg.begin(common::MethodInfo {
6229            id: "tpu.projects.locations.list",
6230            http_method: hyper::Method::GET,
6231        });
6232
6233        for &field in [
6234            "alt",
6235            "name",
6236            "pageToken",
6237            "pageSize",
6238            "filter",
6239            "extraLocationTypes",
6240        ]
6241        .iter()
6242        {
6243            if self._additional_params.contains_key(field) {
6244                dlg.finished(false);
6245                return Err(common::Error::FieldClash(field));
6246            }
6247        }
6248
6249        let mut params = Params::with_capacity(7 + self._additional_params.len());
6250        params.push("name", self._name);
6251        if let Some(value) = self._page_token.as_ref() {
6252            params.push("pageToken", value);
6253        }
6254        if let Some(value) = self._page_size.as_ref() {
6255            params.push("pageSize", value.to_string());
6256        }
6257        if let Some(value) = self._filter.as_ref() {
6258            params.push("filter", value);
6259        }
6260        if !self._extra_location_types.is_empty() {
6261            for f in self._extra_location_types.iter() {
6262                params.push("extraLocationTypes", f);
6263            }
6264        }
6265
6266        params.extend(self._additional_params.iter());
6267
6268        params.push("alt", "json");
6269        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
6270        if self._scopes.is_empty() {
6271            self._scopes
6272                .insert(Scope::CloudPlatform.as_ref().to_string());
6273        }
6274
6275        #[allow(clippy::single_element_loop)]
6276        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6277            url = params.uri_replacement(url, param_name, find_this, true);
6278        }
6279        {
6280            let to_remove = ["name"];
6281            params.remove_params(&to_remove);
6282        }
6283
6284        let url = params.parse_with_url(&url);
6285
6286        loop {
6287            let token = match self
6288                .hub
6289                .auth
6290                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6291                .await
6292            {
6293                Ok(token) => token,
6294                Err(e) => match dlg.token(e) {
6295                    Ok(token) => token,
6296                    Err(e) => {
6297                        dlg.finished(false);
6298                        return Err(common::Error::MissingToken(e));
6299                    }
6300                },
6301            };
6302            let mut req_result = {
6303                let client = &self.hub.client;
6304                dlg.pre_request();
6305                let mut req_builder = hyper::Request::builder()
6306                    .method(hyper::Method::GET)
6307                    .uri(url.as_str())
6308                    .header(USER_AGENT, self.hub._user_agent.clone());
6309
6310                if let Some(token) = token.as_ref() {
6311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6312                }
6313
6314                let request = req_builder
6315                    .header(CONTENT_LENGTH, 0_u64)
6316                    .body(common::to_body::<String>(None));
6317
6318                client.request(request.unwrap()).await
6319            };
6320
6321            match req_result {
6322                Err(err) => {
6323                    if let common::Retry::After(d) = dlg.http_error(&err) {
6324                        sleep(d).await;
6325                        continue;
6326                    }
6327                    dlg.finished(false);
6328                    return Err(common::Error::HttpError(err));
6329                }
6330                Ok(res) => {
6331                    let (mut parts, body) = res.into_parts();
6332                    let mut body = common::Body::new(body);
6333                    if !parts.status.is_success() {
6334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6335                        let error = serde_json::from_str(&common::to_string(&bytes));
6336                        let response = common::to_response(parts, bytes.into());
6337
6338                        if let common::Retry::After(d) =
6339                            dlg.http_failure(&response, error.as_ref().ok())
6340                        {
6341                            sleep(d).await;
6342                            continue;
6343                        }
6344
6345                        dlg.finished(false);
6346
6347                        return Err(match error {
6348                            Ok(value) => common::Error::BadRequest(value),
6349                            _ => common::Error::Failure(response),
6350                        });
6351                    }
6352                    let response = {
6353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6354                        let encoded = common::to_string(&bytes);
6355                        match serde_json::from_str(&encoded) {
6356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6357                            Err(error) => {
6358                                dlg.response_json_decode_error(&encoded, &error);
6359                                return Err(common::Error::JsonDecodeError(
6360                                    encoded.to_string(),
6361                                    error,
6362                                ));
6363                            }
6364                        }
6365                    };
6366
6367                    dlg.finished(true);
6368                    return Ok(response);
6369                }
6370            }
6371        }
6372    }
6373
6374    /// The resource that owns the locations collection, if applicable.
6375    ///
6376    /// Sets the *name* path property to the given value.
6377    ///
6378    /// Even though the property as already been set when instantiating this call,
6379    /// we provide this method for API completeness.
6380    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6381        self._name = new_value.to_string();
6382        self
6383    }
6384    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
6385    ///
6386    /// Sets the *page token* query property to the given value.
6387    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6388        self._page_token = Some(new_value.to_string());
6389        self
6390    }
6391    /// The maximum number of results to return. If not set, the service selects a default.
6392    ///
6393    /// Sets the *page size* query property to the given value.
6394    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
6395        self._page_size = Some(new_value);
6396        self
6397    }
6398    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
6399    ///
6400    /// Sets the *filter* query property to the given value.
6401    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6402        self._filter = Some(new_value.to_string());
6403        self
6404    }
6405    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
6406    ///
6407    /// Append the given value to the *extra location types* query property.
6408    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6409    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
6410        self._extra_location_types.push(new_value.to_string());
6411        self
6412    }
6413    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6414    /// while executing the actual API request.
6415    ///
6416    /// ````text
6417    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6418    /// ````
6419    ///
6420    /// Sets the *delegate* property to the given value.
6421    pub fn delegate(
6422        mut self,
6423        new_value: &'a mut dyn common::Delegate,
6424    ) -> ProjectLocationListCall<'a, C> {
6425        self._delegate = Some(new_value);
6426        self
6427    }
6428
6429    /// Set any additional parameter of the query string used in the request.
6430    /// It should be used to set parameters which are not yet available through their own
6431    /// setters.
6432    ///
6433    /// Please note that this method must not be used to set any of the known parameters
6434    /// which have their own setter method. If done anyway, the request will fail.
6435    ///
6436    /// # Additional Parameters
6437    ///
6438    /// * *$.xgafv* (query-string) - V1 error format.
6439    /// * *access_token* (query-string) - OAuth access token.
6440    /// * *alt* (query-string) - Data format for response.
6441    /// * *callback* (query-string) - JSONP
6442    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6443    /// * *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.
6444    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6445    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6446    /// * *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.
6447    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6448    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6449    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
6450    where
6451        T: AsRef<str>,
6452    {
6453        self._additional_params
6454            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6455        self
6456    }
6457
6458    /// Identifies the authorization scope for the method you are building.
6459    ///
6460    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6461    /// [`Scope::CloudPlatform`].
6462    ///
6463    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6464    /// tokens for more than one scope.
6465    ///
6466    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6467    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6468    /// sufficient, a read-write scope will do as well.
6469    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
6470    where
6471        St: AsRef<str>,
6472    {
6473        self._scopes.insert(String::from(scope.as_ref()));
6474        self
6475    }
6476    /// Identifies the authorization scope(s) for the method you are building.
6477    ///
6478    /// See [`Self::add_scope()`] for details.
6479    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
6480    where
6481        I: IntoIterator<Item = St>,
6482        St: AsRef<str>,
6483    {
6484        self._scopes
6485            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6486        self
6487    }
6488
6489    /// Removes all scopes, and no default scope will be used either.
6490    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6491    /// for details).
6492    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
6493        self._scopes.clear();
6494        self
6495    }
6496}