google_ids1/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 IDS 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_ids1 as ids1;
49/// use ids1::api::Endpoint;
50/// use ids1::{Result, Error};
51/// # async fn dox() {
52/// use ids1::{IDS, 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 = IDS::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 = Endpoint::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_endpoints_create(req, "parent")
99/// .request_id("sed")
100/// .endpoint_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 IDS<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 IDS<C> {}
132
133impl<'a, C> IDS<C> {
134 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> IDS<C> {
135 IDS {
136 client,
137 auth: Box::new(auth),
138 _user_agent: "google-api-rust-client/7.0.0".to_string(),
139 _base_url: "https://ids.googleapis.com/".to_string(),
140 _root_url: "https://ids.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://ids.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://ids.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/// The request message for Operations.CancelOperation.
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 operations cancel projects](ProjectLocationOperationCancelCall) (request)
184#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
185#[serde_with::serde_as]
186#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
187pub struct CancelOperationRequest {
188 _never_set: Option<bool>,
189}
190
191impl common::RequestValue for CancelOperationRequest {}
192
193/// 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); }
194///
195/// # Activities
196///
197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
199///
200/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
201/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct Empty {
206 _never_set: Option<bool>,
207}
208
209impl common::ResponseResult for Empty {}
210
211/// Endpoint describes a single IDS endpoint. It defines a forwarding rule to which packets can be sent for IDS inspection.
212///
213/// # Activities
214///
215/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
216/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
217///
218/// * [locations endpoints create projects](ProjectLocationEndpointCreateCall) (request)
219/// * [locations endpoints get projects](ProjectLocationEndpointGetCall) (response)
220/// * [locations endpoints patch projects](ProjectLocationEndpointPatchCall) (request)
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct Endpoint {
225 /// Output only. The create time timestamp.
226 #[serde(rename = "createTime")]
227 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
228 /// User-provided description of the endpoint
229 pub description: Option<String>,
230 /// Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule.
231 #[serde(rename = "endpointForwardingRule")]
232 pub endpoint_forwarding_rule: Option<String>,
233 /// Output only. The IP address of the IDS Endpoint's ILB.
234 #[serde(rename = "endpointIp")]
235 pub endpoint_ip: Option<String>,
236 /// The labels of the endpoint.
237 pub labels: Option<HashMap<String, String>>,
238 /// Output only. The name of the endpoint.
239 pub name: Option<String>,
240 /// Required. The fully qualified URL of the network to which the IDS Endpoint is attached.
241 pub network: Option<String>,
242 /// Output only. [Output Only] Reserved for future use.
243 #[serde(rename = "satisfiesPzi")]
244 pub satisfies_pzi: Option<bool>,
245 /// Output only. [Output Only] Reserved for future use.
246 #[serde(rename = "satisfiesPzs")]
247 pub satisfies_pzs: Option<bool>,
248 /// Required. Lowest threat severity that this endpoint will alert on.
249 pub severity: Option<String>,
250 /// Output only. Current state of the endpoint.
251 pub state: Option<String>,
252 /// List of threat IDs to be excepted from generating alerts.
253 #[serde(rename = "threatExceptions")]
254 pub threat_exceptions: Option<Vec<String>>,
255 /// Whether the endpoint should report traffic logs in addition to threat logs.
256 #[serde(rename = "trafficLogs")]
257 pub traffic_logs: Option<bool>,
258 /// Output only. The update time timestamp.
259 #[serde(rename = "updateTime")]
260 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
261}
262
263impl common::RequestValue for Endpoint {}
264impl common::ResponseResult for Endpoint {}
265
266/// There is no detailed description.
267///
268/// # Activities
269///
270/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
271/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
272///
273/// * [locations endpoints list projects](ProjectLocationEndpointListCall) (response)
274#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
275#[serde_with::serde_as]
276#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
277pub struct ListEndpointsResponse {
278 /// The list of endpoints response.
279 pub endpoints: Option<Vec<Endpoint>>,
280 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
281 #[serde(rename = "nextPageToken")]
282 pub next_page_token: Option<String>,
283 /// Locations that could not be reached.
284 pub unreachable: Option<Vec<String>>,
285}
286
287impl common::ResponseResult for ListEndpointsResponse {}
288
289/// The response message for Locations.ListLocations.
290///
291/// # Activities
292///
293/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
294/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
295///
296/// * [locations list projects](ProjectLocationListCall) (response)
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct ListLocationsResponse {
301 /// A list of locations that matches the specified filter in the request.
302 pub locations: Option<Vec<Location>>,
303 /// The standard List next-page token.
304 #[serde(rename = "nextPageToken")]
305 pub next_page_token: Option<String>,
306}
307
308impl common::ResponseResult for ListLocationsResponse {}
309
310/// The response message for Operations.ListOperations.
311///
312/// # Activities
313///
314/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
315/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
316///
317/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
318#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
319#[serde_with::serde_as]
320#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
321pub struct ListOperationsResponse {
322 /// The standard List next-page token.
323 #[serde(rename = "nextPageToken")]
324 pub next_page_token: Option<String>,
325 /// A list of operations that matches the specified filter in the request.
326 pub operations: Option<Vec<Operation>>,
327 /// 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.
328 pub unreachable: Option<Vec<String>>,
329}
330
331impl common::ResponseResult for ListOperationsResponse {}
332
333/// A resource that represents a Google Cloud location.
334///
335/// # Activities
336///
337/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
338/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
339///
340/// * [locations get projects](ProjectLocationGetCall) (response)
341#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
342#[serde_with::serde_as]
343#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
344pub struct Location {
345 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
346 #[serde(rename = "displayName")]
347 pub display_name: Option<String>,
348 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
349 pub labels: Option<HashMap<String, String>>,
350 /// The canonical id for this location. For example: `"us-east1"`.
351 #[serde(rename = "locationId")]
352 pub location_id: Option<String>,
353 /// Service-specific metadata. For example the available capacity at the given location.
354 pub metadata: Option<HashMap<String, serde_json::Value>>,
355 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
356 pub name: Option<String>,
357}
358
359impl common::ResponseResult for Location {}
360
361/// This resource represents a long-running operation that is the result of a network API call.
362///
363/// # Activities
364///
365/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
366/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
367///
368/// * [locations endpoints create projects](ProjectLocationEndpointCreateCall) (response)
369/// * [locations endpoints delete projects](ProjectLocationEndpointDeleteCall) (response)
370/// * [locations endpoints patch projects](ProjectLocationEndpointPatchCall) (response)
371/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct Operation {
376 /// 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.
377 pub done: Option<bool>,
378 /// The error result of the operation in case of failure or cancellation.
379 pub error: Option<Status>,
380 /// 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.
381 pub metadata: Option<HashMap<String, serde_json::Value>>,
382 /// 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}`.
383 pub name: Option<String>,
384 /// 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`.
385 pub response: Option<HashMap<String, serde_json::Value>>,
386}
387
388impl common::ResponseResult for Operation {}
389
390/// 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).
391///
392/// This type is not used in any activity, and only used as *part* of another schema.
393///
394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
395#[serde_with::serde_as]
396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
397pub struct Status {
398 /// The status code, which should be an enum value of google.rpc.Code.
399 pub code: Option<i32>,
400 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
401 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
402 /// 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.
403 pub message: Option<String>,
404}
405
406impl common::Part for Status {}
407
408// ###################
409// MethodBuilders ###
410// #################
411
412/// A builder providing access to all methods supported on *project* resources.
413/// It is not used directly, but through the [`IDS`] hub.
414///
415/// # Example
416///
417/// Instantiate a resource builder
418///
419/// ```test_harness,no_run
420/// extern crate hyper;
421/// extern crate hyper_rustls;
422/// extern crate google_ids1 as ids1;
423///
424/// # async fn dox() {
425/// use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
426///
427/// let secret: yup_oauth2::ApplicationSecret = Default::default();
428/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
429/// .with_native_roots()
430/// .unwrap()
431/// .https_only()
432/// .enable_http2()
433/// .build();
434///
435/// let executor = hyper_util::rt::TokioExecutor::new();
436/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
437/// secret,
438/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
439/// yup_oauth2::client::CustomHyperClientBuilder::from(
440/// hyper_util::client::legacy::Client::builder(executor).build(connector),
441/// ),
442/// ).build().await.unwrap();
443///
444/// let client = hyper_util::client::legacy::Client::builder(
445/// hyper_util::rt::TokioExecutor::new()
446/// )
447/// .build(
448/// hyper_rustls::HttpsConnectorBuilder::new()
449/// .with_native_roots()
450/// .unwrap()
451/// .https_or_http()
452/// .enable_http2()
453/// .build()
454/// );
455/// let mut hub = IDS::new(client, auth);
456/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
457/// // like `locations_endpoints_create(...)`, `locations_endpoints_delete(...)`, `locations_endpoints_get(...)`, `locations_endpoints_list(...)`, `locations_endpoints_patch(...)`, `locations_get(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
458/// // to build up your call.
459/// let rb = hub.projects();
460/// # }
461/// ```
462pub struct ProjectMethods<'a, C>
463where
464 C: 'a,
465{
466 hub: &'a IDS<C>,
467}
468
469impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
470
471impl<'a, C> ProjectMethods<'a, C> {
472 /// Create a builder to help you perform the following task:
473 ///
474 /// Creates a new Endpoint in a given project and location.
475 ///
476 /// # Arguments
477 ///
478 /// * `request` - No description provided.
479 /// * `parent` - Required. The endpoint's parent.
480 pub fn locations_endpoints_create(
481 &self,
482 request: Endpoint,
483 parent: &str,
484 ) -> ProjectLocationEndpointCreateCall<'a, C> {
485 ProjectLocationEndpointCreateCall {
486 hub: self.hub,
487 _request: request,
488 _parent: parent.to_string(),
489 _request_id: Default::default(),
490 _endpoint_id: Default::default(),
491 _delegate: Default::default(),
492 _additional_params: Default::default(),
493 _scopes: Default::default(),
494 }
495 }
496
497 /// Create a builder to help you perform the following task:
498 ///
499 /// Deletes a single Endpoint.
500 ///
501 /// # Arguments
502 ///
503 /// * `name` - Required. The name of the endpoint to delete.
504 pub fn locations_endpoints_delete(
505 &self,
506 name: &str,
507 ) -> ProjectLocationEndpointDeleteCall<'a, C> {
508 ProjectLocationEndpointDeleteCall {
509 hub: self.hub,
510 _name: name.to_string(),
511 _request_id: Default::default(),
512 _delegate: Default::default(),
513 _additional_params: Default::default(),
514 _scopes: Default::default(),
515 }
516 }
517
518 /// Create a builder to help you perform the following task:
519 ///
520 /// Gets details of a single Endpoint.
521 ///
522 /// # Arguments
523 ///
524 /// * `name` - Required. The name of the endpoint to retrieve. Format: projects/{project}/locations/{location}/endpoints/{endpoint}
525 pub fn locations_endpoints_get(&self, name: &str) -> ProjectLocationEndpointGetCall<'a, C> {
526 ProjectLocationEndpointGetCall {
527 hub: self.hub,
528 _name: name.to_string(),
529 _delegate: Default::default(),
530 _additional_params: Default::default(),
531 _scopes: Default::default(),
532 }
533 }
534
535 /// Create a builder to help you perform the following task:
536 ///
537 /// Lists Endpoints in a given project and location.
538 ///
539 /// # Arguments
540 ///
541 /// * `parent` - Required. The parent, which owns this collection of endpoints.
542 pub fn locations_endpoints_list(&self, parent: &str) -> ProjectLocationEndpointListCall<'a, C> {
543 ProjectLocationEndpointListCall {
544 hub: self.hub,
545 _parent: parent.to_string(),
546 _page_token: Default::default(),
547 _page_size: Default::default(),
548 _order_by: Default::default(),
549 _filter: Default::default(),
550 _delegate: Default::default(),
551 _additional_params: Default::default(),
552 _scopes: Default::default(),
553 }
554 }
555
556 /// Create a builder to help you perform the following task:
557 ///
558 /// Updates the parameters of a single Endpoint.
559 ///
560 /// # Arguments
561 ///
562 /// * `request` - No description provided.
563 /// * `name` - Output only. The name of the endpoint.
564 pub fn locations_endpoints_patch(
565 &self,
566 request: Endpoint,
567 name: &str,
568 ) -> ProjectLocationEndpointPatchCall<'a, C> {
569 ProjectLocationEndpointPatchCall {
570 hub: self.hub,
571 _request: request,
572 _name: name.to_string(),
573 _update_mask: Default::default(),
574 _request_id: Default::default(),
575 _delegate: Default::default(),
576 _additional_params: Default::default(),
577 _scopes: Default::default(),
578 }
579 }
580
581 /// Create a builder to help you perform the following task:
582 ///
583 /// 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`.
584 ///
585 /// # Arguments
586 ///
587 /// * `request` - No description provided.
588 /// * `name` - The name of the operation resource to be cancelled.
589 pub fn locations_operations_cancel(
590 &self,
591 request: CancelOperationRequest,
592 name: &str,
593 ) -> ProjectLocationOperationCancelCall<'a, C> {
594 ProjectLocationOperationCancelCall {
595 hub: self.hub,
596 _request: request,
597 _name: name.to_string(),
598 _delegate: Default::default(),
599 _additional_params: Default::default(),
600 _scopes: Default::default(),
601 }
602 }
603
604 /// Create a builder to help you perform the following task:
605 ///
606 /// 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`.
607 ///
608 /// # Arguments
609 ///
610 /// * `name` - The name of the operation resource to be deleted.
611 pub fn locations_operations_delete(
612 &self,
613 name: &str,
614 ) -> ProjectLocationOperationDeleteCall<'a, C> {
615 ProjectLocationOperationDeleteCall {
616 hub: self.hub,
617 _name: name.to_string(),
618 _delegate: Default::default(),
619 _additional_params: Default::default(),
620 _scopes: Default::default(),
621 }
622 }
623
624 /// Create a builder to help you perform the following task:
625 ///
626 /// 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.
627 ///
628 /// # Arguments
629 ///
630 /// * `name` - The name of the operation resource.
631 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
632 ProjectLocationOperationGetCall {
633 hub: self.hub,
634 _name: name.to_string(),
635 _delegate: Default::default(),
636 _additional_params: Default::default(),
637 _scopes: Default::default(),
638 }
639 }
640
641 /// Create a builder to help you perform the following task:
642 ///
643 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
644 ///
645 /// # Arguments
646 ///
647 /// * `name` - The name of the operation's parent resource.
648 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
649 ProjectLocationOperationListCall {
650 hub: self.hub,
651 _name: name.to_string(),
652 _return_partial_success: Default::default(),
653 _page_token: Default::default(),
654 _page_size: Default::default(),
655 _filter: Default::default(),
656 _delegate: Default::default(),
657 _additional_params: Default::default(),
658 _scopes: Default::default(),
659 }
660 }
661
662 /// Create a builder to help you perform the following task:
663 ///
664 /// Gets information about a location.
665 ///
666 /// # Arguments
667 ///
668 /// * `name` - Resource name for the location.
669 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
670 ProjectLocationGetCall {
671 hub: self.hub,
672 _name: name.to_string(),
673 _delegate: Default::default(),
674 _additional_params: Default::default(),
675 _scopes: Default::default(),
676 }
677 }
678
679 /// Create a builder to help you perform the following task:
680 ///
681 /// Lists information about the supported locations for this service.
682 ///
683 /// # Arguments
684 ///
685 /// * `name` - The resource that owns the locations collection, if applicable.
686 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
687 ProjectLocationListCall {
688 hub: self.hub,
689 _name: name.to_string(),
690 _page_token: Default::default(),
691 _page_size: Default::default(),
692 _filter: Default::default(),
693 _extra_location_types: Default::default(),
694 _delegate: Default::default(),
695 _additional_params: Default::default(),
696 _scopes: Default::default(),
697 }
698 }
699}
700
701// ###################
702// CallBuilders ###
703// #################
704
705/// Creates a new Endpoint in a given project and location.
706///
707/// A builder for the *locations.endpoints.create* method supported by a *project* resource.
708/// It is not used directly, but through a [`ProjectMethods`] instance.
709///
710/// # Example
711///
712/// Instantiate a resource method builder
713///
714/// ```test_harness,no_run
715/// # extern crate hyper;
716/// # extern crate hyper_rustls;
717/// # extern crate google_ids1 as ids1;
718/// use ids1::api::Endpoint;
719/// # async fn dox() {
720/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
721///
722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
723/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
724/// # .with_native_roots()
725/// # .unwrap()
726/// # .https_only()
727/// # .enable_http2()
728/// # .build();
729///
730/// # let executor = hyper_util::rt::TokioExecutor::new();
731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
732/// # secret,
733/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
734/// # yup_oauth2::client::CustomHyperClientBuilder::from(
735/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
736/// # ),
737/// # ).build().await.unwrap();
738///
739/// # let client = hyper_util::client::legacy::Client::builder(
740/// # hyper_util::rt::TokioExecutor::new()
741/// # )
742/// # .build(
743/// # hyper_rustls::HttpsConnectorBuilder::new()
744/// # .with_native_roots()
745/// # .unwrap()
746/// # .https_or_http()
747/// # .enable_http2()
748/// # .build()
749/// # );
750/// # let mut hub = IDS::new(client, auth);
751/// // As the method needs a request, you would usually fill it with the desired information
752/// // into the respective structure. Some of the parts shown here might not be applicable !
753/// // Values shown here are possibly random and not representative !
754/// let mut req = Endpoint::default();
755///
756/// // You can configure optional parameters by calling the respective setters at will, and
757/// // execute the final call using `doit()`.
758/// // Values shown here are possibly random and not representative !
759/// let result = hub.projects().locations_endpoints_create(req, "parent")
760/// .request_id("amet.")
761/// .endpoint_id("duo")
762/// .doit().await;
763/// # }
764/// ```
765pub struct ProjectLocationEndpointCreateCall<'a, C>
766where
767 C: 'a,
768{
769 hub: &'a IDS<C>,
770 _request: Endpoint,
771 _parent: String,
772 _request_id: Option<String>,
773 _endpoint_id: Option<String>,
774 _delegate: Option<&'a mut dyn common::Delegate>,
775 _additional_params: HashMap<String, String>,
776 _scopes: BTreeSet<String>,
777}
778
779impl<'a, C> common::CallBuilder for ProjectLocationEndpointCreateCall<'a, C> {}
780
781impl<'a, C> ProjectLocationEndpointCreateCall<'a, C>
782where
783 C: common::Connector,
784{
785 /// Perform the operation you have build so far.
786 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
787 use std::borrow::Cow;
788 use std::io::{Read, Seek};
789
790 use common::{url::Params, ToParts};
791 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
792
793 let mut dd = common::DefaultDelegate;
794 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
795 dlg.begin(common::MethodInfo {
796 id: "ids.projects.locations.endpoints.create",
797 http_method: hyper::Method::POST,
798 });
799
800 for &field in ["alt", "parent", "requestId", "endpointId"].iter() {
801 if self._additional_params.contains_key(field) {
802 dlg.finished(false);
803 return Err(common::Error::FieldClash(field));
804 }
805 }
806
807 let mut params = Params::with_capacity(6 + self._additional_params.len());
808 params.push("parent", self._parent);
809 if let Some(value) = self._request_id.as_ref() {
810 params.push("requestId", value);
811 }
812 if let Some(value) = self._endpoint_id.as_ref() {
813 params.push("endpointId", value);
814 }
815
816 params.extend(self._additional_params.iter());
817
818 params.push("alt", "json");
819 let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpoints";
820 if self._scopes.is_empty() {
821 self._scopes
822 .insert(Scope::CloudPlatform.as_ref().to_string());
823 }
824
825 #[allow(clippy::single_element_loop)]
826 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
827 url = params.uri_replacement(url, param_name, find_this, true);
828 }
829 {
830 let to_remove = ["parent"];
831 params.remove_params(&to_remove);
832 }
833
834 let url = params.parse_with_url(&url);
835
836 let mut json_mime_type = mime::APPLICATION_JSON;
837 let mut request_value_reader = {
838 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
839 common::remove_json_null_values(&mut value);
840 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
841 serde_json::to_writer(&mut dst, &value).unwrap();
842 dst
843 };
844 let request_size = request_value_reader
845 .seek(std::io::SeekFrom::End(0))
846 .unwrap();
847 request_value_reader
848 .seek(std::io::SeekFrom::Start(0))
849 .unwrap();
850
851 loop {
852 let token = match self
853 .hub
854 .auth
855 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
856 .await
857 {
858 Ok(token) => token,
859 Err(e) => match dlg.token(e) {
860 Ok(token) => token,
861 Err(e) => {
862 dlg.finished(false);
863 return Err(common::Error::MissingToken(e));
864 }
865 },
866 };
867 request_value_reader
868 .seek(std::io::SeekFrom::Start(0))
869 .unwrap();
870 let mut req_result = {
871 let client = &self.hub.client;
872 dlg.pre_request();
873 let mut req_builder = hyper::Request::builder()
874 .method(hyper::Method::POST)
875 .uri(url.as_str())
876 .header(USER_AGENT, self.hub._user_agent.clone());
877
878 if let Some(token) = token.as_ref() {
879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
880 }
881
882 let request = req_builder
883 .header(CONTENT_TYPE, json_mime_type.to_string())
884 .header(CONTENT_LENGTH, request_size as u64)
885 .body(common::to_body(
886 request_value_reader.get_ref().clone().into(),
887 ));
888
889 client.request(request.unwrap()).await
890 };
891
892 match req_result {
893 Err(err) => {
894 if let common::Retry::After(d) = dlg.http_error(&err) {
895 sleep(d).await;
896 continue;
897 }
898 dlg.finished(false);
899 return Err(common::Error::HttpError(err));
900 }
901 Ok(res) => {
902 let (mut parts, body) = res.into_parts();
903 let mut body = common::Body::new(body);
904 if !parts.status.is_success() {
905 let bytes = common::to_bytes(body).await.unwrap_or_default();
906 let error = serde_json::from_str(&common::to_string(&bytes));
907 let response = common::to_response(parts, bytes.into());
908
909 if let common::Retry::After(d) =
910 dlg.http_failure(&response, error.as_ref().ok())
911 {
912 sleep(d).await;
913 continue;
914 }
915
916 dlg.finished(false);
917
918 return Err(match error {
919 Ok(value) => common::Error::BadRequest(value),
920 _ => common::Error::Failure(response),
921 });
922 }
923 let response = {
924 let bytes = common::to_bytes(body).await.unwrap_or_default();
925 let encoded = common::to_string(&bytes);
926 match serde_json::from_str(&encoded) {
927 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
928 Err(error) => {
929 dlg.response_json_decode_error(&encoded, &error);
930 return Err(common::Error::JsonDecodeError(
931 encoded.to_string(),
932 error,
933 ));
934 }
935 }
936 };
937
938 dlg.finished(true);
939 return Ok(response);
940 }
941 }
942 }
943 }
944
945 ///
946 /// Sets the *request* property to the given value.
947 ///
948 /// Even though the property as already been set when instantiating this call,
949 /// we provide this method for API completeness.
950 pub fn request(mut self, new_value: Endpoint) -> ProjectLocationEndpointCreateCall<'a, C> {
951 self._request = new_value;
952 self
953 }
954 /// Required. The endpoint's parent.
955 ///
956 /// Sets the *parent* path property to the given value.
957 ///
958 /// Even though the property as already been set when instantiating this call,
959 /// we provide this method for API completeness.
960 pub fn parent(mut self, new_value: &str) -> ProjectLocationEndpointCreateCall<'a, C> {
961 self._parent = new_value.to_string();
962 self
963 }
964 /// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
965 ///
966 /// Sets the *request id* query property to the given value.
967 pub fn request_id(mut self, new_value: &str) -> ProjectLocationEndpointCreateCall<'a, C> {
968 self._request_id = Some(new_value.to_string());
969 self
970 }
971 /// Required. The endpoint identifier. This will be part of the endpoint's resource name. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. Values that do not match this pattern will trigger an INVALID_ARGUMENT error.
972 ///
973 /// Sets the *endpoint id* query property to the given value.
974 pub fn endpoint_id(mut self, new_value: &str) -> ProjectLocationEndpointCreateCall<'a, C> {
975 self._endpoint_id = Some(new_value.to_string());
976 self
977 }
978 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
979 /// while executing the actual API request.
980 ///
981 /// ````text
982 /// It should be used to handle progress information, and to implement a certain level of resilience.
983 /// ````
984 ///
985 /// Sets the *delegate* property to the given value.
986 pub fn delegate(
987 mut self,
988 new_value: &'a mut dyn common::Delegate,
989 ) -> ProjectLocationEndpointCreateCall<'a, C> {
990 self._delegate = Some(new_value);
991 self
992 }
993
994 /// Set any additional parameter of the query string used in the request.
995 /// It should be used to set parameters which are not yet available through their own
996 /// setters.
997 ///
998 /// Please note that this method must not be used to set any of the known parameters
999 /// which have their own setter method. If done anyway, the request will fail.
1000 ///
1001 /// # Additional Parameters
1002 ///
1003 /// * *$.xgafv* (query-string) - V1 error format.
1004 /// * *access_token* (query-string) - OAuth access token.
1005 /// * *alt* (query-string) - Data format for response.
1006 /// * *callback* (query-string) - JSONP
1007 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1008 /// * *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.
1009 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1010 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1011 /// * *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.
1012 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1013 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1014 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointCreateCall<'a, C>
1015 where
1016 T: AsRef<str>,
1017 {
1018 self._additional_params
1019 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1020 self
1021 }
1022
1023 /// Identifies the authorization scope for the method you are building.
1024 ///
1025 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1026 /// [`Scope::CloudPlatform`].
1027 ///
1028 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1029 /// tokens for more than one scope.
1030 ///
1031 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1032 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1033 /// sufficient, a read-write scope will do as well.
1034 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointCreateCall<'a, C>
1035 where
1036 St: AsRef<str>,
1037 {
1038 self._scopes.insert(String::from(scope.as_ref()));
1039 self
1040 }
1041 /// Identifies the authorization scope(s) for the method you are building.
1042 ///
1043 /// See [`Self::add_scope()`] for details.
1044 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointCreateCall<'a, C>
1045 where
1046 I: IntoIterator<Item = St>,
1047 St: AsRef<str>,
1048 {
1049 self._scopes
1050 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1051 self
1052 }
1053
1054 /// Removes all scopes, and no default scope will be used either.
1055 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1056 /// for details).
1057 pub fn clear_scopes(mut self) -> ProjectLocationEndpointCreateCall<'a, C> {
1058 self._scopes.clear();
1059 self
1060 }
1061}
1062
1063/// Deletes a single Endpoint.
1064///
1065/// A builder for the *locations.endpoints.delete* method supported by a *project* resource.
1066/// It is not used directly, but through a [`ProjectMethods`] instance.
1067///
1068/// # Example
1069///
1070/// Instantiate a resource method builder
1071///
1072/// ```test_harness,no_run
1073/// # extern crate hyper;
1074/// # extern crate hyper_rustls;
1075/// # extern crate google_ids1 as ids1;
1076/// # async fn dox() {
1077/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1078///
1079/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1080/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1081/// # .with_native_roots()
1082/// # .unwrap()
1083/// # .https_only()
1084/// # .enable_http2()
1085/// # .build();
1086///
1087/// # let executor = hyper_util::rt::TokioExecutor::new();
1088/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1089/// # secret,
1090/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1091/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1092/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1093/// # ),
1094/// # ).build().await.unwrap();
1095///
1096/// # let client = hyper_util::client::legacy::Client::builder(
1097/// # hyper_util::rt::TokioExecutor::new()
1098/// # )
1099/// # .build(
1100/// # hyper_rustls::HttpsConnectorBuilder::new()
1101/// # .with_native_roots()
1102/// # .unwrap()
1103/// # .https_or_http()
1104/// # .enable_http2()
1105/// # .build()
1106/// # );
1107/// # let mut hub = IDS::new(client, auth);
1108/// // You can configure optional parameters by calling the respective setters at will, and
1109/// // execute the final call using `doit()`.
1110/// // Values shown here are possibly random and not representative !
1111/// let result = hub.projects().locations_endpoints_delete("name")
1112/// .request_id("gubergren")
1113/// .doit().await;
1114/// # }
1115/// ```
1116pub struct ProjectLocationEndpointDeleteCall<'a, C>
1117where
1118 C: 'a,
1119{
1120 hub: &'a IDS<C>,
1121 _name: String,
1122 _request_id: Option<String>,
1123 _delegate: Option<&'a mut dyn common::Delegate>,
1124 _additional_params: HashMap<String, String>,
1125 _scopes: BTreeSet<String>,
1126}
1127
1128impl<'a, C> common::CallBuilder for ProjectLocationEndpointDeleteCall<'a, C> {}
1129
1130impl<'a, C> ProjectLocationEndpointDeleteCall<'a, C>
1131where
1132 C: common::Connector,
1133{
1134 /// Perform the operation you have build so far.
1135 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1136 use std::borrow::Cow;
1137 use std::io::{Read, Seek};
1138
1139 use common::{url::Params, ToParts};
1140 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1141
1142 let mut dd = common::DefaultDelegate;
1143 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1144 dlg.begin(common::MethodInfo {
1145 id: "ids.projects.locations.endpoints.delete",
1146 http_method: hyper::Method::DELETE,
1147 });
1148
1149 for &field in ["alt", "name", "requestId"].iter() {
1150 if self._additional_params.contains_key(field) {
1151 dlg.finished(false);
1152 return Err(common::Error::FieldClash(field));
1153 }
1154 }
1155
1156 let mut params = Params::with_capacity(4 + self._additional_params.len());
1157 params.push("name", self._name);
1158 if let Some(value) = self._request_id.as_ref() {
1159 params.push("requestId", value);
1160 }
1161
1162 params.extend(self._additional_params.iter());
1163
1164 params.push("alt", "json");
1165 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1166 if self._scopes.is_empty() {
1167 self._scopes
1168 .insert(Scope::CloudPlatform.as_ref().to_string());
1169 }
1170
1171 #[allow(clippy::single_element_loop)]
1172 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1173 url = params.uri_replacement(url, param_name, find_this, true);
1174 }
1175 {
1176 let to_remove = ["name"];
1177 params.remove_params(&to_remove);
1178 }
1179
1180 let url = params.parse_with_url(&url);
1181
1182 loop {
1183 let token = match self
1184 .hub
1185 .auth
1186 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1187 .await
1188 {
1189 Ok(token) => token,
1190 Err(e) => match dlg.token(e) {
1191 Ok(token) => token,
1192 Err(e) => {
1193 dlg.finished(false);
1194 return Err(common::Error::MissingToken(e));
1195 }
1196 },
1197 };
1198 let mut req_result = {
1199 let client = &self.hub.client;
1200 dlg.pre_request();
1201 let mut req_builder = hyper::Request::builder()
1202 .method(hyper::Method::DELETE)
1203 .uri(url.as_str())
1204 .header(USER_AGENT, self.hub._user_agent.clone());
1205
1206 if let Some(token) = token.as_ref() {
1207 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1208 }
1209
1210 let request = req_builder
1211 .header(CONTENT_LENGTH, 0_u64)
1212 .body(common::to_body::<String>(None));
1213
1214 client.request(request.unwrap()).await
1215 };
1216
1217 match req_result {
1218 Err(err) => {
1219 if let common::Retry::After(d) = dlg.http_error(&err) {
1220 sleep(d).await;
1221 continue;
1222 }
1223 dlg.finished(false);
1224 return Err(common::Error::HttpError(err));
1225 }
1226 Ok(res) => {
1227 let (mut parts, body) = res.into_parts();
1228 let mut body = common::Body::new(body);
1229 if !parts.status.is_success() {
1230 let bytes = common::to_bytes(body).await.unwrap_or_default();
1231 let error = serde_json::from_str(&common::to_string(&bytes));
1232 let response = common::to_response(parts, bytes.into());
1233
1234 if let common::Retry::After(d) =
1235 dlg.http_failure(&response, error.as_ref().ok())
1236 {
1237 sleep(d).await;
1238 continue;
1239 }
1240
1241 dlg.finished(false);
1242
1243 return Err(match error {
1244 Ok(value) => common::Error::BadRequest(value),
1245 _ => common::Error::Failure(response),
1246 });
1247 }
1248 let response = {
1249 let bytes = common::to_bytes(body).await.unwrap_or_default();
1250 let encoded = common::to_string(&bytes);
1251 match serde_json::from_str(&encoded) {
1252 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1253 Err(error) => {
1254 dlg.response_json_decode_error(&encoded, &error);
1255 return Err(common::Error::JsonDecodeError(
1256 encoded.to_string(),
1257 error,
1258 ));
1259 }
1260 }
1261 };
1262
1263 dlg.finished(true);
1264 return Ok(response);
1265 }
1266 }
1267 }
1268 }
1269
1270 /// Required. The name of the endpoint to delete.
1271 ///
1272 /// Sets the *name* path property to the given value.
1273 ///
1274 /// Even though the property as already been set when instantiating this call,
1275 /// we provide this method for API completeness.
1276 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointDeleteCall<'a, C> {
1277 self._name = new_value.to_string();
1278 self
1279 }
1280 /// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
1281 ///
1282 /// Sets the *request id* query property to the given value.
1283 pub fn request_id(mut self, new_value: &str) -> ProjectLocationEndpointDeleteCall<'a, C> {
1284 self._request_id = Some(new_value.to_string());
1285 self
1286 }
1287 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1288 /// while executing the actual API request.
1289 ///
1290 /// ````text
1291 /// It should be used to handle progress information, and to implement a certain level of resilience.
1292 /// ````
1293 ///
1294 /// Sets the *delegate* property to the given value.
1295 pub fn delegate(
1296 mut self,
1297 new_value: &'a mut dyn common::Delegate,
1298 ) -> ProjectLocationEndpointDeleteCall<'a, C> {
1299 self._delegate = Some(new_value);
1300 self
1301 }
1302
1303 /// Set any additional parameter of the query string used in the request.
1304 /// It should be used to set parameters which are not yet available through their own
1305 /// setters.
1306 ///
1307 /// Please note that this method must not be used to set any of the known parameters
1308 /// which have their own setter method. If done anyway, the request will fail.
1309 ///
1310 /// # Additional Parameters
1311 ///
1312 /// * *$.xgafv* (query-string) - V1 error format.
1313 /// * *access_token* (query-string) - OAuth access token.
1314 /// * *alt* (query-string) - Data format for response.
1315 /// * *callback* (query-string) - JSONP
1316 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1317 /// * *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.
1318 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1319 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1320 /// * *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.
1321 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1322 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1323 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointDeleteCall<'a, C>
1324 where
1325 T: AsRef<str>,
1326 {
1327 self._additional_params
1328 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1329 self
1330 }
1331
1332 /// Identifies the authorization scope for the method you are building.
1333 ///
1334 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1335 /// [`Scope::CloudPlatform`].
1336 ///
1337 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1338 /// tokens for more than one scope.
1339 ///
1340 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1341 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1342 /// sufficient, a read-write scope will do as well.
1343 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointDeleteCall<'a, C>
1344 where
1345 St: AsRef<str>,
1346 {
1347 self._scopes.insert(String::from(scope.as_ref()));
1348 self
1349 }
1350 /// Identifies the authorization scope(s) for the method you are building.
1351 ///
1352 /// See [`Self::add_scope()`] for details.
1353 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointDeleteCall<'a, C>
1354 where
1355 I: IntoIterator<Item = St>,
1356 St: AsRef<str>,
1357 {
1358 self._scopes
1359 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1360 self
1361 }
1362
1363 /// Removes all scopes, and no default scope will be used either.
1364 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1365 /// for details).
1366 pub fn clear_scopes(mut self) -> ProjectLocationEndpointDeleteCall<'a, C> {
1367 self._scopes.clear();
1368 self
1369 }
1370}
1371
1372/// Gets details of a single Endpoint.
1373///
1374/// A builder for the *locations.endpoints.get* method supported by a *project* resource.
1375/// It is not used directly, but through a [`ProjectMethods`] instance.
1376///
1377/// # Example
1378///
1379/// Instantiate a resource method builder
1380///
1381/// ```test_harness,no_run
1382/// # extern crate hyper;
1383/// # extern crate hyper_rustls;
1384/// # extern crate google_ids1 as ids1;
1385/// # async fn dox() {
1386/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1387///
1388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1389/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1390/// # .with_native_roots()
1391/// # .unwrap()
1392/// # .https_only()
1393/// # .enable_http2()
1394/// # .build();
1395///
1396/// # let executor = hyper_util::rt::TokioExecutor::new();
1397/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1398/// # secret,
1399/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1400/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1401/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1402/// # ),
1403/// # ).build().await.unwrap();
1404///
1405/// # let client = hyper_util::client::legacy::Client::builder(
1406/// # hyper_util::rt::TokioExecutor::new()
1407/// # )
1408/// # .build(
1409/// # hyper_rustls::HttpsConnectorBuilder::new()
1410/// # .with_native_roots()
1411/// # .unwrap()
1412/// # .https_or_http()
1413/// # .enable_http2()
1414/// # .build()
1415/// # );
1416/// # let mut hub = IDS::new(client, auth);
1417/// // You can configure optional parameters by calling the respective setters at will, and
1418/// // execute the final call using `doit()`.
1419/// // Values shown here are possibly random and not representative !
1420/// let result = hub.projects().locations_endpoints_get("name")
1421/// .doit().await;
1422/// # }
1423/// ```
1424pub struct ProjectLocationEndpointGetCall<'a, C>
1425where
1426 C: 'a,
1427{
1428 hub: &'a IDS<C>,
1429 _name: String,
1430 _delegate: Option<&'a mut dyn common::Delegate>,
1431 _additional_params: HashMap<String, String>,
1432 _scopes: BTreeSet<String>,
1433}
1434
1435impl<'a, C> common::CallBuilder for ProjectLocationEndpointGetCall<'a, C> {}
1436
1437impl<'a, C> ProjectLocationEndpointGetCall<'a, C>
1438where
1439 C: common::Connector,
1440{
1441 /// Perform the operation you have build so far.
1442 pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> {
1443 use std::borrow::Cow;
1444 use std::io::{Read, Seek};
1445
1446 use common::{url::Params, ToParts};
1447 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1448
1449 let mut dd = common::DefaultDelegate;
1450 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1451 dlg.begin(common::MethodInfo {
1452 id: "ids.projects.locations.endpoints.get",
1453 http_method: hyper::Method::GET,
1454 });
1455
1456 for &field in ["alt", "name"].iter() {
1457 if self._additional_params.contains_key(field) {
1458 dlg.finished(false);
1459 return Err(common::Error::FieldClash(field));
1460 }
1461 }
1462
1463 let mut params = Params::with_capacity(3 + self._additional_params.len());
1464 params.push("name", self._name);
1465
1466 params.extend(self._additional_params.iter());
1467
1468 params.push("alt", "json");
1469 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1470 if self._scopes.is_empty() {
1471 self._scopes
1472 .insert(Scope::CloudPlatform.as_ref().to_string());
1473 }
1474
1475 #[allow(clippy::single_element_loop)]
1476 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1477 url = params.uri_replacement(url, param_name, find_this, true);
1478 }
1479 {
1480 let to_remove = ["name"];
1481 params.remove_params(&to_remove);
1482 }
1483
1484 let url = params.parse_with_url(&url);
1485
1486 loop {
1487 let token = match self
1488 .hub
1489 .auth
1490 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1491 .await
1492 {
1493 Ok(token) => token,
1494 Err(e) => match dlg.token(e) {
1495 Ok(token) => token,
1496 Err(e) => {
1497 dlg.finished(false);
1498 return Err(common::Error::MissingToken(e));
1499 }
1500 },
1501 };
1502 let mut req_result = {
1503 let client = &self.hub.client;
1504 dlg.pre_request();
1505 let mut req_builder = hyper::Request::builder()
1506 .method(hyper::Method::GET)
1507 .uri(url.as_str())
1508 .header(USER_AGENT, self.hub._user_agent.clone());
1509
1510 if let Some(token) = token.as_ref() {
1511 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1512 }
1513
1514 let request = req_builder
1515 .header(CONTENT_LENGTH, 0_u64)
1516 .body(common::to_body::<String>(None));
1517
1518 client.request(request.unwrap()).await
1519 };
1520
1521 match req_result {
1522 Err(err) => {
1523 if let common::Retry::After(d) = dlg.http_error(&err) {
1524 sleep(d).await;
1525 continue;
1526 }
1527 dlg.finished(false);
1528 return Err(common::Error::HttpError(err));
1529 }
1530 Ok(res) => {
1531 let (mut parts, body) = res.into_parts();
1532 let mut body = common::Body::new(body);
1533 if !parts.status.is_success() {
1534 let bytes = common::to_bytes(body).await.unwrap_or_default();
1535 let error = serde_json::from_str(&common::to_string(&bytes));
1536 let response = common::to_response(parts, bytes.into());
1537
1538 if let common::Retry::After(d) =
1539 dlg.http_failure(&response, error.as_ref().ok())
1540 {
1541 sleep(d).await;
1542 continue;
1543 }
1544
1545 dlg.finished(false);
1546
1547 return Err(match error {
1548 Ok(value) => common::Error::BadRequest(value),
1549 _ => common::Error::Failure(response),
1550 });
1551 }
1552 let response = {
1553 let bytes = common::to_bytes(body).await.unwrap_or_default();
1554 let encoded = common::to_string(&bytes);
1555 match serde_json::from_str(&encoded) {
1556 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1557 Err(error) => {
1558 dlg.response_json_decode_error(&encoded, &error);
1559 return Err(common::Error::JsonDecodeError(
1560 encoded.to_string(),
1561 error,
1562 ));
1563 }
1564 }
1565 };
1566
1567 dlg.finished(true);
1568 return Ok(response);
1569 }
1570 }
1571 }
1572 }
1573
1574 /// Required. The name of the endpoint to retrieve. Format: projects/{project}/locations/{location}/endpoints/{endpoint}
1575 ///
1576 /// Sets the *name* path property to the given value.
1577 ///
1578 /// Even though the property as already been set when instantiating this call,
1579 /// we provide this method for API completeness.
1580 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointGetCall<'a, C> {
1581 self._name = new_value.to_string();
1582 self
1583 }
1584 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1585 /// while executing the actual API request.
1586 ///
1587 /// ````text
1588 /// It should be used to handle progress information, and to implement a certain level of resilience.
1589 /// ````
1590 ///
1591 /// Sets the *delegate* property to the given value.
1592 pub fn delegate(
1593 mut self,
1594 new_value: &'a mut dyn common::Delegate,
1595 ) -> ProjectLocationEndpointGetCall<'a, C> {
1596 self._delegate = Some(new_value);
1597 self
1598 }
1599
1600 /// Set any additional parameter of the query string used in the request.
1601 /// It should be used to set parameters which are not yet available through their own
1602 /// setters.
1603 ///
1604 /// Please note that this method must not be used to set any of the known parameters
1605 /// which have their own setter method. If done anyway, the request will fail.
1606 ///
1607 /// # Additional Parameters
1608 ///
1609 /// * *$.xgafv* (query-string) - V1 error format.
1610 /// * *access_token* (query-string) - OAuth access token.
1611 /// * *alt* (query-string) - Data format for response.
1612 /// * *callback* (query-string) - JSONP
1613 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1614 /// * *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.
1615 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1616 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1617 /// * *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.
1618 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1619 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1620 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointGetCall<'a, C>
1621 where
1622 T: AsRef<str>,
1623 {
1624 self._additional_params
1625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1626 self
1627 }
1628
1629 /// Identifies the authorization scope for the method you are building.
1630 ///
1631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1632 /// [`Scope::CloudPlatform`].
1633 ///
1634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1635 /// tokens for more than one scope.
1636 ///
1637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1639 /// sufficient, a read-write scope will do as well.
1640 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointGetCall<'a, C>
1641 where
1642 St: AsRef<str>,
1643 {
1644 self._scopes.insert(String::from(scope.as_ref()));
1645 self
1646 }
1647 /// Identifies the authorization scope(s) for the method you are building.
1648 ///
1649 /// See [`Self::add_scope()`] for details.
1650 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointGetCall<'a, C>
1651 where
1652 I: IntoIterator<Item = St>,
1653 St: AsRef<str>,
1654 {
1655 self._scopes
1656 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1657 self
1658 }
1659
1660 /// Removes all scopes, and no default scope will be used either.
1661 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1662 /// for details).
1663 pub fn clear_scopes(mut self) -> ProjectLocationEndpointGetCall<'a, C> {
1664 self._scopes.clear();
1665 self
1666 }
1667}
1668
1669/// Lists Endpoints in a given project and location.
1670///
1671/// A builder for the *locations.endpoints.list* method supported by a *project* resource.
1672/// It is not used directly, but through a [`ProjectMethods`] instance.
1673///
1674/// # Example
1675///
1676/// Instantiate a resource method builder
1677///
1678/// ```test_harness,no_run
1679/// # extern crate hyper;
1680/// # extern crate hyper_rustls;
1681/// # extern crate google_ids1 as ids1;
1682/// # async fn dox() {
1683/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1684///
1685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1686/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1687/// # .with_native_roots()
1688/// # .unwrap()
1689/// # .https_only()
1690/// # .enable_http2()
1691/// # .build();
1692///
1693/// # let executor = hyper_util::rt::TokioExecutor::new();
1694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1695/// # secret,
1696/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1697/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1698/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1699/// # ),
1700/// # ).build().await.unwrap();
1701///
1702/// # let client = hyper_util::client::legacy::Client::builder(
1703/// # hyper_util::rt::TokioExecutor::new()
1704/// # )
1705/// # .build(
1706/// # hyper_rustls::HttpsConnectorBuilder::new()
1707/// # .with_native_roots()
1708/// # .unwrap()
1709/// # .https_or_http()
1710/// # .enable_http2()
1711/// # .build()
1712/// # );
1713/// # let mut hub = IDS::new(client, auth);
1714/// // You can configure optional parameters by calling the respective setters at will, and
1715/// // execute the final call using `doit()`.
1716/// // Values shown here are possibly random and not representative !
1717/// let result = hub.projects().locations_endpoints_list("parent")
1718/// .page_token("eos")
1719/// .page_size(-4)
1720/// .order_by("ea")
1721/// .filter("ipsum")
1722/// .doit().await;
1723/// # }
1724/// ```
1725pub struct ProjectLocationEndpointListCall<'a, C>
1726where
1727 C: 'a,
1728{
1729 hub: &'a IDS<C>,
1730 _parent: String,
1731 _page_token: Option<String>,
1732 _page_size: Option<i32>,
1733 _order_by: Option<String>,
1734 _filter: Option<String>,
1735 _delegate: Option<&'a mut dyn common::Delegate>,
1736 _additional_params: HashMap<String, String>,
1737 _scopes: BTreeSet<String>,
1738}
1739
1740impl<'a, C> common::CallBuilder for ProjectLocationEndpointListCall<'a, C> {}
1741
1742impl<'a, C> ProjectLocationEndpointListCall<'a, C>
1743where
1744 C: common::Connector,
1745{
1746 /// Perform the operation you have build so far.
1747 pub async fn doit(mut self) -> common::Result<(common::Response, ListEndpointsResponse)> {
1748 use std::borrow::Cow;
1749 use std::io::{Read, Seek};
1750
1751 use common::{url::Params, ToParts};
1752 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1753
1754 let mut dd = common::DefaultDelegate;
1755 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1756 dlg.begin(common::MethodInfo {
1757 id: "ids.projects.locations.endpoints.list",
1758 http_method: hyper::Method::GET,
1759 });
1760
1761 for &field in [
1762 "alt",
1763 "parent",
1764 "pageToken",
1765 "pageSize",
1766 "orderBy",
1767 "filter",
1768 ]
1769 .iter()
1770 {
1771 if self._additional_params.contains_key(field) {
1772 dlg.finished(false);
1773 return Err(common::Error::FieldClash(field));
1774 }
1775 }
1776
1777 let mut params = Params::with_capacity(7 + self._additional_params.len());
1778 params.push("parent", self._parent);
1779 if let Some(value) = self._page_token.as_ref() {
1780 params.push("pageToken", value);
1781 }
1782 if let Some(value) = self._page_size.as_ref() {
1783 params.push("pageSize", value.to_string());
1784 }
1785 if let Some(value) = self._order_by.as_ref() {
1786 params.push("orderBy", value);
1787 }
1788 if let Some(value) = self._filter.as_ref() {
1789 params.push("filter", value);
1790 }
1791
1792 params.extend(self._additional_params.iter());
1793
1794 params.push("alt", "json");
1795 let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpoints";
1796 if self._scopes.is_empty() {
1797 self._scopes
1798 .insert(Scope::CloudPlatform.as_ref().to_string());
1799 }
1800
1801 #[allow(clippy::single_element_loop)]
1802 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1803 url = params.uri_replacement(url, param_name, find_this, true);
1804 }
1805 {
1806 let to_remove = ["parent"];
1807 params.remove_params(&to_remove);
1808 }
1809
1810 let url = params.parse_with_url(&url);
1811
1812 loop {
1813 let token = match self
1814 .hub
1815 .auth
1816 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1817 .await
1818 {
1819 Ok(token) => token,
1820 Err(e) => match dlg.token(e) {
1821 Ok(token) => token,
1822 Err(e) => {
1823 dlg.finished(false);
1824 return Err(common::Error::MissingToken(e));
1825 }
1826 },
1827 };
1828 let mut req_result = {
1829 let client = &self.hub.client;
1830 dlg.pre_request();
1831 let mut req_builder = hyper::Request::builder()
1832 .method(hyper::Method::GET)
1833 .uri(url.as_str())
1834 .header(USER_AGENT, self.hub._user_agent.clone());
1835
1836 if let Some(token) = token.as_ref() {
1837 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1838 }
1839
1840 let request = req_builder
1841 .header(CONTENT_LENGTH, 0_u64)
1842 .body(common::to_body::<String>(None));
1843
1844 client.request(request.unwrap()).await
1845 };
1846
1847 match req_result {
1848 Err(err) => {
1849 if let common::Retry::After(d) = dlg.http_error(&err) {
1850 sleep(d).await;
1851 continue;
1852 }
1853 dlg.finished(false);
1854 return Err(common::Error::HttpError(err));
1855 }
1856 Ok(res) => {
1857 let (mut parts, body) = res.into_parts();
1858 let mut body = common::Body::new(body);
1859 if !parts.status.is_success() {
1860 let bytes = common::to_bytes(body).await.unwrap_or_default();
1861 let error = serde_json::from_str(&common::to_string(&bytes));
1862 let response = common::to_response(parts, bytes.into());
1863
1864 if let common::Retry::After(d) =
1865 dlg.http_failure(&response, error.as_ref().ok())
1866 {
1867 sleep(d).await;
1868 continue;
1869 }
1870
1871 dlg.finished(false);
1872
1873 return Err(match error {
1874 Ok(value) => common::Error::BadRequest(value),
1875 _ => common::Error::Failure(response),
1876 });
1877 }
1878 let response = {
1879 let bytes = common::to_bytes(body).await.unwrap_or_default();
1880 let encoded = common::to_string(&bytes);
1881 match serde_json::from_str(&encoded) {
1882 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1883 Err(error) => {
1884 dlg.response_json_decode_error(&encoded, &error);
1885 return Err(common::Error::JsonDecodeError(
1886 encoded.to_string(),
1887 error,
1888 ));
1889 }
1890 }
1891 };
1892
1893 dlg.finished(true);
1894 return Ok(response);
1895 }
1896 }
1897 }
1898 }
1899
1900 /// Required. The parent, which owns this collection of endpoints.
1901 ///
1902 /// Sets the *parent* path property to the given value.
1903 ///
1904 /// Even though the property as already been set when instantiating this call,
1905 /// we provide this method for API completeness.
1906 pub fn parent(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
1907 self._parent = new_value.to_string();
1908 self
1909 }
1910 /// Optional. A page token, received from a previous `ListEndpoints` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListEndpoints` must match the call that provided the page token.
1911 ///
1912 /// Sets the *page token* query property to the given value.
1913 pub fn page_token(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
1914 self._page_token = Some(new_value.to_string());
1915 self
1916 }
1917 /// Optional. The maximum number of endpoints to return. The service may return fewer than this value.
1918 ///
1919 /// Sets the *page size* query property to the given value.
1920 pub fn page_size(mut self, new_value: i32) -> ProjectLocationEndpointListCall<'a, C> {
1921 self._page_size = Some(new_value);
1922 self
1923 }
1924 /// Optional. One or more fields to compare and use to sort the output. See https://google.aip.dev/132#ordering.
1925 ///
1926 /// Sets the *order by* query property to the given value.
1927 pub fn order_by(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
1928 self._order_by = Some(new_value.to_string());
1929 self
1930 }
1931 /// Optional. The filter expression, following the syntax outlined in https://google.aip.dev/160.
1932 ///
1933 /// Sets the *filter* query property to the given value.
1934 pub fn filter(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
1935 self._filter = Some(new_value.to_string());
1936 self
1937 }
1938 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1939 /// while executing the actual API request.
1940 ///
1941 /// ````text
1942 /// It should be used to handle progress information, and to implement a certain level of resilience.
1943 /// ````
1944 ///
1945 /// Sets the *delegate* property to the given value.
1946 pub fn delegate(
1947 mut self,
1948 new_value: &'a mut dyn common::Delegate,
1949 ) -> ProjectLocationEndpointListCall<'a, C> {
1950 self._delegate = Some(new_value);
1951 self
1952 }
1953
1954 /// Set any additional parameter of the query string used in the request.
1955 /// It should be used to set parameters which are not yet available through their own
1956 /// setters.
1957 ///
1958 /// Please note that this method must not be used to set any of the known parameters
1959 /// which have their own setter method. If done anyway, the request will fail.
1960 ///
1961 /// # Additional Parameters
1962 ///
1963 /// * *$.xgafv* (query-string) - V1 error format.
1964 /// * *access_token* (query-string) - OAuth access token.
1965 /// * *alt* (query-string) - Data format for response.
1966 /// * *callback* (query-string) - JSONP
1967 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1968 /// * *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.
1969 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1970 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1971 /// * *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.
1972 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1973 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1974 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointListCall<'a, C>
1975 where
1976 T: AsRef<str>,
1977 {
1978 self._additional_params
1979 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1980 self
1981 }
1982
1983 /// Identifies the authorization scope for the method you are building.
1984 ///
1985 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1986 /// [`Scope::CloudPlatform`].
1987 ///
1988 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1989 /// tokens for more than one scope.
1990 ///
1991 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1992 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1993 /// sufficient, a read-write scope will do as well.
1994 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointListCall<'a, C>
1995 where
1996 St: AsRef<str>,
1997 {
1998 self._scopes.insert(String::from(scope.as_ref()));
1999 self
2000 }
2001 /// Identifies the authorization scope(s) for the method you are building.
2002 ///
2003 /// See [`Self::add_scope()`] for details.
2004 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointListCall<'a, C>
2005 where
2006 I: IntoIterator<Item = St>,
2007 St: AsRef<str>,
2008 {
2009 self._scopes
2010 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2011 self
2012 }
2013
2014 /// Removes all scopes, and no default scope will be used either.
2015 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2016 /// for details).
2017 pub fn clear_scopes(mut self) -> ProjectLocationEndpointListCall<'a, C> {
2018 self._scopes.clear();
2019 self
2020 }
2021}
2022
2023/// Updates the parameters of a single Endpoint.
2024///
2025/// A builder for the *locations.endpoints.patch* method supported by a *project* resource.
2026/// It is not used directly, but through a [`ProjectMethods`] instance.
2027///
2028/// # Example
2029///
2030/// Instantiate a resource method builder
2031///
2032/// ```test_harness,no_run
2033/// # extern crate hyper;
2034/// # extern crate hyper_rustls;
2035/// # extern crate google_ids1 as ids1;
2036/// use ids1::api::Endpoint;
2037/// # async fn dox() {
2038/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2039///
2040/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2041/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2042/// # .with_native_roots()
2043/// # .unwrap()
2044/// # .https_only()
2045/// # .enable_http2()
2046/// # .build();
2047///
2048/// # let executor = hyper_util::rt::TokioExecutor::new();
2049/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2050/// # secret,
2051/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2052/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2053/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2054/// # ),
2055/// # ).build().await.unwrap();
2056///
2057/// # let client = hyper_util::client::legacy::Client::builder(
2058/// # hyper_util::rt::TokioExecutor::new()
2059/// # )
2060/// # .build(
2061/// # hyper_rustls::HttpsConnectorBuilder::new()
2062/// # .with_native_roots()
2063/// # .unwrap()
2064/// # .https_or_http()
2065/// # .enable_http2()
2066/// # .build()
2067/// # );
2068/// # let mut hub = IDS::new(client, auth);
2069/// // As the method needs a request, you would usually fill it with the desired information
2070/// // into the respective structure. Some of the parts shown here might not be applicable !
2071/// // Values shown here are possibly random and not representative !
2072/// let mut req = Endpoint::default();
2073///
2074/// // You can configure optional parameters by calling the respective setters at will, and
2075/// // execute the final call using `doit()`.
2076/// // Values shown here are possibly random and not representative !
2077/// let result = hub.projects().locations_endpoints_patch(req, "name")
2078/// .update_mask(FieldMask::new::<&str>(&[]))
2079/// .request_id("amet")
2080/// .doit().await;
2081/// # }
2082/// ```
2083pub struct ProjectLocationEndpointPatchCall<'a, C>
2084where
2085 C: 'a,
2086{
2087 hub: &'a IDS<C>,
2088 _request: Endpoint,
2089 _name: String,
2090 _update_mask: Option<common::FieldMask>,
2091 _request_id: Option<String>,
2092 _delegate: Option<&'a mut dyn common::Delegate>,
2093 _additional_params: HashMap<String, String>,
2094 _scopes: BTreeSet<String>,
2095}
2096
2097impl<'a, C> common::CallBuilder for ProjectLocationEndpointPatchCall<'a, C> {}
2098
2099impl<'a, C> ProjectLocationEndpointPatchCall<'a, C>
2100where
2101 C: common::Connector,
2102{
2103 /// Perform the operation you have build so far.
2104 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2105 use std::borrow::Cow;
2106 use std::io::{Read, Seek};
2107
2108 use common::{url::Params, ToParts};
2109 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2110
2111 let mut dd = common::DefaultDelegate;
2112 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2113 dlg.begin(common::MethodInfo {
2114 id: "ids.projects.locations.endpoints.patch",
2115 http_method: hyper::Method::PATCH,
2116 });
2117
2118 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
2119 if self._additional_params.contains_key(field) {
2120 dlg.finished(false);
2121 return Err(common::Error::FieldClash(field));
2122 }
2123 }
2124
2125 let mut params = Params::with_capacity(6 + self._additional_params.len());
2126 params.push("name", self._name);
2127 if let Some(value) = self._update_mask.as_ref() {
2128 params.push("updateMask", value.to_string());
2129 }
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() + "v1/{+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 let mut json_mime_type = mime::APPLICATION_JSON;
2155 let mut request_value_reader = {
2156 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2157 common::remove_json_null_values(&mut value);
2158 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2159 serde_json::to_writer(&mut dst, &value).unwrap();
2160 dst
2161 };
2162 let request_size = request_value_reader
2163 .seek(std::io::SeekFrom::End(0))
2164 .unwrap();
2165 request_value_reader
2166 .seek(std::io::SeekFrom::Start(0))
2167 .unwrap();
2168
2169 loop {
2170 let token = match self
2171 .hub
2172 .auth
2173 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2174 .await
2175 {
2176 Ok(token) => token,
2177 Err(e) => match dlg.token(e) {
2178 Ok(token) => token,
2179 Err(e) => {
2180 dlg.finished(false);
2181 return Err(common::Error::MissingToken(e));
2182 }
2183 },
2184 };
2185 request_value_reader
2186 .seek(std::io::SeekFrom::Start(0))
2187 .unwrap();
2188 let mut req_result = {
2189 let client = &self.hub.client;
2190 dlg.pre_request();
2191 let mut req_builder = hyper::Request::builder()
2192 .method(hyper::Method::PATCH)
2193 .uri(url.as_str())
2194 .header(USER_AGENT, self.hub._user_agent.clone());
2195
2196 if let Some(token) = token.as_ref() {
2197 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2198 }
2199
2200 let request = req_builder
2201 .header(CONTENT_TYPE, json_mime_type.to_string())
2202 .header(CONTENT_LENGTH, request_size as u64)
2203 .body(common::to_body(
2204 request_value_reader.get_ref().clone().into(),
2205 ));
2206
2207 client.request(request.unwrap()).await
2208 };
2209
2210 match req_result {
2211 Err(err) => {
2212 if let common::Retry::After(d) = dlg.http_error(&err) {
2213 sleep(d).await;
2214 continue;
2215 }
2216 dlg.finished(false);
2217 return Err(common::Error::HttpError(err));
2218 }
2219 Ok(res) => {
2220 let (mut parts, body) = res.into_parts();
2221 let mut body = common::Body::new(body);
2222 if !parts.status.is_success() {
2223 let bytes = common::to_bytes(body).await.unwrap_or_default();
2224 let error = serde_json::from_str(&common::to_string(&bytes));
2225 let response = common::to_response(parts, bytes.into());
2226
2227 if let common::Retry::After(d) =
2228 dlg.http_failure(&response, error.as_ref().ok())
2229 {
2230 sleep(d).await;
2231 continue;
2232 }
2233
2234 dlg.finished(false);
2235
2236 return Err(match error {
2237 Ok(value) => common::Error::BadRequest(value),
2238 _ => common::Error::Failure(response),
2239 });
2240 }
2241 let response = {
2242 let bytes = common::to_bytes(body).await.unwrap_or_default();
2243 let encoded = common::to_string(&bytes);
2244 match serde_json::from_str(&encoded) {
2245 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2246 Err(error) => {
2247 dlg.response_json_decode_error(&encoded, &error);
2248 return Err(common::Error::JsonDecodeError(
2249 encoded.to_string(),
2250 error,
2251 ));
2252 }
2253 }
2254 };
2255
2256 dlg.finished(true);
2257 return Ok(response);
2258 }
2259 }
2260 }
2261 }
2262
2263 ///
2264 /// Sets the *request* property to the given value.
2265 ///
2266 /// Even though the property as already been set when instantiating this call,
2267 /// we provide this method for API completeness.
2268 pub fn request(mut self, new_value: Endpoint) -> ProjectLocationEndpointPatchCall<'a, C> {
2269 self._request = new_value;
2270 self
2271 }
2272 /// Output only. The name of the endpoint.
2273 ///
2274 /// Sets the *name* path property to the given value.
2275 ///
2276 /// Even though the property as already been set when instantiating this call,
2277 /// we provide this method for API completeness.
2278 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointPatchCall<'a, C> {
2279 self._name = new_value.to_string();
2280 self
2281 }
2282 /// Field mask is used to specify the fields to be overwritten in the Endpoint resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten.
2283 ///
2284 /// Sets the *update mask* query property to the given value.
2285 pub fn update_mask(
2286 mut self,
2287 new_value: common::FieldMask,
2288 ) -> ProjectLocationEndpointPatchCall<'a, C> {
2289 self._update_mask = Some(new_value);
2290 self
2291 }
2292 /// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
2293 ///
2294 /// Sets the *request id* query property to the given value.
2295 pub fn request_id(mut self, new_value: &str) -> ProjectLocationEndpointPatchCall<'a, C> {
2296 self._request_id = Some(new_value.to_string());
2297 self
2298 }
2299 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2300 /// while executing the actual API request.
2301 ///
2302 /// ````text
2303 /// It should be used to handle progress information, and to implement a certain level of resilience.
2304 /// ````
2305 ///
2306 /// Sets the *delegate* property to the given value.
2307 pub fn delegate(
2308 mut self,
2309 new_value: &'a mut dyn common::Delegate,
2310 ) -> ProjectLocationEndpointPatchCall<'a, C> {
2311 self._delegate = Some(new_value);
2312 self
2313 }
2314
2315 /// Set any additional parameter of the query string used in the request.
2316 /// It should be used to set parameters which are not yet available through their own
2317 /// setters.
2318 ///
2319 /// Please note that this method must not be used to set any of the known parameters
2320 /// which have their own setter method. If done anyway, the request will fail.
2321 ///
2322 /// # Additional Parameters
2323 ///
2324 /// * *$.xgafv* (query-string) - V1 error format.
2325 /// * *access_token* (query-string) - OAuth access token.
2326 /// * *alt* (query-string) - Data format for response.
2327 /// * *callback* (query-string) - JSONP
2328 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2329 /// * *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.
2330 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2331 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2332 /// * *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.
2333 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2334 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2335 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPatchCall<'a, C>
2336 where
2337 T: AsRef<str>,
2338 {
2339 self._additional_params
2340 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2341 self
2342 }
2343
2344 /// Identifies the authorization scope for the method you are building.
2345 ///
2346 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2347 /// [`Scope::CloudPlatform`].
2348 ///
2349 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2350 /// tokens for more than one scope.
2351 ///
2352 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2353 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2354 /// sufficient, a read-write scope will do as well.
2355 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPatchCall<'a, C>
2356 where
2357 St: AsRef<str>,
2358 {
2359 self._scopes.insert(String::from(scope.as_ref()));
2360 self
2361 }
2362 /// Identifies the authorization scope(s) for the method you are building.
2363 ///
2364 /// See [`Self::add_scope()`] for details.
2365 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPatchCall<'a, C>
2366 where
2367 I: IntoIterator<Item = St>,
2368 St: AsRef<str>,
2369 {
2370 self._scopes
2371 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2372 self
2373 }
2374
2375 /// Removes all scopes, and no default scope will be used either.
2376 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2377 /// for details).
2378 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPatchCall<'a, C> {
2379 self._scopes.clear();
2380 self
2381 }
2382}
2383
2384/// 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`.
2385///
2386/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
2387/// It is not used directly, but through a [`ProjectMethods`] instance.
2388///
2389/// # Example
2390///
2391/// Instantiate a resource method builder
2392///
2393/// ```test_harness,no_run
2394/// # extern crate hyper;
2395/// # extern crate hyper_rustls;
2396/// # extern crate google_ids1 as ids1;
2397/// use ids1::api::CancelOperationRequest;
2398/// # async fn dox() {
2399/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2400///
2401/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2402/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2403/// # .with_native_roots()
2404/// # .unwrap()
2405/// # .https_only()
2406/// # .enable_http2()
2407/// # .build();
2408///
2409/// # let executor = hyper_util::rt::TokioExecutor::new();
2410/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2411/// # secret,
2412/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2413/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2414/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2415/// # ),
2416/// # ).build().await.unwrap();
2417///
2418/// # let client = hyper_util::client::legacy::Client::builder(
2419/// # hyper_util::rt::TokioExecutor::new()
2420/// # )
2421/// # .build(
2422/// # hyper_rustls::HttpsConnectorBuilder::new()
2423/// # .with_native_roots()
2424/// # .unwrap()
2425/// # .https_or_http()
2426/// # .enable_http2()
2427/// # .build()
2428/// # );
2429/// # let mut hub = IDS::new(client, auth);
2430/// // As the method needs a request, you would usually fill it with the desired information
2431/// // into the respective structure. Some of the parts shown here might not be applicable !
2432/// // Values shown here are possibly random and not representative !
2433/// let mut req = CancelOperationRequest::default();
2434///
2435/// // You can configure optional parameters by calling the respective setters at will, and
2436/// // execute the final call using `doit()`.
2437/// // Values shown here are possibly random and not representative !
2438/// let result = hub.projects().locations_operations_cancel(req, "name")
2439/// .doit().await;
2440/// # }
2441/// ```
2442pub struct ProjectLocationOperationCancelCall<'a, C>
2443where
2444 C: 'a,
2445{
2446 hub: &'a IDS<C>,
2447 _request: CancelOperationRequest,
2448 _name: String,
2449 _delegate: Option<&'a mut dyn common::Delegate>,
2450 _additional_params: HashMap<String, String>,
2451 _scopes: BTreeSet<String>,
2452}
2453
2454impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
2455
2456impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
2457where
2458 C: common::Connector,
2459{
2460 /// Perform the operation you have build so far.
2461 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2462 use std::borrow::Cow;
2463 use std::io::{Read, Seek};
2464
2465 use common::{url::Params, ToParts};
2466 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2467
2468 let mut dd = common::DefaultDelegate;
2469 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2470 dlg.begin(common::MethodInfo {
2471 id: "ids.projects.locations.operations.cancel",
2472 http_method: hyper::Method::POST,
2473 });
2474
2475 for &field in ["alt", "name"].iter() {
2476 if self._additional_params.contains_key(field) {
2477 dlg.finished(false);
2478 return Err(common::Error::FieldClash(field));
2479 }
2480 }
2481
2482 let mut params = Params::with_capacity(4 + self._additional_params.len());
2483 params.push("name", self._name);
2484
2485 params.extend(self._additional_params.iter());
2486
2487 params.push("alt", "json");
2488 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
2489 if self._scopes.is_empty() {
2490 self._scopes
2491 .insert(Scope::CloudPlatform.as_ref().to_string());
2492 }
2493
2494 #[allow(clippy::single_element_loop)]
2495 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2496 url = params.uri_replacement(url, param_name, find_this, true);
2497 }
2498 {
2499 let to_remove = ["name"];
2500 params.remove_params(&to_remove);
2501 }
2502
2503 let url = params.parse_with_url(&url);
2504
2505 let mut json_mime_type = mime::APPLICATION_JSON;
2506 let mut request_value_reader = {
2507 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2508 common::remove_json_null_values(&mut value);
2509 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2510 serde_json::to_writer(&mut dst, &value).unwrap();
2511 dst
2512 };
2513 let request_size = request_value_reader
2514 .seek(std::io::SeekFrom::End(0))
2515 .unwrap();
2516 request_value_reader
2517 .seek(std::io::SeekFrom::Start(0))
2518 .unwrap();
2519
2520 loop {
2521 let token = match self
2522 .hub
2523 .auth
2524 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2525 .await
2526 {
2527 Ok(token) => token,
2528 Err(e) => match dlg.token(e) {
2529 Ok(token) => token,
2530 Err(e) => {
2531 dlg.finished(false);
2532 return Err(common::Error::MissingToken(e));
2533 }
2534 },
2535 };
2536 request_value_reader
2537 .seek(std::io::SeekFrom::Start(0))
2538 .unwrap();
2539 let mut req_result = {
2540 let client = &self.hub.client;
2541 dlg.pre_request();
2542 let mut req_builder = hyper::Request::builder()
2543 .method(hyper::Method::POST)
2544 .uri(url.as_str())
2545 .header(USER_AGENT, self.hub._user_agent.clone());
2546
2547 if let Some(token) = token.as_ref() {
2548 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2549 }
2550
2551 let request = req_builder
2552 .header(CONTENT_TYPE, json_mime_type.to_string())
2553 .header(CONTENT_LENGTH, request_size as u64)
2554 .body(common::to_body(
2555 request_value_reader.get_ref().clone().into(),
2556 ));
2557
2558 client.request(request.unwrap()).await
2559 };
2560
2561 match req_result {
2562 Err(err) => {
2563 if let common::Retry::After(d) = dlg.http_error(&err) {
2564 sleep(d).await;
2565 continue;
2566 }
2567 dlg.finished(false);
2568 return Err(common::Error::HttpError(err));
2569 }
2570 Ok(res) => {
2571 let (mut parts, body) = res.into_parts();
2572 let mut body = common::Body::new(body);
2573 if !parts.status.is_success() {
2574 let bytes = common::to_bytes(body).await.unwrap_or_default();
2575 let error = serde_json::from_str(&common::to_string(&bytes));
2576 let response = common::to_response(parts, bytes.into());
2577
2578 if let common::Retry::After(d) =
2579 dlg.http_failure(&response, error.as_ref().ok())
2580 {
2581 sleep(d).await;
2582 continue;
2583 }
2584
2585 dlg.finished(false);
2586
2587 return Err(match error {
2588 Ok(value) => common::Error::BadRequest(value),
2589 _ => common::Error::Failure(response),
2590 });
2591 }
2592 let response = {
2593 let bytes = common::to_bytes(body).await.unwrap_or_default();
2594 let encoded = common::to_string(&bytes);
2595 match serde_json::from_str(&encoded) {
2596 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2597 Err(error) => {
2598 dlg.response_json_decode_error(&encoded, &error);
2599 return Err(common::Error::JsonDecodeError(
2600 encoded.to_string(),
2601 error,
2602 ));
2603 }
2604 }
2605 };
2606
2607 dlg.finished(true);
2608 return Ok(response);
2609 }
2610 }
2611 }
2612 }
2613
2614 ///
2615 /// Sets the *request* property to the given value.
2616 ///
2617 /// Even though the property as already been set when instantiating this call,
2618 /// we provide this method for API completeness.
2619 pub fn request(
2620 mut self,
2621 new_value: CancelOperationRequest,
2622 ) -> ProjectLocationOperationCancelCall<'a, C> {
2623 self._request = new_value;
2624 self
2625 }
2626 /// The name of the operation resource to be cancelled.
2627 ///
2628 /// Sets the *name* path property to the given value.
2629 ///
2630 /// Even though the property as already been set when instantiating this call,
2631 /// we provide this method for API completeness.
2632 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
2633 self._name = new_value.to_string();
2634 self
2635 }
2636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2637 /// while executing the actual API request.
2638 ///
2639 /// ````text
2640 /// It should be used to handle progress information, and to implement a certain level of resilience.
2641 /// ````
2642 ///
2643 /// Sets the *delegate* property to the given value.
2644 pub fn delegate(
2645 mut self,
2646 new_value: &'a mut dyn common::Delegate,
2647 ) -> ProjectLocationOperationCancelCall<'a, C> {
2648 self._delegate = Some(new_value);
2649 self
2650 }
2651
2652 /// Set any additional parameter of the query string used in the request.
2653 /// It should be used to set parameters which are not yet available through their own
2654 /// setters.
2655 ///
2656 /// Please note that this method must not be used to set any of the known parameters
2657 /// which have their own setter method. If done anyway, the request will fail.
2658 ///
2659 /// # Additional Parameters
2660 ///
2661 /// * *$.xgafv* (query-string) - V1 error format.
2662 /// * *access_token* (query-string) - OAuth access token.
2663 /// * *alt* (query-string) - Data format for response.
2664 /// * *callback* (query-string) - JSONP
2665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2666 /// * *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.
2667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2669 /// * *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.
2670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2672 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
2673 where
2674 T: AsRef<str>,
2675 {
2676 self._additional_params
2677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2678 self
2679 }
2680
2681 /// Identifies the authorization scope for the method you are building.
2682 ///
2683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2684 /// [`Scope::CloudPlatform`].
2685 ///
2686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2687 /// tokens for more than one scope.
2688 ///
2689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2691 /// sufficient, a read-write scope will do as well.
2692 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
2693 where
2694 St: AsRef<str>,
2695 {
2696 self._scopes.insert(String::from(scope.as_ref()));
2697 self
2698 }
2699 /// Identifies the authorization scope(s) for the method you are building.
2700 ///
2701 /// See [`Self::add_scope()`] for details.
2702 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
2703 where
2704 I: IntoIterator<Item = St>,
2705 St: AsRef<str>,
2706 {
2707 self._scopes
2708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2709 self
2710 }
2711
2712 /// Removes all scopes, and no default scope will be used either.
2713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2714 /// for details).
2715 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
2716 self._scopes.clear();
2717 self
2718 }
2719}
2720
2721/// 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`.
2722///
2723/// A builder for the *locations.operations.delete* method supported by a *project* resource.
2724/// It is not used directly, but through a [`ProjectMethods`] instance.
2725///
2726/// # Example
2727///
2728/// Instantiate a resource method builder
2729///
2730/// ```test_harness,no_run
2731/// # extern crate hyper;
2732/// # extern crate hyper_rustls;
2733/// # extern crate google_ids1 as ids1;
2734/// # async fn dox() {
2735/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2736///
2737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2738/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2739/// # .with_native_roots()
2740/// # .unwrap()
2741/// # .https_only()
2742/// # .enable_http2()
2743/// # .build();
2744///
2745/// # let executor = hyper_util::rt::TokioExecutor::new();
2746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2747/// # secret,
2748/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2749/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2750/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2751/// # ),
2752/// # ).build().await.unwrap();
2753///
2754/// # let client = hyper_util::client::legacy::Client::builder(
2755/// # hyper_util::rt::TokioExecutor::new()
2756/// # )
2757/// # .build(
2758/// # hyper_rustls::HttpsConnectorBuilder::new()
2759/// # .with_native_roots()
2760/// # .unwrap()
2761/// # .https_or_http()
2762/// # .enable_http2()
2763/// # .build()
2764/// # );
2765/// # let mut hub = IDS::new(client, auth);
2766/// // You can configure optional parameters by calling the respective setters at will, and
2767/// // execute the final call using `doit()`.
2768/// // Values shown here are possibly random and not representative !
2769/// let result = hub.projects().locations_operations_delete("name")
2770/// .doit().await;
2771/// # }
2772/// ```
2773pub struct ProjectLocationOperationDeleteCall<'a, C>
2774where
2775 C: 'a,
2776{
2777 hub: &'a IDS<C>,
2778 _name: String,
2779 _delegate: Option<&'a mut dyn common::Delegate>,
2780 _additional_params: HashMap<String, String>,
2781 _scopes: BTreeSet<String>,
2782}
2783
2784impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
2785
2786impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
2787where
2788 C: common::Connector,
2789{
2790 /// Perform the operation you have build so far.
2791 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2792 use std::borrow::Cow;
2793 use std::io::{Read, Seek};
2794
2795 use common::{url::Params, ToParts};
2796 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2797
2798 let mut dd = common::DefaultDelegate;
2799 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2800 dlg.begin(common::MethodInfo {
2801 id: "ids.projects.locations.operations.delete",
2802 http_method: hyper::Method::DELETE,
2803 });
2804
2805 for &field in ["alt", "name"].iter() {
2806 if self._additional_params.contains_key(field) {
2807 dlg.finished(false);
2808 return Err(common::Error::FieldClash(field));
2809 }
2810 }
2811
2812 let mut params = Params::with_capacity(3 + self._additional_params.len());
2813 params.push("name", self._name);
2814
2815 params.extend(self._additional_params.iter());
2816
2817 params.push("alt", "json");
2818 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2819 if self._scopes.is_empty() {
2820 self._scopes
2821 .insert(Scope::CloudPlatform.as_ref().to_string());
2822 }
2823
2824 #[allow(clippy::single_element_loop)]
2825 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2826 url = params.uri_replacement(url, param_name, find_this, true);
2827 }
2828 {
2829 let to_remove = ["name"];
2830 params.remove_params(&to_remove);
2831 }
2832
2833 let url = params.parse_with_url(&url);
2834
2835 loop {
2836 let token = match self
2837 .hub
2838 .auth
2839 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2840 .await
2841 {
2842 Ok(token) => token,
2843 Err(e) => match dlg.token(e) {
2844 Ok(token) => token,
2845 Err(e) => {
2846 dlg.finished(false);
2847 return Err(common::Error::MissingToken(e));
2848 }
2849 },
2850 };
2851 let mut req_result = {
2852 let client = &self.hub.client;
2853 dlg.pre_request();
2854 let mut req_builder = hyper::Request::builder()
2855 .method(hyper::Method::DELETE)
2856 .uri(url.as_str())
2857 .header(USER_AGENT, self.hub._user_agent.clone());
2858
2859 if let Some(token) = token.as_ref() {
2860 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2861 }
2862
2863 let request = req_builder
2864 .header(CONTENT_LENGTH, 0_u64)
2865 .body(common::to_body::<String>(None));
2866
2867 client.request(request.unwrap()).await
2868 };
2869
2870 match req_result {
2871 Err(err) => {
2872 if let common::Retry::After(d) = dlg.http_error(&err) {
2873 sleep(d).await;
2874 continue;
2875 }
2876 dlg.finished(false);
2877 return Err(common::Error::HttpError(err));
2878 }
2879 Ok(res) => {
2880 let (mut parts, body) = res.into_parts();
2881 let mut body = common::Body::new(body);
2882 if !parts.status.is_success() {
2883 let bytes = common::to_bytes(body).await.unwrap_or_default();
2884 let error = serde_json::from_str(&common::to_string(&bytes));
2885 let response = common::to_response(parts, bytes.into());
2886
2887 if let common::Retry::After(d) =
2888 dlg.http_failure(&response, error.as_ref().ok())
2889 {
2890 sleep(d).await;
2891 continue;
2892 }
2893
2894 dlg.finished(false);
2895
2896 return Err(match error {
2897 Ok(value) => common::Error::BadRequest(value),
2898 _ => common::Error::Failure(response),
2899 });
2900 }
2901 let response = {
2902 let bytes = common::to_bytes(body).await.unwrap_or_default();
2903 let encoded = common::to_string(&bytes);
2904 match serde_json::from_str(&encoded) {
2905 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2906 Err(error) => {
2907 dlg.response_json_decode_error(&encoded, &error);
2908 return Err(common::Error::JsonDecodeError(
2909 encoded.to_string(),
2910 error,
2911 ));
2912 }
2913 }
2914 };
2915
2916 dlg.finished(true);
2917 return Ok(response);
2918 }
2919 }
2920 }
2921 }
2922
2923 /// The name of the operation resource to be deleted.
2924 ///
2925 /// Sets the *name* path property to the given value.
2926 ///
2927 /// Even though the property as already been set when instantiating this call,
2928 /// we provide this method for API completeness.
2929 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
2930 self._name = new_value.to_string();
2931 self
2932 }
2933 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2934 /// while executing the actual API request.
2935 ///
2936 /// ````text
2937 /// It should be used to handle progress information, and to implement a certain level of resilience.
2938 /// ````
2939 ///
2940 /// Sets the *delegate* property to the given value.
2941 pub fn delegate(
2942 mut self,
2943 new_value: &'a mut dyn common::Delegate,
2944 ) -> ProjectLocationOperationDeleteCall<'a, C> {
2945 self._delegate = Some(new_value);
2946 self
2947 }
2948
2949 /// Set any additional parameter of the query string used in the request.
2950 /// It should be used to set parameters which are not yet available through their own
2951 /// setters.
2952 ///
2953 /// Please note that this method must not be used to set any of the known parameters
2954 /// which have their own setter method. If done anyway, the request will fail.
2955 ///
2956 /// # Additional Parameters
2957 ///
2958 /// * *$.xgafv* (query-string) - V1 error format.
2959 /// * *access_token* (query-string) - OAuth access token.
2960 /// * *alt* (query-string) - Data format for response.
2961 /// * *callback* (query-string) - JSONP
2962 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2963 /// * *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.
2964 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2965 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2966 /// * *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.
2967 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2968 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2969 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
2970 where
2971 T: AsRef<str>,
2972 {
2973 self._additional_params
2974 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2975 self
2976 }
2977
2978 /// Identifies the authorization scope for the method you are building.
2979 ///
2980 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2981 /// [`Scope::CloudPlatform`].
2982 ///
2983 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2984 /// tokens for more than one scope.
2985 ///
2986 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2987 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2988 /// sufficient, a read-write scope will do as well.
2989 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
2990 where
2991 St: AsRef<str>,
2992 {
2993 self._scopes.insert(String::from(scope.as_ref()));
2994 self
2995 }
2996 /// Identifies the authorization scope(s) for the method you are building.
2997 ///
2998 /// See [`Self::add_scope()`] for details.
2999 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
3000 where
3001 I: IntoIterator<Item = St>,
3002 St: AsRef<str>,
3003 {
3004 self._scopes
3005 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3006 self
3007 }
3008
3009 /// Removes all scopes, and no default scope will be used either.
3010 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3011 /// for details).
3012 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
3013 self._scopes.clear();
3014 self
3015 }
3016}
3017
3018/// 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.
3019///
3020/// A builder for the *locations.operations.get* method supported by a *project* resource.
3021/// It is not used directly, but through a [`ProjectMethods`] instance.
3022///
3023/// # Example
3024///
3025/// Instantiate a resource method builder
3026///
3027/// ```test_harness,no_run
3028/// # extern crate hyper;
3029/// # extern crate hyper_rustls;
3030/// # extern crate google_ids1 as ids1;
3031/// # async fn dox() {
3032/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3033///
3034/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3035/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3036/// # .with_native_roots()
3037/// # .unwrap()
3038/// # .https_only()
3039/// # .enable_http2()
3040/// # .build();
3041///
3042/// # let executor = hyper_util::rt::TokioExecutor::new();
3043/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3044/// # secret,
3045/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3046/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3047/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3048/// # ),
3049/// # ).build().await.unwrap();
3050///
3051/// # let client = hyper_util::client::legacy::Client::builder(
3052/// # hyper_util::rt::TokioExecutor::new()
3053/// # )
3054/// # .build(
3055/// # hyper_rustls::HttpsConnectorBuilder::new()
3056/// # .with_native_roots()
3057/// # .unwrap()
3058/// # .https_or_http()
3059/// # .enable_http2()
3060/// # .build()
3061/// # );
3062/// # let mut hub = IDS::new(client, auth);
3063/// // You can configure optional parameters by calling the respective setters at will, and
3064/// // execute the final call using `doit()`.
3065/// // Values shown here are possibly random and not representative !
3066/// let result = hub.projects().locations_operations_get("name")
3067/// .doit().await;
3068/// # }
3069/// ```
3070pub struct ProjectLocationOperationGetCall<'a, C>
3071where
3072 C: 'a,
3073{
3074 hub: &'a IDS<C>,
3075 _name: String,
3076 _delegate: Option<&'a mut dyn common::Delegate>,
3077 _additional_params: HashMap<String, String>,
3078 _scopes: BTreeSet<String>,
3079}
3080
3081impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
3082
3083impl<'a, C> ProjectLocationOperationGetCall<'a, C>
3084where
3085 C: common::Connector,
3086{
3087 /// Perform the operation you have build so far.
3088 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3089 use std::borrow::Cow;
3090 use std::io::{Read, Seek};
3091
3092 use common::{url::Params, ToParts};
3093 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3094
3095 let mut dd = common::DefaultDelegate;
3096 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3097 dlg.begin(common::MethodInfo {
3098 id: "ids.projects.locations.operations.get",
3099 http_method: hyper::Method::GET,
3100 });
3101
3102 for &field in ["alt", "name"].iter() {
3103 if self._additional_params.contains_key(field) {
3104 dlg.finished(false);
3105 return Err(common::Error::FieldClash(field));
3106 }
3107 }
3108
3109 let mut params = Params::with_capacity(3 + self._additional_params.len());
3110 params.push("name", self._name);
3111
3112 params.extend(self._additional_params.iter());
3113
3114 params.push("alt", "json");
3115 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3116 if self._scopes.is_empty() {
3117 self._scopes
3118 .insert(Scope::CloudPlatform.as_ref().to_string());
3119 }
3120
3121 #[allow(clippy::single_element_loop)]
3122 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3123 url = params.uri_replacement(url, param_name, find_this, true);
3124 }
3125 {
3126 let to_remove = ["name"];
3127 params.remove_params(&to_remove);
3128 }
3129
3130 let url = params.parse_with_url(&url);
3131
3132 loop {
3133 let token = match self
3134 .hub
3135 .auth
3136 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3137 .await
3138 {
3139 Ok(token) => token,
3140 Err(e) => match dlg.token(e) {
3141 Ok(token) => token,
3142 Err(e) => {
3143 dlg.finished(false);
3144 return Err(common::Error::MissingToken(e));
3145 }
3146 },
3147 };
3148 let mut req_result = {
3149 let client = &self.hub.client;
3150 dlg.pre_request();
3151 let mut req_builder = hyper::Request::builder()
3152 .method(hyper::Method::GET)
3153 .uri(url.as_str())
3154 .header(USER_AGENT, self.hub._user_agent.clone());
3155
3156 if let Some(token) = token.as_ref() {
3157 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3158 }
3159
3160 let request = req_builder
3161 .header(CONTENT_LENGTH, 0_u64)
3162 .body(common::to_body::<String>(None));
3163
3164 client.request(request.unwrap()).await
3165 };
3166
3167 match req_result {
3168 Err(err) => {
3169 if let common::Retry::After(d) = dlg.http_error(&err) {
3170 sleep(d).await;
3171 continue;
3172 }
3173 dlg.finished(false);
3174 return Err(common::Error::HttpError(err));
3175 }
3176 Ok(res) => {
3177 let (mut parts, body) = res.into_parts();
3178 let mut body = common::Body::new(body);
3179 if !parts.status.is_success() {
3180 let bytes = common::to_bytes(body).await.unwrap_or_default();
3181 let error = serde_json::from_str(&common::to_string(&bytes));
3182 let response = common::to_response(parts, bytes.into());
3183
3184 if let common::Retry::After(d) =
3185 dlg.http_failure(&response, error.as_ref().ok())
3186 {
3187 sleep(d).await;
3188 continue;
3189 }
3190
3191 dlg.finished(false);
3192
3193 return Err(match error {
3194 Ok(value) => common::Error::BadRequest(value),
3195 _ => common::Error::Failure(response),
3196 });
3197 }
3198 let response = {
3199 let bytes = common::to_bytes(body).await.unwrap_or_default();
3200 let encoded = common::to_string(&bytes);
3201 match serde_json::from_str(&encoded) {
3202 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3203 Err(error) => {
3204 dlg.response_json_decode_error(&encoded, &error);
3205 return Err(common::Error::JsonDecodeError(
3206 encoded.to_string(),
3207 error,
3208 ));
3209 }
3210 }
3211 };
3212
3213 dlg.finished(true);
3214 return Ok(response);
3215 }
3216 }
3217 }
3218 }
3219
3220 /// The name of the operation resource.
3221 ///
3222 /// Sets the *name* path property to the given value.
3223 ///
3224 /// Even though the property as already been set when instantiating this call,
3225 /// we provide this method for API completeness.
3226 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
3227 self._name = new_value.to_string();
3228 self
3229 }
3230 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3231 /// while executing the actual API request.
3232 ///
3233 /// ````text
3234 /// It should be used to handle progress information, and to implement a certain level of resilience.
3235 /// ````
3236 ///
3237 /// Sets the *delegate* property to the given value.
3238 pub fn delegate(
3239 mut self,
3240 new_value: &'a mut dyn common::Delegate,
3241 ) -> ProjectLocationOperationGetCall<'a, C> {
3242 self._delegate = Some(new_value);
3243 self
3244 }
3245
3246 /// Set any additional parameter of the query string used in the request.
3247 /// It should be used to set parameters which are not yet available through their own
3248 /// setters.
3249 ///
3250 /// Please note that this method must not be used to set any of the known parameters
3251 /// which have their own setter method. If done anyway, the request will fail.
3252 ///
3253 /// # Additional Parameters
3254 ///
3255 /// * *$.xgafv* (query-string) - V1 error format.
3256 /// * *access_token* (query-string) - OAuth access token.
3257 /// * *alt* (query-string) - Data format for response.
3258 /// * *callback* (query-string) - JSONP
3259 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3260 /// * *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.
3261 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3262 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3263 /// * *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.
3264 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3265 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3266 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
3267 where
3268 T: AsRef<str>,
3269 {
3270 self._additional_params
3271 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3272 self
3273 }
3274
3275 /// Identifies the authorization scope for the method you are building.
3276 ///
3277 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3278 /// [`Scope::CloudPlatform`].
3279 ///
3280 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3281 /// tokens for more than one scope.
3282 ///
3283 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3284 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3285 /// sufficient, a read-write scope will do as well.
3286 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
3287 where
3288 St: AsRef<str>,
3289 {
3290 self._scopes.insert(String::from(scope.as_ref()));
3291 self
3292 }
3293 /// Identifies the authorization scope(s) for the method you are building.
3294 ///
3295 /// See [`Self::add_scope()`] for details.
3296 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
3297 where
3298 I: IntoIterator<Item = St>,
3299 St: AsRef<str>,
3300 {
3301 self._scopes
3302 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3303 self
3304 }
3305
3306 /// Removes all scopes, and no default scope will be used either.
3307 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3308 /// for details).
3309 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
3310 self._scopes.clear();
3311 self
3312 }
3313}
3314
3315/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3316///
3317/// A builder for the *locations.operations.list* method supported by a *project* resource.
3318/// It is not used directly, but through a [`ProjectMethods`] instance.
3319///
3320/// # Example
3321///
3322/// Instantiate a resource method builder
3323///
3324/// ```test_harness,no_run
3325/// # extern crate hyper;
3326/// # extern crate hyper_rustls;
3327/// # extern crate google_ids1 as ids1;
3328/// # async fn dox() {
3329/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3330///
3331/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3332/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3333/// # .with_native_roots()
3334/// # .unwrap()
3335/// # .https_only()
3336/// # .enable_http2()
3337/// # .build();
3338///
3339/// # let executor = hyper_util::rt::TokioExecutor::new();
3340/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3341/// # secret,
3342/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3343/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3344/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3345/// # ),
3346/// # ).build().await.unwrap();
3347///
3348/// # let client = hyper_util::client::legacy::Client::builder(
3349/// # hyper_util::rt::TokioExecutor::new()
3350/// # )
3351/// # .build(
3352/// # hyper_rustls::HttpsConnectorBuilder::new()
3353/// # .with_native_roots()
3354/// # .unwrap()
3355/// # .https_or_http()
3356/// # .enable_http2()
3357/// # .build()
3358/// # );
3359/// # let mut hub = IDS::new(client, auth);
3360/// // You can configure optional parameters by calling the respective setters at will, and
3361/// // execute the final call using `doit()`.
3362/// // Values shown here are possibly random and not representative !
3363/// let result = hub.projects().locations_operations_list("name")
3364/// .return_partial_success(true)
3365/// .page_token("ipsum")
3366/// .page_size(-50)
3367/// .filter("est")
3368/// .doit().await;
3369/// # }
3370/// ```
3371pub struct ProjectLocationOperationListCall<'a, C>
3372where
3373 C: 'a,
3374{
3375 hub: &'a IDS<C>,
3376 _name: String,
3377 _return_partial_success: Option<bool>,
3378 _page_token: Option<String>,
3379 _page_size: Option<i32>,
3380 _filter: Option<String>,
3381 _delegate: Option<&'a mut dyn common::Delegate>,
3382 _additional_params: HashMap<String, String>,
3383 _scopes: BTreeSet<String>,
3384}
3385
3386impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
3387
3388impl<'a, C> ProjectLocationOperationListCall<'a, C>
3389where
3390 C: common::Connector,
3391{
3392 /// Perform the operation you have build so far.
3393 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
3394 use std::borrow::Cow;
3395 use std::io::{Read, Seek};
3396
3397 use common::{url::Params, ToParts};
3398 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3399
3400 let mut dd = common::DefaultDelegate;
3401 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3402 dlg.begin(common::MethodInfo {
3403 id: "ids.projects.locations.operations.list",
3404 http_method: hyper::Method::GET,
3405 });
3406
3407 for &field in [
3408 "alt",
3409 "name",
3410 "returnPartialSuccess",
3411 "pageToken",
3412 "pageSize",
3413 "filter",
3414 ]
3415 .iter()
3416 {
3417 if self._additional_params.contains_key(field) {
3418 dlg.finished(false);
3419 return Err(common::Error::FieldClash(field));
3420 }
3421 }
3422
3423 let mut params = Params::with_capacity(7 + self._additional_params.len());
3424 params.push("name", self._name);
3425 if let Some(value) = self._return_partial_success.as_ref() {
3426 params.push("returnPartialSuccess", value.to_string());
3427 }
3428 if let Some(value) = self._page_token.as_ref() {
3429 params.push("pageToken", value);
3430 }
3431 if let Some(value) = self._page_size.as_ref() {
3432 params.push("pageSize", value.to_string());
3433 }
3434 if let Some(value) = self._filter.as_ref() {
3435 params.push("filter", value);
3436 }
3437
3438 params.extend(self._additional_params.iter());
3439
3440 params.push("alt", "json");
3441 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
3442 if self._scopes.is_empty() {
3443 self._scopes
3444 .insert(Scope::CloudPlatform.as_ref().to_string());
3445 }
3446
3447 #[allow(clippy::single_element_loop)]
3448 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3449 url = params.uri_replacement(url, param_name, find_this, true);
3450 }
3451 {
3452 let to_remove = ["name"];
3453 params.remove_params(&to_remove);
3454 }
3455
3456 let url = params.parse_with_url(&url);
3457
3458 loop {
3459 let token = match self
3460 .hub
3461 .auth
3462 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3463 .await
3464 {
3465 Ok(token) => token,
3466 Err(e) => match dlg.token(e) {
3467 Ok(token) => token,
3468 Err(e) => {
3469 dlg.finished(false);
3470 return Err(common::Error::MissingToken(e));
3471 }
3472 },
3473 };
3474 let mut req_result = {
3475 let client = &self.hub.client;
3476 dlg.pre_request();
3477 let mut req_builder = hyper::Request::builder()
3478 .method(hyper::Method::GET)
3479 .uri(url.as_str())
3480 .header(USER_AGENT, self.hub._user_agent.clone());
3481
3482 if let Some(token) = token.as_ref() {
3483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3484 }
3485
3486 let request = req_builder
3487 .header(CONTENT_LENGTH, 0_u64)
3488 .body(common::to_body::<String>(None));
3489
3490 client.request(request.unwrap()).await
3491 };
3492
3493 match req_result {
3494 Err(err) => {
3495 if let common::Retry::After(d) = dlg.http_error(&err) {
3496 sleep(d).await;
3497 continue;
3498 }
3499 dlg.finished(false);
3500 return Err(common::Error::HttpError(err));
3501 }
3502 Ok(res) => {
3503 let (mut parts, body) = res.into_parts();
3504 let mut body = common::Body::new(body);
3505 if !parts.status.is_success() {
3506 let bytes = common::to_bytes(body).await.unwrap_or_default();
3507 let error = serde_json::from_str(&common::to_string(&bytes));
3508 let response = common::to_response(parts, bytes.into());
3509
3510 if let common::Retry::After(d) =
3511 dlg.http_failure(&response, error.as_ref().ok())
3512 {
3513 sleep(d).await;
3514 continue;
3515 }
3516
3517 dlg.finished(false);
3518
3519 return Err(match error {
3520 Ok(value) => common::Error::BadRequest(value),
3521 _ => common::Error::Failure(response),
3522 });
3523 }
3524 let response = {
3525 let bytes = common::to_bytes(body).await.unwrap_or_default();
3526 let encoded = common::to_string(&bytes);
3527 match serde_json::from_str(&encoded) {
3528 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3529 Err(error) => {
3530 dlg.response_json_decode_error(&encoded, &error);
3531 return Err(common::Error::JsonDecodeError(
3532 encoded.to_string(),
3533 error,
3534 ));
3535 }
3536 }
3537 };
3538
3539 dlg.finished(true);
3540 return Ok(response);
3541 }
3542 }
3543 }
3544 }
3545
3546 /// The name of the operation's parent resource.
3547 ///
3548 /// Sets the *name* path property to the given value.
3549 ///
3550 /// Even though the property as already been set when instantiating this call,
3551 /// we provide this method for API completeness.
3552 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
3553 self._name = new_value.to_string();
3554 self
3555 }
3556 /// 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.
3557 ///
3558 /// Sets the *return partial success* query property to the given value.
3559 pub fn return_partial_success(
3560 mut self,
3561 new_value: bool,
3562 ) -> ProjectLocationOperationListCall<'a, C> {
3563 self._return_partial_success = Some(new_value);
3564 self
3565 }
3566 /// The standard list page token.
3567 ///
3568 /// Sets the *page token* query property to the given value.
3569 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
3570 self._page_token = Some(new_value.to_string());
3571 self
3572 }
3573 /// The standard list page size.
3574 ///
3575 /// Sets the *page size* query property to the given value.
3576 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
3577 self._page_size = Some(new_value);
3578 self
3579 }
3580 /// The standard list filter.
3581 ///
3582 /// Sets the *filter* query property to the given value.
3583 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
3584 self._filter = Some(new_value.to_string());
3585 self
3586 }
3587 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3588 /// while executing the actual API request.
3589 ///
3590 /// ````text
3591 /// It should be used to handle progress information, and to implement a certain level of resilience.
3592 /// ````
3593 ///
3594 /// Sets the *delegate* property to the given value.
3595 pub fn delegate(
3596 mut self,
3597 new_value: &'a mut dyn common::Delegate,
3598 ) -> ProjectLocationOperationListCall<'a, C> {
3599 self._delegate = Some(new_value);
3600 self
3601 }
3602
3603 /// Set any additional parameter of the query string used in the request.
3604 /// It should be used to set parameters which are not yet available through their own
3605 /// setters.
3606 ///
3607 /// Please note that this method must not be used to set any of the known parameters
3608 /// which have their own setter method. If done anyway, the request will fail.
3609 ///
3610 /// # Additional Parameters
3611 ///
3612 /// * *$.xgafv* (query-string) - V1 error format.
3613 /// * *access_token* (query-string) - OAuth access token.
3614 /// * *alt* (query-string) - Data format for response.
3615 /// * *callback* (query-string) - JSONP
3616 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3617 /// * *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.
3618 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3619 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3620 /// * *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.
3621 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3622 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3623 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
3624 where
3625 T: AsRef<str>,
3626 {
3627 self._additional_params
3628 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3629 self
3630 }
3631
3632 /// Identifies the authorization scope for the method you are building.
3633 ///
3634 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3635 /// [`Scope::CloudPlatform`].
3636 ///
3637 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3638 /// tokens for more than one scope.
3639 ///
3640 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3641 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3642 /// sufficient, a read-write scope will do as well.
3643 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
3644 where
3645 St: AsRef<str>,
3646 {
3647 self._scopes.insert(String::from(scope.as_ref()));
3648 self
3649 }
3650 /// Identifies the authorization scope(s) for the method you are building.
3651 ///
3652 /// See [`Self::add_scope()`] for details.
3653 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
3654 where
3655 I: IntoIterator<Item = St>,
3656 St: AsRef<str>,
3657 {
3658 self._scopes
3659 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3660 self
3661 }
3662
3663 /// Removes all scopes, and no default scope will be used either.
3664 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3665 /// for details).
3666 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
3667 self._scopes.clear();
3668 self
3669 }
3670}
3671
3672/// Gets information about a location.
3673///
3674/// A builder for the *locations.get* method supported by a *project* resource.
3675/// It is not used directly, but through a [`ProjectMethods`] instance.
3676///
3677/// # Example
3678///
3679/// Instantiate a resource method builder
3680///
3681/// ```test_harness,no_run
3682/// # extern crate hyper;
3683/// # extern crate hyper_rustls;
3684/// # extern crate google_ids1 as ids1;
3685/// # async fn dox() {
3686/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3687///
3688/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3689/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3690/// # .with_native_roots()
3691/// # .unwrap()
3692/// # .https_only()
3693/// # .enable_http2()
3694/// # .build();
3695///
3696/// # let executor = hyper_util::rt::TokioExecutor::new();
3697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3698/// # secret,
3699/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3700/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3701/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3702/// # ),
3703/// # ).build().await.unwrap();
3704///
3705/// # let client = hyper_util::client::legacy::Client::builder(
3706/// # hyper_util::rt::TokioExecutor::new()
3707/// # )
3708/// # .build(
3709/// # hyper_rustls::HttpsConnectorBuilder::new()
3710/// # .with_native_roots()
3711/// # .unwrap()
3712/// # .https_or_http()
3713/// # .enable_http2()
3714/// # .build()
3715/// # );
3716/// # let mut hub = IDS::new(client, auth);
3717/// // You can configure optional parameters by calling the respective setters at will, and
3718/// // execute the final call using `doit()`.
3719/// // Values shown here are possibly random and not representative !
3720/// let result = hub.projects().locations_get("name")
3721/// .doit().await;
3722/// # }
3723/// ```
3724pub struct ProjectLocationGetCall<'a, C>
3725where
3726 C: 'a,
3727{
3728 hub: &'a IDS<C>,
3729 _name: String,
3730 _delegate: Option<&'a mut dyn common::Delegate>,
3731 _additional_params: HashMap<String, String>,
3732 _scopes: BTreeSet<String>,
3733}
3734
3735impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
3736
3737impl<'a, C> ProjectLocationGetCall<'a, C>
3738where
3739 C: common::Connector,
3740{
3741 /// Perform the operation you have build so far.
3742 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
3743 use std::borrow::Cow;
3744 use std::io::{Read, Seek};
3745
3746 use common::{url::Params, ToParts};
3747 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3748
3749 let mut dd = common::DefaultDelegate;
3750 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3751 dlg.begin(common::MethodInfo {
3752 id: "ids.projects.locations.get",
3753 http_method: hyper::Method::GET,
3754 });
3755
3756 for &field in ["alt", "name"].iter() {
3757 if self._additional_params.contains_key(field) {
3758 dlg.finished(false);
3759 return Err(common::Error::FieldClash(field));
3760 }
3761 }
3762
3763 let mut params = Params::with_capacity(3 + self._additional_params.len());
3764 params.push("name", self._name);
3765
3766 params.extend(self._additional_params.iter());
3767
3768 params.push("alt", "json");
3769 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3770 if self._scopes.is_empty() {
3771 self._scopes
3772 .insert(Scope::CloudPlatform.as_ref().to_string());
3773 }
3774
3775 #[allow(clippy::single_element_loop)]
3776 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3777 url = params.uri_replacement(url, param_name, find_this, true);
3778 }
3779 {
3780 let to_remove = ["name"];
3781 params.remove_params(&to_remove);
3782 }
3783
3784 let url = params.parse_with_url(&url);
3785
3786 loop {
3787 let token = match self
3788 .hub
3789 .auth
3790 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3791 .await
3792 {
3793 Ok(token) => token,
3794 Err(e) => match dlg.token(e) {
3795 Ok(token) => token,
3796 Err(e) => {
3797 dlg.finished(false);
3798 return Err(common::Error::MissingToken(e));
3799 }
3800 },
3801 };
3802 let mut req_result = {
3803 let client = &self.hub.client;
3804 dlg.pre_request();
3805 let mut req_builder = hyper::Request::builder()
3806 .method(hyper::Method::GET)
3807 .uri(url.as_str())
3808 .header(USER_AGENT, self.hub._user_agent.clone());
3809
3810 if let Some(token) = token.as_ref() {
3811 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3812 }
3813
3814 let request = req_builder
3815 .header(CONTENT_LENGTH, 0_u64)
3816 .body(common::to_body::<String>(None));
3817
3818 client.request(request.unwrap()).await
3819 };
3820
3821 match req_result {
3822 Err(err) => {
3823 if let common::Retry::After(d) = dlg.http_error(&err) {
3824 sleep(d).await;
3825 continue;
3826 }
3827 dlg.finished(false);
3828 return Err(common::Error::HttpError(err));
3829 }
3830 Ok(res) => {
3831 let (mut parts, body) = res.into_parts();
3832 let mut body = common::Body::new(body);
3833 if !parts.status.is_success() {
3834 let bytes = common::to_bytes(body).await.unwrap_or_default();
3835 let error = serde_json::from_str(&common::to_string(&bytes));
3836 let response = common::to_response(parts, bytes.into());
3837
3838 if let common::Retry::After(d) =
3839 dlg.http_failure(&response, error.as_ref().ok())
3840 {
3841 sleep(d).await;
3842 continue;
3843 }
3844
3845 dlg.finished(false);
3846
3847 return Err(match error {
3848 Ok(value) => common::Error::BadRequest(value),
3849 _ => common::Error::Failure(response),
3850 });
3851 }
3852 let response = {
3853 let bytes = common::to_bytes(body).await.unwrap_or_default();
3854 let encoded = common::to_string(&bytes);
3855 match serde_json::from_str(&encoded) {
3856 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3857 Err(error) => {
3858 dlg.response_json_decode_error(&encoded, &error);
3859 return Err(common::Error::JsonDecodeError(
3860 encoded.to_string(),
3861 error,
3862 ));
3863 }
3864 }
3865 };
3866
3867 dlg.finished(true);
3868 return Ok(response);
3869 }
3870 }
3871 }
3872 }
3873
3874 /// Resource name for the location.
3875 ///
3876 /// Sets the *name* path property to the given value.
3877 ///
3878 /// Even though the property as already been set when instantiating this call,
3879 /// we provide this method for API completeness.
3880 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
3881 self._name = new_value.to_string();
3882 self
3883 }
3884 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3885 /// while executing the actual API request.
3886 ///
3887 /// ````text
3888 /// It should be used to handle progress information, and to implement a certain level of resilience.
3889 /// ````
3890 ///
3891 /// Sets the *delegate* property to the given value.
3892 pub fn delegate(
3893 mut self,
3894 new_value: &'a mut dyn common::Delegate,
3895 ) -> ProjectLocationGetCall<'a, C> {
3896 self._delegate = Some(new_value);
3897 self
3898 }
3899
3900 /// Set any additional parameter of the query string used in the request.
3901 /// It should be used to set parameters which are not yet available through their own
3902 /// setters.
3903 ///
3904 /// Please note that this method must not be used to set any of the known parameters
3905 /// which have their own setter method. If done anyway, the request will fail.
3906 ///
3907 /// # Additional Parameters
3908 ///
3909 /// * *$.xgafv* (query-string) - V1 error format.
3910 /// * *access_token* (query-string) - OAuth access token.
3911 /// * *alt* (query-string) - Data format for response.
3912 /// * *callback* (query-string) - JSONP
3913 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3914 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3915 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3916 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3917 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3918 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3919 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3920 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
3921 where
3922 T: AsRef<str>,
3923 {
3924 self._additional_params
3925 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3926 self
3927 }
3928
3929 /// Identifies the authorization scope for the method you are building.
3930 ///
3931 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3932 /// [`Scope::CloudPlatform`].
3933 ///
3934 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3935 /// tokens for more than one scope.
3936 ///
3937 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3938 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3939 /// sufficient, a read-write scope will do as well.
3940 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
3941 where
3942 St: AsRef<str>,
3943 {
3944 self._scopes.insert(String::from(scope.as_ref()));
3945 self
3946 }
3947 /// Identifies the authorization scope(s) for the method you are building.
3948 ///
3949 /// See [`Self::add_scope()`] for details.
3950 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
3951 where
3952 I: IntoIterator<Item = St>,
3953 St: AsRef<str>,
3954 {
3955 self._scopes
3956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3957 self
3958 }
3959
3960 /// Removes all scopes, and no default scope will be used either.
3961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3962 /// for details).
3963 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
3964 self._scopes.clear();
3965 self
3966 }
3967}
3968
3969/// Lists information about the supported locations for this service.
3970///
3971/// A builder for the *locations.list* method supported by a *project* resource.
3972/// It is not used directly, but through a [`ProjectMethods`] instance.
3973///
3974/// # Example
3975///
3976/// Instantiate a resource method builder
3977///
3978/// ```test_harness,no_run
3979/// # extern crate hyper;
3980/// # extern crate hyper_rustls;
3981/// # extern crate google_ids1 as ids1;
3982/// # async fn dox() {
3983/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3984///
3985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3986/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3987/// # .with_native_roots()
3988/// # .unwrap()
3989/// # .https_only()
3990/// # .enable_http2()
3991/// # .build();
3992///
3993/// # let executor = hyper_util::rt::TokioExecutor::new();
3994/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3995/// # secret,
3996/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3997/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3998/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3999/// # ),
4000/// # ).build().await.unwrap();
4001///
4002/// # let client = hyper_util::client::legacy::Client::builder(
4003/// # hyper_util::rt::TokioExecutor::new()
4004/// # )
4005/// # .build(
4006/// # hyper_rustls::HttpsConnectorBuilder::new()
4007/// # .with_native_roots()
4008/// # .unwrap()
4009/// # .https_or_http()
4010/// # .enable_http2()
4011/// # .build()
4012/// # );
4013/// # let mut hub = IDS::new(client, auth);
4014/// // You can configure optional parameters by calling the respective setters at will, and
4015/// // execute the final call using `doit()`.
4016/// // Values shown here are possibly random and not representative !
4017/// let result = hub.projects().locations_list("name")
4018/// .page_token("dolor")
4019/// .page_size(-56)
4020/// .filter("eos")
4021/// .add_extra_location_types("labore")
4022/// .doit().await;
4023/// # }
4024/// ```
4025pub struct ProjectLocationListCall<'a, C>
4026where
4027 C: 'a,
4028{
4029 hub: &'a IDS<C>,
4030 _name: String,
4031 _page_token: Option<String>,
4032 _page_size: Option<i32>,
4033 _filter: Option<String>,
4034 _extra_location_types: Vec<String>,
4035 _delegate: Option<&'a mut dyn common::Delegate>,
4036 _additional_params: HashMap<String, String>,
4037 _scopes: BTreeSet<String>,
4038}
4039
4040impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
4041
4042impl<'a, C> ProjectLocationListCall<'a, C>
4043where
4044 C: common::Connector,
4045{
4046 /// Perform the operation you have build so far.
4047 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
4048 use std::borrow::Cow;
4049 use std::io::{Read, Seek};
4050
4051 use common::{url::Params, ToParts};
4052 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4053
4054 let mut dd = common::DefaultDelegate;
4055 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4056 dlg.begin(common::MethodInfo {
4057 id: "ids.projects.locations.list",
4058 http_method: hyper::Method::GET,
4059 });
4060
4061 for &field in [
4062 "alt",
4063 "name",
4064 "pageToken",
4065 "pageSize",
4066 "filter",
4067 "extraLocationTypes",
4068 ]
4069 .iter()
4070 {
4071 if self._additional_params.contains_key(field) {
4072 dlg.finished(false);
4073 return Err(common::Error::FieldClash(field));
4074 }
4075 }
4076
4077 let mut params = Params::with_capacity(7 + self._additional_params.len());
4078 params.push("name", self._name);
4079 if let Some(value) = self._page_token.as_ref() {
4080 params.push("pageToken", value);
4081 }
4082 if let Some(value) = self._page_size.as_ref() {
4083 params.push("pageSize", value.to_string());
4084 }
4085 if let Some(value) = self._filter.as_ref() {
4086 params.push("filter", value);
4087 }
4088 if !self._extra_location_types.is_empty() {
4089 for f in self._extra_location_types.iter() {
4090 params.push("extraLocationTypes", f);
4091 }
4092 }
4093
4094 params.extend(self._additional_params.iter());
4095
4096 params.push("alt", "json");
4097 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
4098 if self._scopes.is_empty() {
4099 self._scopes
4100 .insert(Scope::CloudPlatform.as_ref().to_string());
4101 }
4102
4103 #[allow(clippy::single_element_loop)]
4104 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4105 url = params.uri_replacement(url, param_name, find_this, true);
4106 }
4107 {
4108 let to_remove = ["name"];
4109 params.remove_params(&to_remove);
4110 }
4111
4112 let url = params.parse_with_url(&url);
4113
4114 loop {
4115 let token = match self
4116 .hub
4117 .auth
4118 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4119 .await
4120 {
4121 Ok(token) => token,
4122 Err(e) => match dlg.token(e) {
4123 Ok(token) => token,
4124 Err(e) => {
4125 dlg.finished(false);
4126 return Err(common::Error::MissingToken(e));
4127 }
4128 },
4129 };
4130 let mut req_result = {
4131 let client = &self.hub.client;
4132 dlg.pre_request();
4133 let mut req_builder = hyper::Request::builder()
4134 .method(hyper::Method::GET)
4135 .uri(url.as_str())
4136 .header(USER_AGENT, self.hub._user_agent.clone());
4137
4138 if let Some(token) = token.as_ref() {
4139 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4140 }
4141
4142 let request = req_builder
4143 .header(CONTENT_LENGTH, 0_u64)
4144 .body(common::to_body::<String>(None));
4145
4146 client.request(request.unwrap()).await
4147 };
4148
4149 match req_result {
4150 Err(err) => {
4151 if let common::Retry::After(d) = dlg.http_error(&err) {
4152 sleep(d).await;
4153 continue;
4154 }
4155 dlg.finished(false);
4156 return Err(common::Error::HttpError(err));
4157 }
4158 Ok(res) => {
4159 let (mut parts, body) = res.into_parts();
4160 let mut body = common::Body::new(body);
4161 if !parts.status.is_success() {
4162 let bytes = common::to_bytes(body).await.unwrap_or_default();
4163 let error = serde_json::from_str(&common::to_string(&bytes));
4164 let response = common::to_response(parts, bytes.into());
4165
4166 if let common::Retry::After(d) =
4167 dlg.http_failure(&response, error.as_ref().ok())
4168 {
4169 sleep(d).await;
4170 continue;
4171 }
4172
4173 dlg.finished(false);
4174
4175 return Err(match error {
4176 Ok(value) => common::Error::BadRequest(value),
4177 _ => common::Error::Failure(response),
4178 });
4179 }
4180 let response = {
4181 let bytes = common::to_bytes(body).await.unwrap_or_default();
4182 let encoded = common::to_string(&bytes);
4183 match serde_json::from_str(&encoded) {
4184 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4185 Err(error) => {
4186 dlg.response_json_decode_error(&encoded, &error);
4187 return Err(common::Error::JsonDecodeError(
4188 encoded.to_string(),
4189 error,
4190 ));
4191 }
4192 }
4193 };
4194
4195 dlg.finished(true);
4196 return Ok(response);
4197 }
4198 }
4199 }
4200 }
4201
4202 /// The resource that owns the locations collection, if applicable.
4203 ///
4204 /// Sets the *name* path property to the given value.
4205 ///
4206 /// Even though the property as already been set when instantiating this call,
4207 /// we provide this method for API completeness.
4208 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
4209 self._name = new_value.to_string();
4210 self
4211 }
4212 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
4213 ///
4214 /// Sets the *page token* query property to the given value.
4215 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
4216 self._page_token = Some(new_value.to_string());
4217 self
4218 }
4219 /// The maximum number of results to return. If not set, the service selects a default.
4220 ///
4221 /// Sets the *page size* query property to the given value.
4222 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
4223 self._page_size = Some(new_value);
4224 self
4225 }
4226 /// 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).
4227 ///
4228 /// Sets the *filter* query property to the given value.
4229 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
4230 self._filter = Some(new_value.to_string());
4231 self
4232 }
4233 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
4234 ///
4235 /// Append the given value to the *extra location types* query property.
4236 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4237 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
4238 self._extra_location_types.push(new_value.to_string());
4239 self
4240 }
4241 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4242 /// while executing the actual API request.
4243 ///
4244 /// ````text
4245 /// It should be used to handle progress information, and to implement a certain level of resilience.
4246 /// ````
4247 ///
4248 /// Sets the *delegate* property to the given value.
4249 pub fn delegate(
4250 mut self,
4251 new_value: &'a mut dyn common::Delegate,
4252 ) -> ProjectLocationListCall<'a, C> {
4253 self._delegate = Some(new_value);
4254 self
4255 }
4256
4257 /// Set any additional parameter of the query string used in the request.
4258 /// It should be used to set parameters which are not yet available through their own
4259 /// setters.
4260 ///
4261 /// Please note that this method must not be used to set any of the known parameters
4262 /// which have their own setter method. If done anyway, the request will fail.
4263 ///
4264 /// # Additional Parameters
4265 ///
4266 /// * *$.xgafv* (query-string) - V1 error format.
4267 /// * *access_token* (query-string) - OAuth access token.
4268 /// * *alt* (query-string) - Data format for response.
4269 /// * *callback* (query-string) - JSONP
4270 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4271 /// * *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.
4272 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4273 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4274 /// * *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.
4275 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4276 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4277 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
4278 where
4279 T: AsRef<str>,
4280 {
4281 self._additional_params
4282 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4283 self
4284 }
4285
4286 /// Identifies the authorization scope for the method you are building.
4287 ///
4288 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4289 /// [`Scope::CloudPlatform`].
4290 ///
4291 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4292 /// tokens for more than one scope.
4293 ///
4294 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4295 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4296 /// sufficient, a read-write scope will do as well.
4297 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
4298 where
4299 St: AsRef<str>,
4300 {
4301 self._scopes.insert(String::from(scope.as_ref()));
4302 self
4303 }
4304 /// Identifies the authorization scope(s) for the method you are building.
4305 ///
4306 /// See [`Self::add_scope()`] for details.
4307 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
4308 where
4309 I: IntoIterator<Item = St>,
4310 St: AsRef<str>,
4311 {
4312 self._scopes
4313 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4314 self
4315 }
4316
4317 /// Removes all scopes, and no default scope will be used either.
4318 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4319 /// for details).
4320 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
4321 self._scopes.clear();
4322 self
4323 }
4324}