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