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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = IDS::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Endpoint::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_endpoints_create(req, "parent")
88/// .request_id("sed")
89/// .endpoint_id("amet.")
90/// .doit().await;
91///
92/// match result {
93/// Err(e) => match e {
94/// // The Error enum provides details about what exactly happened.
95/// // You can also just use its `Debug`, `Display` or `Error` traits
96/// Error::HttpError(_)
97/// |Error::Io(_)
98/// |Error::MissingAPIKey
99/// |Error::MissingToken(_)
100/// |Error::Cancelled
101/// |Error::UploadSizeLimitExceeded(_, _)
102/// |Error::Failure(_)
103/// |Error::BadRequest(_)
104/// |Error::FieldClash(_)
105/// |Error::JsonDecodeError(_, _) => println!("{}", e),
106/// },
107/// Ok(res) => println!("Success: {:?}", res),
108/// }
109/// # }
110/// ```
111#[derive(Clone)]
112pub struct IDS<C> {
113 pub client: common::Client<C>,
114 pub auth: Box<dyn common::GetToken>,
115 _user_agent: String,
116 _base_url: String,
117 _root_url: String,
118}
119
120impl<C> common::Hub for IDS<C> {}
121
122impl<'a, C> IDS<C> {
123 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> IDS<C> {
124 IDS {
125 client,
126 auth: Box::new(auth),
127 _user_agent: "google-api-rust-client/6.0.0".to_string(),
128 _base_url: "https://ids.googleapis.com/".to_string(),
129 _root_url: "https://ids.googleapis.com/".to_string(),
130 }
131 }
132
133 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
134 ProjectMethods { hub: self }
135 }
136
137 /// Set the user-agent header field to use in all requests to the server.
138 /// It defaults to `google-api-rust-client/6.0.0`.
139 ///
140 /// Returns the previously set user-agent.
141 pub fn user_agent(&mut self, agent_name: String) -> String {
142 std::mem::replace(&mut self._user_agent, agent_name)
143 }
144
145 /// Set the base url to use in all requests to the server.
146 /// It defaults to `https://ids.googleapis.com/`.
147 ///
148 /// Returns the previously set base url.
149 pub fn base_url(&mut self, new_base_url: String) -> String {
150 std::mem::replace(&mut self._base_url, new_base_url)
151 }
152
153 /// Set the root url to use in all requests to the server.
154 /// It defaults to `https://ids.googleapis.com/`.
155 ///
156 /// Returns the previously set root url.
157 pub fn root_url(&mut self, new_root_url: String) -> String {
158 std::mem::replace(&mut self._root_url, new_root_url)
159 }
160}
161
162// ############
163// SCHEMAS ###
164// ##########
165/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
166///
167/// This type is not used in any activity, and only used as *part* of another schema.
168///
169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
170#[serde_with::serde_as]
171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
172pub struct AuditConfig {
173 /// The configuration for logging of each type of permission.
174 #[serde(rename = "auditLogConfigs")]
175 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
176 /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
177 pub service: Option<String>,
178}
179
180impl common::Part for AuditConfig {}
181
182/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
183///
184/// This type is not used in any activity, and only used as *part* of another schema.
185///
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct AuditLogConfig {
190 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
191 #[serde(rename = "exemptedMembers")]
192 pub exempted_members: Option<Vec<String>>,
193 /// The log type that this config enables.
194 #[serde(rename = "logType")]
195 pub log_type: Option<String>,
196}
197
198impl common::Part for AuditLogConfig {}
199
200/// Associates `members`, or principals, with a `role`.
201///
202/// This type is not used in any activity, and only used as *part* of another schema.
203///
204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
205#[serde_with::serde_as]
206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
207pub struct Binding {
208 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
209 pub condition: Option<Expr>,
210 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
211 pub members: Option<Vec<String>>,
212 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
213 pub role: Option<String>,
214}
215
216impl common::Part for Binding {}
217
218/// The request message for Operations.CancelOperation.
219///
220/// # Activities
221///
222/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
223/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
224///
225/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
226#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
227#[serde_with::serde_as]
228#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
229pub struct CancelOperationRequest {
230 _never_set: Option<bool>,
231}
232
233impl common::RequestValue for CancelOperationRequest {}
234
235/// 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); }
236///
237/// # Activities
238///
239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
241///
242/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
243/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
245#[serde_with::serde_as]
246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
247pub struct Empty {
248 _never_set: Option<bool>,
249}
250
251impl common::ResponseResult for Empty {}
252
253/// Endpoint describes a single IDS endpoint. It defines a forwarding rule to which packets can be sent for IDS inspection.
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [locations endpoints create projects](ProjectLocationEndpointCreateCall) (request)
261/// * [locations endpoints get projects](ProjectLocationEndpointGetCall) (response)
262/// * [locations endpoints patch projects](ProjectLocationEndpointPatchCall) (request)
263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
264#[serde_with::serde_as]
265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
266pub struct Endpoint {
267 /// Output only. The create time timestamp.
268 #[serde(rename = "createTime")]
269 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
270 /// User-provided description of the endpoint
271 pub description: Option<String>,
272 /// Output only. The fully qualified URL of the endpoint's ILB Forwarding Rule.
273 #[serde(rename = "endpointForwardingRule")]
274 pub endpoint_forwarding_rule: Option<String>,
275 /// Output only. The IP address of the IDS Endpoint's ILB.
276 #[serde(rename = "endpointIp")]
277 pub endpoint_ip: Option<String>,
278 /// The labels of the endpoint.
279 pub labels: Option<HashMap<String, String>>,
280 /// Output only. The name of the endpoint.
281 pub name: Option<String>,
282 /// Required. The fully qualified URL of the network to which the IDS Endpoint is attached.
283 pub network: Option<String>,
284 /// Output only. [Output Only] Reserved for future use.
285 #[serde(rename = "satisfiesPzi")]
286 pub satisfies_pzi: Option<bool>,
287 /// Output only. [Output Only] Reserved for future use.
288 #[serde(rename = "satisfiesPzs")]
289 pub satisfies_pzs: Option<bool>,
290 /// Required. Lowest threat severity that this endpoint will alert on.
291 pub severity: Option<String>,
292 /// Output only. Current state of the endpoint.
293 pub state: Option<String>,
294 /// List of threat IDs to be excepted from generating alerts.
295 #[serde(rename = "threatExceptions")]
296 pub threat_exceptions: Option<Vec<String>>,
297 /// Whether the endpoint should report traffic logs in addition to threat logs.
298 #[serde(rename = "trafficLogs")]
299 pub traffic_logs: Option<bool>,
300 /// Output only. The update time timestamp.
301 #[serde(rename = "updateTime")]
302 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
303}
304
305impl common::RequestValue for Endpoint {}
306impl common::ResponseResult for Endpoint {}
307
308/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
309///
310/// This type is not used in any activity, and only used as *part* of another schema.
311///
312#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
313#[serde_with::serde_as]
314#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
315pub struct Expr {
316 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
317 pub description: Option<String>,
318 /// Textual representation of an expression in Common Expression Language syntax.
319 pub expression: Option<String>,
320 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
321 pub location: Option<String>,
322 /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
323 pub title: Option<String>,
324}
325
326impl common::Part for Expr {}
327
328/// There is no detailed description.
329///
330/// # Activities
331///
332/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
333/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
334///
335/// * [locations endpoints list projects](ProjectLocationEndpointListCall) (response)
336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
337#[serde_with::serde_as]
338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
339pub struct ListEndpointsResponse {
340 /// The list of endpoints response.
341 pub endpoints: Option<Vec<Endpoint>>,
342 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
343 #[serde(rename = "nextPageToken")]
344 pub next_page_token: Option<String>,
345 /// Locations that could not be reached.
346 pub unreachable: Option<Vec<String>>,
347}
348
349impl common::ResponseResult for ListEndpointsResponse {}
350
351/// The response message for Locations.ListLocations.
352///
353/// # Activities
354///
355/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
356/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
357///
358/// * [locations list projects](ProjectLocationListCall) (response)
359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
360#[serde_with::serde_as]
361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
362pub struct ListLocationsResponse {
363 /// A list of locations that matches the specified filter in the request.
364 pub locations: Option<Vec<Location>>,
365 /// The standard List next-page token.
366 #[serde(rename = "nextPageToken")]
367 pub next_page_token: Option<String>,
368}
369
370impl common::ResponseResult for ListLocationsResponse {}
371
372/// The response message for Operations.ListOperations.
373///
374/// # Activities
375///
376/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
377/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
378///
379/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
381#[serde_with::serde_as]
382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
383pub struct ListOperationsResponse {
384 /// The standard List next-page token.
385 #[serde(rename = "nextPageToken")]
386 pub next_page_token: Option<String>,
387 /// A list of operations that matches the specified filter in the request.
388 pub operations: Option<Vec<Operation>>,
389}
390
391impl common::ResponseResult for ListOperationsResponse {}
392
393/// A resource that represents a Google Cloud location.
394///
395/// # Activities
396///
397/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
398/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
399///
400/// * [locations get projects](ProjectLocationGetCall) (response)
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as]
403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
404pub struct Location {
405 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
406 #[serde(rename = "displayName")]
407 pub display_name: Option<String>,
408 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
409 pub labels: Option<HashMap<String, String>>,
410 /// The canonical id for this location. For example: `"us-east1"`.
411 #[serde(rename = "locationId")]
412 pub location_id: Option<String>,
413 /// Service-specific metadata. For example the available capacity at the given location.
414 pub metadata: Option<HashMap<String, serde_json::Value>>,
415 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
416 pub name: Option<String>,
417}
418
419impl common::ResponseResult for Location {}
420
421/// This resource represents a long-running operation that is the result of a network API call.
422///
423/// # Activities
424///
425/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
426/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
427///
428/// * [locations endpoints create projects](ProjectLocationEndpointCreateCall) (response)
429/// * [locations endpoints delete projects](ProjectLocationEndpointDeleteCall) (response)
430/// * [locations endpoints patch projects](ProjectLocationEndpointPatchCall) (response)
431/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct Operation {
436 /// 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.
437 pub done: Option<bool>,
438 /// The error result of the operation in case of failure or cancellation.
439 pub error: Option<Status>,
440 /// 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.
441 pub metadata: Option<HashMap<String, serde_json::Value>>,
442 /// 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}`.
443 pub name: Option<String>,
444 /// 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`.
445 pub response: Option<HashMap<String, serde_json::Value>>,
446}
447
448impl common::ResponseResult for Operation {}
449
450/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
451///
452/// # Activities
453///
454/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
455/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
456///
457/// * [locations endpoints get iam policy projects](ProjectLocationEndpointGetIamPolicyCall) (response)
458/// * [locations endpoints set iam policy projects](ProjectLocationEndpointSetIamPolicyCall) (response)
459#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
460#[serde_with::serde_as]
461#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
462pub struct Policy {
463 /// Specifies cloud audit logging configuration for this policy.
464 #[serde(rename = "auditConfigs")]
465 pub audit_configs: Option<Vec<AuditConfig>>,
466 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
467 pub bindings: Option<Vec<Binding>>,
468 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
469 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
470 pub etag: Option<Vec<u8>>,
471 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
472 pub version: Option<i32>,
473}
474
475impl common::ResponseResult for Policy {}
476
477/// Request message for `SetIamPolicy` method.
478///
479/// # Activities
480///
481/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
482/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
483///
484/// * [locations endpoints set iam policy projects](ProjectLocationEndpointSetIamPolicyCall) (request)
485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
486#[serde_with::serde_as]
487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
488pub struct SetIamPolicyRequest {
489 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
490 pub policy: Option<Policy>,
491 /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
492 #[serde(rename = "updateMask")]
493 pub update_mask: Option<common::FieldMask>,
494}
495
496impl common::RequestValue for SetIamPolicyRequest {}
497
498/// 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).
499///
500/// This type is not used in any activity, and only used as *part* of another schema.
501///
502#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
503#[serde_with::serde_as]
504#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
505pub struct Status {
506 /// The status code, which should be an enum value of google.rpc.Code.
507 pub code: Option<i32>,
508 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
509 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
510 /// 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.
511 pub message: Option<String>,
512}
513
514impl common::Part for Status {}
515
516/// Request message for `TestIamPermissions` method.
517///
518/// # Activities
519///
520/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
521/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
522///
523/// * [locations endpoints test iam permissions projects](ProjectLocationEndpointTestIamPermissionCall) (request)
524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
525#[serde_with::serde_as]
526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
527pub struct TestIamPermissionsRequest {
528 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
529 pub permissions: Option<Vec<String>>,
530}
531
532impl common::RequestValue for TestIamPermissionsRequest {}
533
534/// Response message for `TestIamPermissions` method.
535///
536/// # Activities
537///
538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
540///
541/// * [locations endpoints test iam permissions projects](ProjectLocationEndpointTestIamPermissionCall) (response)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as]
544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
545pub struct TestIamPermissionsResponse {
546 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
547 pub permissions: Option<Vec<String>>,
548}
549
550impl common::ResponseResult for TestIamPermissionsResponse {}
551
552// ###################
553// MethodBuilders ###
554// #################
555
556/// A builder providing access to all methods supported on *project* resources.
557/// It is not used directly, but through the [`IDS`] hub.
558///
559/// # Example
560///
561/// Instantiate a resource builder
562///
563/// ```test_harness,no_run
564/// extern crate hyper;
565/// extern crate hyper_rustls;
566/// extern crate google_ids1 as ids1;
567///
568/// # async fn dox() {
569/// use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
570///
571/// let secret: yup_oauth2::ApplicationSecret = Default::default();
572/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
573/// secret,
574/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
575/// ).build().await.unwrap();
576///
577/// let client = hyper_util::client::legacy::Client::builder(
578/// hyper_util::rt::TokioExecutor::new()
579/// )
580/// .build(
581/// hyper_rustls::HttpsConnectorBuilder::new()
582/// .with_native_roots()
583/// .unwrap()
584/// .https_or_http()
585/// .enable_http1()
586/// .build()
587/// );
588/// let mut hub = IDS::new(client, auth);
589/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
590/// // like `locations_endpoints_create(...)`, `locations_endpoints_delete(...)`, `locations_endpoints_get(...)`, `locations_endpoints_get_iam_policy(...)`, `locations_endpoints_list(...)`, `locations_endpoints_patch(...)`, `locations_endpoints_set_iam_policy(...)`, `locations_endpoints_test_iam_permissions(...)`, `locations_get(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
591/// // to build up your call.
592/// let rb = hub.projects();
593/// # }
594/// ```
595pub struct ProjectMethods<'a, C>
596where
597 C: 'a,
598{
599 hub: &'a IDS<C>,
600}
601
602impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
603
604impl<'a, C> ProjectMethods<'a, C> {
605 /// Create a builder to help you perform the following task:
606 ///
607 /// Creates a new Endpoint in a given project and location.
608 ///
609 /// # Arguments
610 ///
611 /// * `request` - No description provided.
612 /// * `parent` - Required. The endpoint's parent.
613 pub fn locations_endpoints_create(
614 &self,
615 request: Endpoint,
616 parent: &str,
617 ) -> ProjectLocationEndpointCreateCall<'a, C> {
618 ProjectLocationEndpointCreateCall {
619 hub: self.hub,
620 _request: request,
621 _parent: parent.to_string(),
622 _request_id: Default::default(),
623 _endpoint_id: Default::default(),
624 _delegate: Default::default(),
625 _additional_params: Default::default(),
626 _scopes: Default::default(),
627 }
628 }
629
630 /// Create a builder to help you perform the following task:
631 ///
632 /// Deletes a single Endpoint.
633 ///
634 /// # Arguments
635 ///
636 /// * `name` - Required. The name of the endpoint to delete.
637 pub fn locations_endpoints_delete(
638 &self,
639 name: &str,
640 ) -> ProjectLocationEndpointDeleteCall<'a, C> {
641 ProjectLocationEndpointDeleteCall {
642 hub: self.hub,
643 _name: name.to_string(),
644 _request_id: Default::default(),
645 _delegate: Default::default(),
646 _additional_params: Default::default(),
647 _scopes: Default::default(),
648 }
649 }
650
651 /// Create a builder to help you perform the following task:
652 ///
653 /// Gets details of a single Endpoint.
654 ///
655 /// # Arguments
656 ///
657 /// * `name` - Required. The name of the endpoint to retrieve. Format: projects/{project}/locations/{location}/endpoints/{endpoint}
658 pub fn locations_endpoints_get(&self, name: &str) -> ProjectLocationEndpointGetCall<'a, C> {
659 ProjectLocationEndpointGetCall {
660 hub: self.hub,
661 _name: name.to_string(),
662 _delegate: Default::default(),
663 _additional_params: Default::default(),
664 _scopes: Default::default(),
665 }
666 }
667
668 /// Create a builder to help you perform the following task:
669 ///
670 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
671 ///
672 /// # Arguments
673 ///
674 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
675 pub fn locations_endpoints_get_iam_policy(
676 &self,
677 resource: &str,
678 ) -> ProjectLocationEndpointGetIamPolicyCall<'a, C> {
679 ProjectLocationEndpointGetIamPolicyCall {
680 hub: self.hub,
681 _resource: resource.to_string(),
682 _options_requested_policy_version: Default::default(),
683 _delegate: Default::default(),
684 _additional_params: Default::default(),
685 _scopes: Default::default(),
686 }
687 }
688
689 /// Create a builder to help you perform the following task:
690 ///
691 /// Lists Endpoints in a given project and location.
692 ///
693 /// # Arguments
694 ///
695 /// * `parent` - Required. The parent, which owns this collection of endpoints.
696 pub fn locations_endpoints_list(&self, parent: &str) -> ProjectLocationEndpointListCall<'a, C> {
697 ProjectLocationEndpointListCall {
698 hub: self.hub,
699 _parent: parent.to_string(),
700 _page_token: Default::default(),
701 _page_size: Default::default(),
702 _order_by: Default::default(),
703 _filter: Default::default(),
704 _delegate: Default::default(),
705 _additional_params: Default::default(),
706 _scopes: Default::default(),
707 }
708 }
709
710 /// Create a builder to help you perform the following task:
711 ///
712 /// Updates the parameters of a single Endpoint.
713 ///
714 /// # Arguments
715 ///
716 /// * `request` - No description provided.
717 /// * `name` - Output only. The name of the endpoint.
718 pub fn locations_endpoints_patch(
719 &self,
720 request: Endpoint,
721 name: &str,
722 ) -> ProjectLocationEndpointPatchCall<'a, C> {
723 ProjectLocationEndpointPatchCall {
724 hub: self.hub,
725 _request: request,
726 _name: name.to_string(),
727 _update_mask: Default::default(),
728 _request_id: Default::default(),
729 _delegate: Default::default(),
730 _additional_params: Default::default(),
731 _scopes: Default::default(),
732 }
733 }
734
735 /// Create a builder to help you perform the following task:
736 ///
737 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
738 ///
739 /// # Arguments
740 ///
741 /// * `request` - No description provided.
742 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
743 pub fn locations_endpoints_set_iam_policy(
744 &self,
745 request: SetIamPolicyRequest,
746 resource: &str,
747 ) -> ProjectLocationEndpointSetIamPolicyCall<'a, C> {
748 ProjectLocationEndpointSetIamPolicyCall {
749 hub: self.hub,
750 _request: request,
751 _resource: resource.to_string(),
752 _delegate: Default::default(),
753 _additional_params: Default::default(),
754 _scopes: Default::default(),
755 }
756 }
757
758 /// Create a builder to help you perform the following task:
759 ///
760 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
761 ///
762 /// # Arguments
763 ///
764 /// * `request` - No description provided.
765 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
766 pub fn locations_endpoints_test_iam_permissions(
767 &self,
768 request: TestIamPermissionsRequest,
769 resource: &str,
770 ) -> ProjectLocationEndpointTestIamPermissionCall<'a, C> {
771 ProjectLocationEndpointTestIamPermissionCall {
772 hub: self.hub,
773 _request: request,
774 _resource: resource.to_string(),
775 _delegate: Default::default(),
776 _additional_params: Default::default(),
777 _scopes: Default::default(),
778 }
779 }
780
781 /// Create a builder to help you perform the following task:
782 ///
783 /// 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`.
784 ///
785 /// # Arguments
786 ///
787 /// * `request` - No description provided.
788 /// * `name` - The name of the operation resource to be cancelled.
789 pub fn locations_operations_cancel(
790 &self,
791 request: CancelOperationRequest,
792 name: &str,
793 ) -> ProjectLocationOperationCancelCall<'a, C> {
794 ProjectLocationOperationCancelCall {
795 hub: self.hub,
796 _request: request,
797 _name: name.to_string(),
798 _delegate: Default::default(),
799 _additional_params: Default::default(),
800 _scopes: Default::default(),
801 }
802 }
803
804 /// Create a builder to help you perform the following task:
805 ///
806 /// 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`.
807 ///
808 /// # Arguments
809 ///
810 /// * `name` - The name of the operation resource to be deleted.
811 pub fn locations_operations_delete(
812 &self,
813 name: &str,
814 ) -> ProjectLocationOperationDeleteCall<'a, C> {
815 ProjectLocationOperationDeleteCall {
816 hub: self.hub,
817 _name: name.to_string(),
818 _delegate: Default::default(),
819 _additional_params: Default::default(),
820 _scopes: Default::default(),
821 }
822 }
823
824 /// Create a builder to help you perform the following task:
825 ///
826 /// 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.
827 ///
828 /// # Arguments
829 ///
830 /// * `name` - The name of the operation resource.
831 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
832 ProjectLocationOperationGetCall {
833 hub: self.hub,
834 _name: name.to_string(),
835 _delegate: Default::default(),
836 _additional_params: Default::default(),
837 _scopes: Default::default(),
838 }
839 }
840
841 /// Create a builder to help you perform the following task:
842 ///
843 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
844 ///
845 /// # Arguments
846 ///
847 /// * `name` - The name of the operation's parent resource.
848 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
849 ProjectLocationOperationListCall {
850 hub: self.hub,
851 _name: name.to_string(),
852 _page_token: Default::default(),
853 _page_size: Default::default(),
854 _filter: Default::default(),
855 _delegate: Default::default(),
856 _additional_params: Default::default(),
857 _scopes: Default::default(),
858 }
859 }
860
861 /// Create a builder to help you perform the following task:
862 ///
863 /// Gets information about a location.
864 ///
865 /// # Arguments
866 ///
867 /// * `name` - Resource name for the location.
868 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
869 ProjectLocationGetCall {
870 hub: self.hub,
871 _name: name.to_string(),
872 _delegate: Default::default(),
873 _additional_params: Default::default(),
874 _scopes: Default::default(),
875 }
876 }
877
878 /// Create a builder to help you perform the following task:
879 ///
880 /// Lists information about the supported locations for this service.
881 ///
882 /// # Arguments
883 ///
884 /// * `name` - The resource that owns the locations collection, if applicable.
885 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
886 ProjectLocationListCall {
887 hub: self.hub,
888 _name: name.to_string(),
889 _page_token: Default::default(),
890 _page_size: Default::default(),
891 _filter: Default::default(),
892 _delegate: Default::default(),
893 _additional_params: Default::default(),
894 _scopes: Default::default(),
895 }
896 }
897}
898
899// ###################
900// CallBuilders ###
901// #################
902
903/// Creates a new Endpoint in a given project and location.
904///
905/// A builder for the *locations.endpoints.create* method supported by a *project* resource.
906/// It is not used directly, but through a [`ProjectMethods`] instance.
907///
908/// # Example
909///
910/// Instantiate a resource method builder
911///
912/// ```test_harness,no_run
913/// # extern crate hyper;
914/// # extern crate hyper_rustls;
915/// # extern crate google_ids1 as ids1;
916/// use ids1::api::Endpoint;
917/// # async fn dox() {
918/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
919///
920/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
922/// # secret,
923/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
924/// # ).build().await.unwrap();
925///
926/// # let client = hyper_util::client::legacy::Client::builder(
927/// # hyper_util::rt::TokioExecutor::new()
928/// # )
929/// # .build(
930/// # hyper_rustls::HttpsConnectorBuilder::new()
931/// # .with_native_roots()
932/// # .unwrap()
933/// # .https_or_http()
934/// # .enable_http1()
935/// # .build()
936/// # );
937/// # let mut hub = IDS::new(client, auth);
938/// // As the method needs a request, you would usually fill it with the desired information
939/// // into the respective structure. Some of the parts shown here might not be applicable !
940/// // Values shown here are possibly random and not representative !
941/// let mut req = Endpoint::default();
942///
943/// // You can configure optional parameters by calling the respective setters at will, and
944/// // execute the final call using `doit()`.
945/// // Values shown here are possibly random and not representative !
946/// let result = hub.projects().locations_endpoints_create(req, "parent")
947/// .request_id("amet.")
948/// .endpoint_id("duo")
949/// .doit().await;
950/// # }
951/// ```
952pub struct ProjectLocationEndpointCreateCall<'a, C>
953where
954 C: 'a,
955{
956 hub: &'a IDS<C>,
957 _request: Endpoint,
958 _parent: String,
959 _request_id: Option<String>,
960 _endpoint_id: Option<String>,
961 _delegate: Option<&'a mut dyn common::Delegate>,
962 _additional_params: HashMap<String, String>,
963 _scopes: BTreeSet<String>,
964}
965
966impl<'a, C> common::CallBuilder for ProjectLocationEndpointCreateCall<'a, C> {}
967
968impl<'a, C> ProjectLocationEndpointCreateCall<'a, C>
969where
970 C: common::Connector,
971{
972 /// Perform the operation you have build so far.
973 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
974 use std::borrow::Cow;
975 use std::io::{Read, Seek};
976
977 use common::{url::Params, ToParts};
978 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
979
980 let mut dd = common::DefaultDelegate;
981 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
982 dlg.begin(common::MethodInfo {
983 id: "ids.projects.locations.endpoints.create",
984 http_method: hyper::Method::POST,
985 });
986
987 for &field in ["alt", "parent", "requestId", "endpointId"].iter() {
988 if self._additional_params.contains_key(field) {
989 dlg.finished(false);
990 return Err(common::Error::FieldClash(field));
991 }
992 }
993
994 let mut params = Params::with_capacity(6 + self._additional_params.len());
995 params.push("parent", self._parent);
996 if let Some(value) = self._request_id.as_ref() {
997 params.push("requestId", value);
998 }
999 if let Some(value) = self._endpoint_id.as_ref() {
1000 params.push("endpointId", value);
1001 }
1002
1003 params.extend(self._additional_params.iter());
1004
1005 params.push("alt", "json");
1006 let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpoints";
1007 if self._scopes.is_empty() {
1008 self._scopes
1009 .insert(Scope::CloudPlatform.as_ref().to_string());
1010 }
1011
1012 #[allow(clippy::single_element_loop)]
1013 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1014 url = params.uri_replacement(url, param_name, find_this, true);
1015 }
1016 {
1017 let to_remove = ["parent"];
1018 params.remove_params(&to_remove);
1019 }
1020
1021 let url = params.parse_with_url(&url);
1022
1023 let mut json_mime_type = mime::APPLICATION_JSON;
1024 let mut request_value_reader = {
1025 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1026 common::remove_json_null_values(&mut value);
1027 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1028 serde_json::to_writer(&mut dst, &value).unwrap();
1029 dst
1030 };
1031 let request_size = request_value_reader
1032 .seek(std::io::SeekFrom::End(0))
1033 .unwrap();
1034 request_value_reader
1035 .seek(std::io::SeekFrom::Start(0))
1036 .unwrap();
1037
1038 loop {
1039 let token = match self
1040 .hub
1041 .auth
1042 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1043 .await
1044 {
1045 Ok(token) => token,
1046 Err(e) => match dlg.token(e) {
1047 Ok(token) => token,
1048 Err(e) => {
1049 dlg.finished(false);
1050 return Err(common::Error::MissingToken(e));
1051 }
1052 },
1053 };
1054 request_value_reader
1055 .seek(std::io::SeekFrom::Start(0))
1056 .unwrap();
1057 let mut req_result = {
1058 let client = &self.hub.client;
1059 dlg.pre_request();
1060 let mut req_builder = hyper::Request::builder()
1061 .method(hyper::Method::POST)
1062 .uri(url.as_str())
1063 .header(USER_AGENT, self.hub._user_agent.clone());
1064
1065 if let Some(token) = token.as_ref() {
1066 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1067 }
1068
1069 let request = req_builder
1070 .header(CONTENT_TYPE, json_mime_type.to_string())
1071 .header(CONTENT_LENGTH, request_size as u64)
1072 .body(common::to_body(
1073 request_value_reader.get_ref().clone().into(),
1074 ));
1075
1076 client.request(request.unwrap()).await
1077 };
1078
1079 match req_result {
1080 Err(err) => {
1081 if let common::Retry::After(d) = dlg.http_error(&err) {
1082 sleep(d).await;
1083 continue;
1084 }
1085 dlg.finished(false);
1086 return Err(common::Error::HttpError(err));
1087 }
1088 Ok(res) => {
1089 let (mut parts, body) = res.into_parts();
1090 let mut body = common::Body::new(body);
1091 if !parts.status.is_success() {
1092 let bytes = common::to_bytes(body).await.unwrap_or_default();
1093 let error = serde_json::from_str(&common::to_string(&bytes));
1094 let response = common::to_response(parts, bytes.into());
1095
1096 if let common::Retry::After(d) =
1097 dlg.http_failure(&response, error.as_ref().ok())
1098 {
1099 sleep(d).await;
1100 continue;
1101 }
1102
1103 dlg.finished(false);
1104
1105 return Err(match error {
1106 Ok(value) => common::Error::BadRequest(value),
1107 _ => common::Error::Failure(response),
1108 });
1109 }
1110 let response = {
1111 let bytes = common::to_bytes(body).await.unwrap_or_default();
1112 let encoded = common::to_string(&bytes);
1113 match serde_json::from_str(&encoded) {
1114 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1115 Err(error) => {
1116 dlg.response_json_decode_error(&encoded, &error);
1117 return Err(common::Error::JsonDecodeError(
1118 encoded.to_string(),
1119 error,
1120 ));
1121 }
1122 }
1123 };
1124
1125 dlg.finished(true);
1126 return Ok(response);
1127 }
1128 }
1129 }
1130 }
1131
1132 ///
1133 /// Sets the *request* property to the given value.
1134 ///
1135 /// Even though the property as already been set when instantiating this call,
1136 /// we provide this method for API completeness.
1137 pub fn request(mut self, new_value: Endpoint) -> ProjectLocationEndpointCreateCall<'a, C> {
1138 self._request = new_value;
1139 self
1140 }
1141 /// Required. The endpoint's parent.
1142 ///
1143 /// Sets the *parent* path property to the given value.
1144 ///
1145 /// Even though the property as already been set when instantiating this call,
1146 /// we provide this method for API completeness.
1147 pub fn parent(mut self, new_value: &str) -> ProjectLocationEndpointCreateCall<'a, C> {
1148 self._parent = new_value.to_string();
1149 self
1150 }
1151 /// 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).
1152 ///
1153 /// Sets the *request id* query property to the given value.
1154 pub fn request_id(mut self, new_value: &str) -> ProjectLocationEndpointCreateCall<'a, C> {
1155 self._request_id = Some(new_value.to_string());
1156 self
1157 }
1158 /// 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.
1159 ///
1160 /// Sets the *endpoint id* query property to the given value.
1161 pub fn endpoint_id(mut self, new_value: &str) -> ProjectLocationEndpointCreateCall<'a, C> {
1162 self._endpoint_id = Some(new_value.to_string());
1163 self
1164 }
1165 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1166 /// while executing the actual API request.
1167 ///
1168 /// ````text
1169 /// It should be used to handle progress information, and to implement a certain level of resilience.
1170 /// ````
1171 ///
1172 /// Sets the *delegate* property to the given value.
1173 pub fn delegate(
1174 mut self,
1175 new_value: &'a mut dyn common::Delegate,
1176 ) -> ProjectLocationEndpointCreateCall<'a, C> {
1177 self._delegate = Some(new_value);
1178 self
1179 }
1180
1181 /// Set any additional parameter of the query string used in the request.
1182 /// It should be used to set parameters which are not yet available through their own
1183 /// setters.
1184 ///
1185 /// Please note that this method must not be used to set any of the known parameters
1186 /// which have their own setter method. If done anyway, the request will fail.
1187 ///
1188 /// # Additional Parameters
1189 ///
1190 /// * *$.xgafv* (query-string) - V1 error format.
1191 /// * *access_token* (query-string) - OAuth access token.
1192 /// * *alt* (query-string) - Data format for response.
1193 /// * *callback* (query-string) - JSONP
1194 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1195 /// * *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.
1196 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1197 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1198 /// * *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.
1199 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1200 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1201 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointCreateCall<'a, C>
1202 where
1203 T: AsRef<str>,
1204 {
1205 self._additional_params
1206 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1207 self
1208 }
1209
1210 /// Identifies the authorization scope for the method you are building.
1211 ///
1212 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1213 /// [`Scope::CloudPlatform`].
1214 ///
1215 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1216 /// tokens for more than one scope.
1217 ///
1218 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1219 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1220 /// sufficient, a read-write scope will do as well.
1221 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointCreateCall<'a, C>
1222 where
1223 St: AsRef<str>,
1224 {
1225 self._scopes.insert(String::from(scope.as_ref()));
1226 self
1227 }
1228 /// Identifies the authorization scope(s) for the method you are building.
1229 ///
1230 /// See [`Self::add_scope()`] for details.
1231 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointCreateCall<'a, C>
1232 where
1233 I: IntoIterator<Item = St>,
1234 St: AsRef<str>,
1235 {
1236 self._scopes
1237 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1238 self
1239 }
1240
1241 /// Removes all scopes, and no default scope will be used either.
1242 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1243 /// for details).
1244 pub fn clear_scopes(mut self) -> ProjectLocationEndpointCreateCall<'a, C> {
1245 self._scopes.clear();
1246 self
1247 }
1248}
1249
1250/// Deletes a single Endpoint.
1251///
1252/// A builder for the *locations.endpoints.delete* method supported by a *project* resource.
1253/// It is not used directly, but through a [`ProjectMethods`] instance.
1254///
1255/// # Example
1256///
1257/// Instantiate a resource method builder
1258///
1259/// ```test_harness,no_run
1260/// # extern crate hyper;
1261/// # extern crate hyper_rustls;
1262/// # extern crate google_ids1 as ids1;
1263/// # async fn dox() {
1264/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1265///
1266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1268/// # secret,
1269/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1270/// # ).build().await.unwrap();
1271///
1272/// # let client = hyper_util::client::legacy::Client::builder(
1273/// # hyper_util::rt::TokioExecutor::new()
1274/// # )
1275/// # .build(
1276/// # hyper_rustls::HttpsConnectorBuilder::new()
1277/// # .with_native_roots()
1278/// # .unwrap()
1279/// # .https_or_http()
1280/// # .enable_http1()
1281/// # .build()
1282/// # );
1283/// # let mut hub = IDS::new(client, auth);
1284/// // You can configure optional parameters by calling the respective setters at will, and
1285/// // execute the final call using `doit()`.
1286/// // Values shown here are possibly random and not representative !
1287/// let result = hub.projects().locations_endpoints_delete("name")
1288/// .request_id("gubergren")
1289/// .doit().await;
1290/// # }
1291/// ```
1292pub struct ProjectLocationEndpointDeleteCall<'a, C>
1293where
1294 C: 'a,
1295{
1296 hub: &'a IDS<C>,
1297 _name: String,
1298 _request_id: Option<String>,
1299 _delegate: Option<&'a mut dyn common::Delegate>,
1300 _additional_params: HashMap<String, String>,
1301 _scopes: BTreeSet<String>,
1302}
1303
1304impl<'a, C> common::CallBuilder for ProjectLocationEndpointDeleteCall<'a, C> {}
1305
1306impl<'a, C> ProjectLocationEndpointDeleteCall<'a, C>
1307where
1308 C: common::Connector,
1309{
1310 /// Perform the operation you have build so far.
1311 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1312 use std::borrow::Cow;
1313 use std::io::{Read, Seek};
1314
1315 use common::{url::Params, ToParts};
1316 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1317
1318 let mut dd = common::DefaultDelegate;
1319 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1320 dlg.begin(common::MethodInfo {
1321 id: "ids.projects.locations.endpoints.delete",
1322 http_method: hyper::Method::DELETE,
1323 });
1324
1325 for &field in ["alt", "name", "requestId"].iter() {
1326 if self._additional_params.contains_key(field) {
1327 dlg.finished(false);
1328 return Err(common::Error::FieldClash(field));
1329 }
1330 }
1331
1332 let mut params = Params::with_capacity(4 + self._additional_params.len());
1333 params.push("name", self._name);
1334 if let Some(value) = self._request_id.as_ref() {
1335 params.push("requestId", value);
1336 }
1337
1338 params.extend(self._additional_params.iter());
1339
1340 params.push("alt", "json");
1341 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1342 if self._scopes.is_empty() {
1343 self._scopes
1344 .insert(Scope::CloudPlatform.as_ref().to_string());
1345 }
1346
1347 #[allow(clippy::single_element_loop)]
1348 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1349 url = params.uri_replacement(url, param_name, find_this, true);
1350 }
1351 {
1352 let to_remove = ["name"];
1353 params.remove_params(&to_remove);
1354 }
1355
1356 let url = params.parse_with_url(&url);
1357
1358 loop {
1359 let token = match self
1360 .hub
1361 .auth
1362 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1363 .await
1364 {
1365 Ok(token) => token,
1366 Err(e) => match dlg.token(e) {
1367 Ok(token) => token,
1368 Err(e) => {
1369 dlg.finished(false);
1370 return Err(common::Error::MissingToken(e));
1371 }
1372 },
1373 };
1374 let mut req_result = {
1375 let client = &self.hub.client;
1376 dlg.pre_request();
1377 let mut req_builder = hyper::Request::builder()
1378 .method(hyper::Method::DELETE)
1379 .uri(url.as_str())
1380 .header(USER_AGENT, self.hub._user_agent.clone());
1381
1382 if let Some(token) = token.as_ref() {
1383 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1384 }
1385
1386 let request = req_builder
1387 .header(CONTENT_LENGTH, 0_u64)
1388 .body(common::to_body::<String>(None));
1389
1390 client.request(request.unwrap()).await
1391 };
1392
1393 match req_result {
1394 Err(err) => {
1395 if let common::Retry::After(d) = dlg.http_error(&err) {
1396 sleep(d).await;
1397 continue;
1398 }
1399 dlg.finished(false);
1400 return Err(common::Error::HttpError(err));
1401 }
1402 Ok(res) => {
1403 let (mut parts, body) = res.into_parts();
1404 let mut body = common::Body::new(body);
1405 if !parts.status.is_success() {
1406 let bytes = common::to_bytes(body).await.unwrap_or_default();
1407 let error = serde_json::from_str(&common::to_string(&bytes));
1408 let response = common::to_response(parts, bytes.into());
1409
1410 if let common::Retry::After(d) =
1411 dlg.http_failure(&response, error.as_ref().ok())
1412 {
1413 sleep(d).await;
1414 continue;
1415 }
1416
1417 dlg.finished(false);
1418
1419 return Err(match error {
1420 Ok(value) => common::Error::BadRequest(value),
1421 _ => common::Error::Failure(response),
1422 });
1423 }
1424 let response = {
1425 let bytes = common::to_bytes(body).await.unwrap_or_default();
1426 let encoded = common::to_string(&bytes);
1427 match serde_json::from_str(&encoded) {
1428 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1429 Err(error) => {
1430 dlg.response_json_decode_error(&encoded, &error);
1431 return Err(common::Error::JsonDecodeError(
1432 encoded.to_string(),
1433 error,
1434 ));
1435 }
1436 }
1437 };
1438
1439 dlg.finished(true);
1440 return Ok(response);
1441 }
1442 }
1443 }
1444 }
1445
1446 /// Required. The name of the endpoint to delete.
1447 ///
1448 /// Sets the *name* path property to the given value.
1449 ///
1450 /// Even though the property as already been set when instantiating this call,
1451 /// we provide this method for API completeness.
1452 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointDeleteCall<'a, C> {
1453 self._name = new_value.to_string();
1454 self
1455 }
1456 /// 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).
1457 ///
1458 /// Sets the *request id* query property to the given value.
1459 pub fn request_id(mut self, new_value: &str) -> ProjectLocationEndpointDeleteCall<'a, C> {
1460 self._request_id = Some(new_value.to_string());
1461 self
1462 }
1463 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1464 /// while executing the actual API request.
1465 ///
1466 /// ````text
1467 /// It should be used to handle progress information, and to implement a certain level of resilience.
1468 /// ````
1469 ///
1470 /// Sets the *delegate* property to the given value.
1471 pub fn delegate(
1472 mut self,
1473 new_value: &'a mut dyn common::Delegate,
1474 ) -> ProjectLocationEndpointDeleteCall<'a, C> {
1475 self._delegate = Some(new_value);
1476 self
1477 }
1478
1479 /// Set any additional parameter of the query string used in the request.
1480 /// It should be used to set parameters which are not yet available through their own
1481 /// setters.
1482 ///
1483 /// Please note that this method must not be used to set any of the known parameters
1484 /// which have their own setter method. If done anyway, the request will fail.
1485 ///
1486 /// # Additional Parameters
1487 ///
1488 /// * *$.xgafv* (query-string) - V1 error format.
1489 /// * *access_token* (query-string) - OAuth access token.
1490 /// * *alt* (query-string) - Data format for response.
1491 /// * *callback* (query-string) - JSONP
1492 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1493 /// * *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.
1494 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1495 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1496 /// * *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.
1497 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1498 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1499 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointDeleteCall<'a, C>
1500 where
1501 T: AsRef<str>,
1502 {
1503 self._additional_params
1504 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1505 self
1506 }
1507
1508 /// Identifies the authorization scope for the method you are building.
1509 ///
1510 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1511 /// [`Scope::CloudPlatform`].
1512 ///
1513 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1514 /// tokens for more than one scope.
1515 ///
1516 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1517 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1518 /// sufficient, a read-write scope will do as well.
1519 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointDeleteCall<'a, C>
1520 where
1521 St: AsRef<str>,
1522 {
1523 self._scopes.insert(String::from(scope.as_ref()));
1524 self
1525 }
1526 /// Identifies the authorization scope(s) for the method you are building.
1527 ///
1528 /// See [`Self::add_scope()`] for details.
1529 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointDeleteCall<'a, C>
1530 where
1531 I: IntoIterator<Item = St>,
1532 St: AsRef<str>,
1533 {
1534 self._scopes
1535 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1536 self
1537 }
1538
1539 /// Removes all scopes, and no default scope will be used either.
1540 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1541 /// for details).
1542 pub fn clear_scopes(mut self) -> ProjectLocationEndpointDeleteCall<'a, C> {
1543 self._scopes.clear();
1544 self
1545 }
1546}
1547
1548/// Gets details of a single Endpoint.
1549///
1550/// A builder for the *locations.endpoints.get* method supported by a *project* resource.
1551/// It is not used directly, but through a [`ProjectMethods`] instance.
1552///
1553/// # Example
1554///
1555/// Instantiate a resource method builder
1556///
1557/// ```test_harness,no_run
1558/// # extern crate hyper;
1559/// # extern crate hyper_rustls;
1560/// # extern crate google_ids1 as ids1;
1561/// # async fn dox() {
1562/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1563///
1564/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1565/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1566/// # secret,
1567/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1568/// # ).build().await.unwrap();
1569///
1570/// # let client = hyper_util::client::legacy::Client::builder(
1571/// # hyper_util::rt::TokioExecutor::new()
1572/// # )
1573/// # .build(
1574/// # hyper_rustls::HttpsConnectorBuilder::new()
1575/// # .with_native_roots()
1576/// # .unwrap()
1577/// # .https_or_http()
1578/// # .enable_http1()
1579/// # .build()
1580/// # );
1581/// # let mut hub = IDS::new(client, auth);
1582/// // You can configure optional parameters by calling the respective setters at will, and
1583/// // execute the final call using `doit()`.
1584/// // Values shown here are possibly random and not representative !
1585/// let result = hub.projects().locations_endpoints_get("name")
1586/// .doit().await;
1587/// # }
1588/// ```
1589pub struct ProjectLocationEndpointGetCall<'a, C>
1590where
1591 C: 'a,
1592{
1593 hub: &'a IDS<C>,
1594 _name: String,
1595 _delegate: Option<&'a mut dyn common::Delegate>,
1596 _additional_params: HashMap<String, String>,
1597 _scopes: BTreeSet<String>,
1598}
1599
1600impl<'a, C> common::CallBuilder for ProjectLocationEndpointGetCall<'a, C> {}
1601
1602impl<'a, C> ProjectLocationEndpointGetCall<'a, C>
1603where
1604 C: common::Connector,
1605{
1606 /// Perform the operation you have build so far.
1607 pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> {
1608 use std::borrow::Cow;
1609 use std::io::{Read, Seek};
1610
1611 use common::{url::Params, ToParts};
1612 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1613
1614 let mut dd = common::DefaultDelegate;
1615 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1616 dlg.begin(common::MethodInfo {
1617 id: "ids.projects.locations.endpoints.get",
1618 http_method: hyper::Method::GET,
1619 });
1620
1621 for &field in ["alt", "name"].iter() {
1622 if self._additional_params.contains_key(field) {
1623 dlg.finished(false);
1624 return Err(common::Error::FieldClash(field));
1625 }
1626 }
1627
1628 let mut params = Params::with_capacity(3 + self._additional_params.len());
1629 params.push("name", self._name);
1630
1631 params.extend(self._additional_params.iter());
1632
1633 params.push("alt", "json");
1634 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1635 if self._scopes.is_empty() {
1636 self._scopes
1637 .insert(Scope::CloudPlatform.as_ref().to_string());
1638 }
1639
1640 #[allow(clippy::single_element_loop)]
1641 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1642 url = params.uri_replacement(url, param_name, find_this, true);
1643 }
1644 {
1645 let to_remove = ["name"];
1646 params.remove_params(&to_remove);
1647 }
1648
1649 let url = params.parse_with_url(&url);
1650
1651 loop {
1652 let token = match self
1653 .hub
1654 .auth
1655 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1656 .await
1657 {
1658 Ok(token) => token,
1659 Err(e) => match dlg.token(e) {
1660 Ok(token) => token,
1661 Err(e) => {
1662 dlg.finished(false);
1663 return Err(common::Error::MissingToken(e));
1664 }
1665 },
1666 };
1667 let mut req_result = {
1668 let client = &self.hub.client;
1669 dlg.pre_request();
1670 let mut req_builder = hyper::Request::builder()
1671 .method(hyper::Method::GET)
1672 .uri(url.as_str())
1673 .header(USER_AGENT, self.hub._user_agent.clone());
1674
1675 if let Some(token) = token.as_ref() {
1676 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1677 }
1678
1679 let request = req_builder
1680 .header(CONTENT_LENGTH, 0_u64)
1681 .body(common::to_body::<String>(None));
1682
1683 client.request(request.unwrap()).await
1684 };
1685
1686 match req_result {
1687 Err(err) => {
1688 if let common::Retry::After(d) = dlg.http_error(&err) {
1689 sleep(d).await;
1690 continue;
1691 }
1692 dlg.finished(false);
1693 return Err(common::Error::HttpError(err));
1694 }
1695 Ok(res) => {
1696 let (mut parts, body) = res.into_parts();
1697 let mut body = common::Body::new(body);
1698 if !parts.status.is_success() {
1699 let bytes = common::to_bytes(body).await.unwrap_or_default();
1700 let error = serde_json::from_str(&common::to_string(&bytes));
1701 let response = common::to_response(parts, bytes.into());
1702
1703 if let common::Retry::After(d) =
1704 dlg.http_failure(&response, error.as_ref().ok())
1705 {
1706 sleep(d).await;
1707 continue;
1708 }
1709
1710 dlg.finished(false);
1711
1712 return Err(match error {
1713 Ok(value) => common::Error::BadRequest(value),
1714 _ => common::Error::Failure(response),
1715 });
1716 }
1717 let response = {
1718 let bytes = common::to_bytes(body).await.unwrap_or_default();
1719 let encoded = common::to_string(&bytes);
1720 match serde_json::from_str(&encoded) {
1721 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1722 Err(error) => {
1723 dlg.response_json_decode_error(&encoded, &error);
1724 return Err(common::Error::JsonDecodeError(
1725 encoded.to_string(),
1726 error,
1727 ));
1728 }
1729 }
1730 };
1731
1732 dlg.finished(true);
1733 return Ok(response);
1734 }
1735 }
1736 }
1737 }
1738
1739 /// Required. The name of the endpoint to retrieve. Format: projects/{project}/locations/{location}/endpoints/{endpoint}
1740 ///
1741 /// Sets the *name* path property to the given value.
1742 ///
1743 /// Even though the property as already been set when instantiating this call,
1744 /// we provide this method for API completeness.
1745 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointGetCall<'a, C> {
1746 self._name = new_value.to_string();
1747 self
1748 }
1749 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1750 /// while executing the actual API request.
1751 ///
1752 /// ````text
1753 /// It should be used to handle progress information, and to implement a certain level of resilience.
1754 /// ````
1755 ///
1756 /// Sets the *delegate* property to the given value.
1757 pub fn delegate(
1758 mut self,
1759 new_value: &'a mut dyn common::Delegate,
1760 ) -> ProjectLocationEndpointGetCall<'a, C> {
1761 self._delegate = Some(new_value);
1762 self
1763 }
1764
1765 /// Set any additional parameter of the query string used in the request.
1766 /// It should be used to set parameters which are not yet available through their own
1767 /// setters.
1768 ///
1769 /// Please note that this method must not be used to set any of the known parameters
1770 /// which have their own setter method. If done anyway, the request will fail.
1771 ///
1772 /// # Additional Parameters
1773 ///
1774 /// * *$.xgafv* (query-string) - V1 error format.
1775 /// * *access_token* (query-string) - OAuth access token.
1776 /// * *alt* (query-string) - Data format for response.
1777 /// * *callback* (query-string) - JSONP
1778 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1779 /// * *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.
1780 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1781 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1782 /// * *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.
1783 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1784 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1785 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointGetCall<'a, C>
1786 where
1787 T: AsRef<str>,
1788 {
1789 self._additional_params
1790 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1791 self
1792 }
1793
1794 /// Identifies the authorization scope for the method you are building.
1795 ///
1796 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1797 /// [`Scope::CloudPlatform`].
1798 ///
1799 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1800 /// tokens for more than one scope.
1801 ///
1802 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1803 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1804 /// sufficient, a read-write scope will do as well.
1805 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointGetCall<'a, C>
1806 where
1807 St: AsRef<str>,
1808 {
1809 self._scopes.insert(String::from(scope.as_ref()));
1810 self
1811 }
1812 /// Identifies the authorization scope(s) for the method you are building.
1813 ///
1814 /// See [`Self::add_scope()`] for details.
1815 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointGetCall<'a, C>
1816 where
1817 I: IntoIterator<Item = St>,
1818 St: AsRef<str>,
1819 {
1820 self._scopes
1821 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1822 self
1823 }
1824
1825 /// Removes all scopes, and no default scope will be used either.
1826 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1827 /// for details).
1828 pub fn clear_scopes(mut self) -> ProjectLocationEndpointGetCall<'a, C> {
1829 self._scopes.clear();
1830 self
1831 }
1832}
1833
1834/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1835///
1836/// A builder for the *locations.endpoints.getIamPolicy* method supported by a *project* resource.
1837/// It is not used directly, but through a [`ProjectMethods`] instance.
1838///
1839/// # Example
1840///
1841/// Instantiate a resource method builder
1842///
1843/// ```test_harness,no_run
1844/// # extern crate hyper;
1845/// # extern crate hyper_rustls;
1846/// # extern crate google_ids1 as ids1;
1847/// # async fn dox() {
1848/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1849///
1850/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1851/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1852/// # secret,
1853/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1854/// # ).build().await.unwrap();
1855///
1856/// # let client = hyper_util::client::legacy::Client::builder(
1857/// # hyper_util::rt::TokioExecutor::new()
1858/// # )
1859/// # .build(
1860/// # hyper_rustls::HttpsConnectorBuilder::new()
1861/// # .with_native_roots()
1862/// # .unwrap()
1863/// # .https_or_http()
1864/// # .enable_http1()
1865/// # .build()
1866/// # );
1867/// # let mut hub = IDS::new(client, auth);
1868/// // You can configure optional parameters by calling the respective setters at will, and
1869/// // execute the final call using `doit()`.
1870/// // Values shown here are possibly random and not representative !
1871/// let result = hub.projects().locations_endpoints_get_iam_policy("resource")
1872/// .options_requested_policy_version(-75)
1873/// .doit().await;
1874/// # }
1875/// ```
1876pub struct ProjectLocationEndpointGetIamPolicyCall<'a, C>
1877where
1878 C: 'a,
1879{
1880 hub: &'a IDS<C>,
1881 _resource: String,
1882 _options_requested_policy_version: Option<i32>,
1883 _delegate: Option<&'a mut dyn common::Delegate>,
1884 _additional_params: HashMap<String, String>,
1885 _scopes: BTreeSet<String>,
1886}
1887
1888impl<'a, C> common::CallBuilder for ProjectLocationEndpointGetIamPolicyCall<'a, C> {}
1889
1890impl<'a, C> ProjectLocationEndpointGetIamPolicyCall<'a, C>
1891where
1892 C: common::Connector,
1893{
1894 /// Perform the operation you have build so far.
1895 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
1896 use std::borrow::Cow;
1897 use std::io::{Read, Seek};
1898
1899 use common::{url::Params, ToParts};
1900 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1901
1902 let mut dd = common::DefaultDelegate;
1903 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1904 dlg.begin(common::MethodInfo {
1905 id: "ids.projects.locations.endpoints.getIamPolicy",
1906 http_method: hyper::Method::GET,
1907 });
1908
1909 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
1910 if self._additional_params.contains_key(field) {
1911 dlg.finished(false);
1912 return Err(common::Error::FieldClash(field));
1913 }
1914 }
1915
1916 let mut params = Params::with_capacity(4 + self._additional_params.len());
1917 params.push("resource", self._resource);
1918 if let Some(value) = self._options_requested_policy_version.as_ref() {
1919 params.push("options.requestedPolicyVersion", value.to_string());
1920 }
1921
1922 params.extend(self._additional_params.iter());
1923
1924 params.push("alt", "json");
1925 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
1926 if self._scopes.is_empty() {
1927 self._scopes
1928 .insert(Scope::CloudPlatform.as_ref().to_string());
1929 }
1930
1931 #[allow(clippy::single_element_loop)]
1932 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
1933 url = params.uri_replacement(url, param_name, find_this, true);
1934 }
1935 {
1936 let to_remove = ["resource"];
1937 params.remove_params(&to_remove);
1938 }
1939
1940 let url = params.parse_with_url(&url);
1941
1942 loop {
1943 let token = match self
1944 .hub
1945 .auth
1946 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1947 .await
1948 {
1949 Ok(token) => token,
1950 Err(e) => match dlg.token(e) {
1951 Ok(token) => token,
1952 Err(e) => {
1953 dlg.finished(false);
1954 return Err(common::Error::MissingToken(e));
1955 }
1956 },
1957 };
1958 let mut req_result = {
1959 let client = &self.hub.client;
1960 dlg.pre_request();
1961 let mut req_builder = hyper::Request::builder()
1962 .method(hyper::Method::GET)
1963 .uri(url.as_str())
1964 .header(USER_AGENT, self.hub._user_agent.clone());
1965
1966 if let Some(token) = token.as_ref() {
1967 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1968 }
1969
1970 let request = req_builder
1971 .header(CONTENT_LENGTH, 0_u64)
1972 .body(common::to_body::<String>(None));
1973
1974 client.request(request.unwrap()).await
1975 };
1976
1977 match req_result {
1978 Err(err) => {
1979 if let common::Retry::After(d) = dlg.http_error(&err) {
1980 sleep(d).await;
1981 continue;
1982 }
1983 dlg.finished(false);
1984 return Err(common::Error::HttpError(err));
1985 }
1986 Ok(res) => {
1987 let (mut parts, body) = res.into_parts();
1988 let mut body = common::Body::new(body);
1989 if !parts.status.is_success() {
1990 let bytes = common::to_bytes(body).await.unwrap_or_default();
1991 let error = serde_json::from_str(&common::to_string(&bytes));
1992 let response = common::to_response(parts, bytes.into());
1993
1994 if let common::Retry::After(d) =
1995 dlg.http_failure(&response, error.as_ref().ok())
1996 {
1997 sleep(d).await;
1998 continue;
1999 }
2000
2001 dlg.finished(false);
2002
2003 return Err(match error {
2004 Ok(value) => common::Error::BadRequest(value),
2005 _ => common::Error::Failure(response),
2006 });
2007 }
2008 let response = {
2009 let bytes = common::to_bytes(body).await.unwrap_or_default();
2010 let encoded = common::to_string(&bytes);
2011 match serde_json::from_str(&encoded) {
2012 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2013 Err(error) => {
2014 dlg.response_json_decode_error(&encoded, &error);
2015 return Err(common::Error::JsonDecodeError(
2016 encoded.to_string(),
2017 error,
2018 ));
2019 }
2020 }
2021 };
2022
2023 dlg.finished(true);
2024 return Ok(response);
2025 }
2026 }
2027 }
2028 }
2029
2030 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2031 ///
2032 /// Sets the *resource* path property to the given value.
2033 ///
2034 /// Even though the property as already been set when instantiating this call,
2035 /// we provide this method for API completeness.
2036 pub fn resource(mut self, new_value: &str) -> ProjectLocationEndpointGetIamPolicyCall<'a, C> {
2037 self._resource = new_value.to_string();
2038 self
2039 }
2040 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
2041 ///
2042 /// Sets the *options.requested policy version* query property to the given value.
2043 pub fn options_requested_policy_version(
2044 mut self,
2045 new_value: i32,
2046 ) -> ProjectLocationEndpointGetIamPolicyCall<'a, C> {
2047 self._options_requested_policy_version = Some(new_value);
2048 self
2049 }
2050 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2051 /// while executing the actual API request.
2052 ///
2053 /// ````text
2054 /// It should be used to handle progress information, and to implement a certain level of resilience.
2055 /// ````
2056 ///
2057 /// Sets the *delegate* property to the given value.
2058 pub fn delegate(
2059 mut self,
2060 new_value: &'a mut dyn common::Delegate,
2061 ) -> ProjectLocationEndpointGetIamPolicyCall<'a, C> {
2062 self._delegate = Some(new_value);
2063 self
2064 }
2065
2066 /// Set any additional parameter of the query string used in the request.
2067 /// It should be used to set parameters which are not yet available through their own
2068 /// setters.
2069 ///
2070 /// Please note that this method must not be used to set any of the known parameters
2071 /// which have their own setter method. If done anyway, the request will fail.
2072 ///
2073 /// # Additional Parameters
2074 ///
2075 /// * *$.xgafv* (query-string) - V1 error format.
2076 /// * *access_token* (query-string) - OAuth access token.
2077 /// * *alt* (query-string) - Data format for response.
2078 /// * *callback* (query-string) - JSONP
2079 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2080 /// * *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.
2081 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2082 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2083 /// * *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.
2084 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2085 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2086 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointGetIamPolicyCall<'a, C>
2087 where
2088 T: AsRef<str>,
2089 {
2090 self._additional_params
2091 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2092 self
2093 }
2094
2095 /// Identifies the authorization scope for the method you are building.
2096 ///
2097 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2098 /// [`Scope::CloudPlatform`].
2099 ///
2100 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2101 /// tokens for more than one scope.
2102 ///
2103 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2104 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2105 /// sufficient, a read-write scope will do as well.
2106 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointGetIamPolicyCall<'a, C>
2107 where
2108 St: AsRef<str>,
2109 {
2110 self._scopes.insert(String::from(scope.as_ref()));
2111 self
2112 }
2113 /// Identifies the authorization scope(s) for the method you are building.
2114 ///
2115 /// See [`Self::add_scope()`] for details.
2116 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointGetIamPolicyCall<'a, C>
2117 where
2118 I: IntoIterator<Item = St>,
2119 St: AsRef<str>,
2120 {
2121 self._scopes
2122 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2123 self
2124 }
2125
2126 /// Removes all scopes, and no default scope will be used either.
2127 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2128 /// for details).
2129 pub fn clear_scopes(mut self) -> ProjectLocationEndpointGetIamPolicyCall<'a, C> {
2130 self._scopes.clear();
2131 self
2132 }
2133}
2134
2135/// Lists Endpoints in a given project and location.
2136///
2137/// A builder for the *locations.endpoints.list* method supported by a *project* resource.
2138/// It is not used directly, but through a [`ProjectMethods`] instance.
2139///
2140/// # Example
2141///
2142/// Instantiate a resource method builder
2143///
2144/// ```test_harness,no_run
2145/// # extern crate hyper;
2146/// # extern crate hyper_rustls;
2147/// # extern crate google_ids1 as ids1;
2148/// # async fn dox() {
2149/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2150///
2151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2152/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2153/// # secret,
2154/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2155/// # ).build().await.unwrap();
2156///
2157/// # let client = hyper_util::client::legacy::Client::builder(
2158/// # hyper_util::rt::TokioExecutor::new()
2159/// # )
2160/// # .build(
2161/// # hyper_rustls::HttpsConnectorBuilder::new()
2162/// # .with_native_roots()
2163/// # .unwrap()
2164/// # .https_or_http()
2165/// # .enable_http1()
2166/// # .build()
2167/// # );
2168/// # let mut hub = IDS::new(client, auth);
2169/// // You can configure optional parameters by calling the respective setters at will, and
2170/// // execute the final call using `doit()`.
2171/// // Values shown here are possibly random and not representative !
2172/// let result = hub.projects().locations_endpoints_list("parent")
2173/// .page_token("ea")
2174/// .page_size(-55)
2175/// .order_by("invidunt")
2176/// .filter("amet")
2177/// .doit().await;
2178/// # }
2179/// ```
2180pub struct ProjectLocationEndpointListCall<'a, C>
2181where
2182 C: 'a,
2183{
2184 hub: &'a IDS<C>,
2185 _parent: String,
2186 _page_token: Option<String>,
2187 _page_size: Option<i32>,
2188 _order_by: Option<String>,
2189 _filter: Option<String>,
2190 _delegate: Option<&'a mut dyn common::Delegate>,
2191 _additional_params: HashMap<String, String>,
2192 _scopes: BTreeSet<String>,
2193}
2194
2195impl<'a, C> common::CallBuilder for ProjectLocationEndpointListCall<'a, C> {}
2196
2197impl<'a, C> ProjectLocationEndpointListCall<'a, C>
2198where
2199 C: common::Connector,
2200{
2201 /// Perform the operation you have build so far.
2202 pub async fn doit(mut self) -> common::Result<(common::Response, ListEndpointsResponse)> {
2203 use std::borrow::Cow;
2204 use std::io::{Read, Seek};
2205
2206 use common::{url::Params, ToParts};
2207 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2208
2209 let mut dd = common::DefaultDelegate;
2210 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2211 dlg.begin(common::MethodInfo {
2212 id: "ids.projects.locations.endpoints.list",
2213 http_method: hyper::Method::GET,
2214 });
2215
2216 for &field in [
2217 "alt",
2218 "parent",
2219 "pageToken",
2220 "pageSize",
2221 "orderBy",
2222 "filter",
2223 ]
2224 .iter()
2225 {
2226 if self._additional_params.contains_key(field) {
2227 dlg.finished(false);
2228 return Err(common::Error::FieldClash(field));
2229 }
2230 }
2231
2232 let mut params = Params::with_capacity(7 + self._additional_params.len());
2233 params.push("parent", self._parent);
2234 if let Some(value) = self._page_token.as_ref() {
2235 params.push("pageToken", value);
2236 }
2237 if let Some(value) = self._page_size.as_ref() {
2238 params.push("pageSize", value.to_string());
2239 }
2240 if let Some(value) = self._order_by.as_ref() {
2241 params.push("orderBy", value);
2242 }
2243 if let Some(value) = self._filter.as_ref() {
2244 params.push("filter", value);
2245 }
2246
2247 params.extend(self._additional_params.iter());
2248
2249 params.push("alt", "json");
2250 let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpoints";
2251 if self._scopes.is_empty() {
2252 self._scopes
2253 .insert(Scope::CloudPlatform.as_ref().to_string());
2254 }
2255
2256 #[allow(clippy::single_element_loop)]
2257 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2258 url = params.uri_replacement(url, param_name, find_this, true);
2259 }
2260 {
2261 let to_remove = ["parent"];
2262 params.remove_params(&to_remove);
2263 }
2264
2265 let url = params.parse_with_url(&url);
2266
2267 loop {
2268 let token = match self
2269 .hub
2270 .auth
2271 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2272 .await
2273 {
2274 Ok(token) => token,
2275 Err(e) => match dlg.token(e) {
2276 Ok(token) => token,
2277 Err(e) => {
2278 dlg.finished(false);
2279 return Err(common::Error::MissingToken(e));
2280 }
2281 },
2282 };
2283 let mut req_result = {
2284 let client = &self.hub.client;
2285 dlg.pre_request();
2286 let mut req_builder = hyper::Request::builder()
2287 .method(hyper::Method::GET)
2288 .uri(url.as_str())
2289 .header(USER_AGENT, self.hub._user_agent.clone());
2290
2291 if let Some(token) = token.as_ref() {
2292 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2293 }
2294
2295 let request = req_builder
2296 .header(CONTENT_LENGTH, 0_u64)
2297 .body(common::to_body::<String>(None));
2298
2299 client.request(request.unwrap()).await
2300 };
2301
2302 match req_result {
2303 Err(err) => {
2304 if let common::Retry::After(d) = dlg.http_error(&err) {
2305 sleep(d).await;
2306 continue;
2307 }
2308 dlg.finished(false);
2309 return Err(common::Error::HttpError(err));
2310 }
2311 Ok(res) => {
2312 let (mut parts, body) = res.into_parts();
2313 let mut body = common::Body::new(body);
2314 if !parts.status.is_success() {
2315 let bytes = common::to_bytes(body).await.unwrap_or_default();
2316 let error = serde_json::from_str(&common::to_string(&bytes));
2317 let response = common::to_response(parts, bytes.into());
2318
2319 if let common::Retry::After(d) =
2320 dlg.http_failure(&response, error.as_ref().ok())
2321 {
2322 sleep(d).await;
2323 continue;
2324 }
2325
2326 dlg.finished(false);
2327
2328 return Err(match error {
2329 Ok(value) => common::Error::BadRequest(value),
2330 _ => common::Error::Failure(response),
2331 });
2332 }
2333 let response = {
2334 let bytes = common::to_bytes(body).await.unwrap_or_default();
2335 let encoded = common::to_string(&bytes);
2336 match serde_json::from_str(&encoded) {
2337 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2338 Err(error) => {
2339 dlg.response_json_decode_error(&encoded, &error);
2340 return Err(common::Error::JsonDecodeError(
2341 encoded.to_string(),
2342 error,
2343 ));
2344 }
2345 }
2346 };
2347
2348 dlg.finished(true);
2349 return Ok(response);
2350 }
2351 }
2352 }
2353 }
2354
2355 /// Required. The parent, which owns this collection of endpoints.
2356 ///
2357 /// Sets the *parent* path property to the given value.
2358 ///
2359 /// Even though the property as already been set when instantiating this call,
2360 /// we provide this method for API completeness.
2361 pub fn parent(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
2362 self._parent = new_value.to_string();
2363 self
2364 }
2365 /// 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.
2366 ///
2367 /// Sets the *page token* query property to the given value.
2368 pub fn page_token(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
2369 self._page_token = Some(new_value.to_string());
2370 self
2371 }
2372 /// Optional. The maximum number of endpoints to return. The service may return fewer than this value.
2373 ///
2374 /// Sets the *page size* query property to the given value.
2375 pub fn page_size(mut self, new_value: i32) -> ProjectLocationEndpointListCall<'a, C> {
2376 self._page_size = Some(new_value);
2377 self
2378 }
2379 /// Optional. One or more fields to compare and use to sort the output. See https://google.aip.dev/132#ordering.
2380 ///
2381 /// Sets the *order by* query property to the given value.
2382 pub fn order_by(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
2383 self._order_by = Some(new_value.to_string());
2384 self
2385 }
2386 /// Optional. The filter expression, following the syntax outlined in https://google.aip.dev/160.
2387 ///
2388 /// Sets the *filter* query property to the given value.
2389 pub fn filter(mut self, new_value: &str) -> ProjectLocationEndpointListCall<'a, C> {
2390 self._filter = Some(new_value.to_string());
2391 self
2392 }
2393 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2394 /// while executing the actual API request.
2395 ///
2396 /// ````text
2397 /// It should be used to handle progress information, and to implement a certain level of resilience.
2398 /// ````
2399 ///
2400 /// Sets the *delegate* property to the given value.
2401 pub fn delegate(
2402 mut self,
2403 new_value: &'a mut dyn common::Delegate,
2404 ) -> ProjectLocationEndpointListCall<'a, C> {
2405 self._delegate = Some(new_value);
2406 self
2407 }
2408
2409 /// Set any additional parameter of the query string used in the request.
2410 /// It should be used to set parameters which are not yet available through their own
2411 /// setters.
2412 ///
2413 /// Please note that this method must not be used to set any of the known parameters
2414 /// which have their own setter method. If done anyway, the request will fail.
2415 ///
2416 /// # Additional Parameters
2417 ///
2418 /// * *$.xgafv* (query-string) - V1 error format.
2419 /// * *access_token* (query-string) - OAuth access token.
2420 /// * *alt* (query-string) - Data format for response.
2421 /// * *callback* (query-string) - JSONP
2422 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2423 /// * *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.
2424 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2425 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2426 /// * *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.
2427 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2428 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2429 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointListCall<'a, C>
2430 where
2431 T: AsRef<str>,
2432 {
2433 self._additional_params
2434 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2435 self
2436 }
2437
2438 /// Identifies the authorization scope for the method you are building.
2439 ///
2440 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2441 /// [`Scope::CloudPlatform`].
2442 ///
2443 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2444 /// tokens for more than one scope.
2445 ///
2446 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2447 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2448 /// sufficient, a read-write scope will do as well.
2449 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointListCall<'a, C>
2450 where
2451 St: AsRef<str>,
2452 {
2453 self._scopes.insert(String::from(scope.as_ref()));
2454 self
2455 }
2456 /// Identifies the authorization scope(s) for the method you are building.
2457 ///
2458 /// See [`Self::add_scope()`] for details.
2459 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointListCall<'a, C>
2460 where
2461 I: IntoIterator<Item = St>,
2462 St: AsRef<str>,
2463 {
2464 self._scopes
2465 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2466 self
2467 }
2468
2469 /// Removes all scopes, and no default scope will be used either.
2470 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2471 /// for details).
2472 pub fn clear_scopes(mut self) -> ProjectLocationEndpointListCall<'a, C> {
2473 self._scopes.clear();
2474 self
2475 }
2476}
2477
2478/// Updates the parameters of a single Endpoint.
2479///
2480/// A builder for the *locations.endpoints.patch* method supported by a *project* resource.
2481/// It is not used directly, but through a [`ProjectMethods`] instance.
2482///
2483/// # Example
2484///
2485/// Instantiate a resource method builder
2486///
2487/// ```test_harness,no_run
2488/// # extern crate hyper;
2489/// # extern crate hyper_rustls;
2490/// # extern crate google_ids1 as ids1;
2491/// use ids1::api::Endpoint;
2492/// # async fn dox() {
2493/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2494///
2495/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2496/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2497/// # secret,
2498/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2499/// # ).build().await.unwrap();
2500///
2501/// # let client = hyper_util::client::legacy::Client::builder(
2502/// # hyper_util::rt::TokioExecutor::new()
2503/// # )
2504/// # .build(
2505/// # hyper_rustls::HttpsConnectorBuilder::new()
2506/// # .with_native_roots()
2507/// # .unwrap()
2508/// # .https_or_http()
2509/// # .enable_http1()
2510/// # .build()
2511/// # );
2512/// # let mut hub = IDS::new(client, auth);
2513/// // As the method needs a request, you would usually fill it with the desired information
2514/// // into the respective structure. Some of the parts shown here might not be applicable !
2515/// // Values shown here are possibly random and not representative !
2516/// let mut req = Endpoint::default();
2517///
2518/// // You can configure optional parameters by calling the respective setters at will, and
2519/// // execute the final call using `doit()`.
2520/// // Values shown here are possibly random and not representative !
2521/// let result = hub.projects().locations_endpoints_patch(req, "name")
2522/// .update_mask(FieldMask::new::<&str>(&[]))
2523/// .request_id("ipsum")
2524/// .doit().await;
2525/// # }
2526/// ```
2527pub struct ProjectLocationEndpointPatchCall<'a, C>
2528where
2529 C: 'a,
2530{
2531 hub: &'a IDS<C>,
2532 _request: Endpoint,
2533 _name: String,
2534 _update_mask: Option<common::FieldMask>,
2535 _request_id: Option<String>,
2536 _delegate: Option<&'a mut dyn common::Delegate>,
2537 _additional_params: HashMap<String, String>,
2538 _scopes: BTreeSet<String>,
2539}
2540
2541impl<'a, C> common::CallBuilder for ProjectLocationEndpointPatchCall<'a, C> {}
2542
2543impl<'a, C> ProjectLocationEndpointPatchCall<'a, C>
2544where
2545 C: common::Connector,
2546{
2547 /// Perform the operation you have build so far.
2548 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2549 use std::borrow::Cow;
2550 use std::io::{Read, Seek};
2551
2552 use common::{url::Params, ToParts};
2553 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2554
2555 let mut dd = common::DefaultDelegate;
2556 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2557 dlg.begin(common::MethodInfo {
2558 id: "ids.projects.locations.endpoints.patch",
2559 http_method: hyper::Method::PATCH,
2560 });
2561
2562 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
2563 if self._additional_params.contains_key(field) {
2564 dlg.finished(false);
2565 return Err(common::Error::FieldClash(field));
2566 }
2567 }
2568
2569 let mut params = Params::with_capacity(6 + self._additional_params.len());
2570 params.push("name", self._name);
2571 if let Some(value) = self._update_mask.as_ref() {
2572 params.push("updateMask", value.to_string());
2573 }
2574 if let Some(value) = self._request_id.as_ref() {
2575 params.push("requestId", value);
2576 }
2577
2578 params.extend(self._additional_params.iter());
2579
2580 params.push("alt", "json");
2581 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2582 if self._scopes.is_empty() {
2583 self._scopes
2584 .insert(Scope::CloudPlatform.as_ref().to_string());
2585 }
2586
2587 #[allow(clippy::single_element_loop)]
2588 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2589 url = params.uri_replacement(url, param_name, find_this, true);
2590 }
2591 {
2592 let to_remove = ["name"];
2593 params.remove_params(&to_remove);
2594 }
2595
2596 let url = params.parse_with_url(&url);
2597
2598 let mut json_mime_type = mime::APPLICATION_JSON;
2599 let mut request_value_reader = {
2600 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2601 common::remove_json_null_values(&mut value);
2602 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2603 serde_json::to_writer(&mut dst, &value).unwrap();
2604 dst
2605 };
2606 let request_size = request_value_reader
2607 .seek(std::io::SeekFrom::End(0))
2608 .unwrap();
2609 request_value_reader
2610 .seek(std::io::SeekFrom::Start(0))
2611 .unwrap();
2612
2613 loop {
2614 let token = match self
2615 .hub
2616 .auth
2617 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2618 .await
2619 {
2620 Ok(token) => token,
2621 Err(e) => match dlg.token(e) {
2622 Ok(token) => token,
2623 Err(e) => {
2624 dlg.finished(false);
2625 return Err(common::Error::MissingToken(e));
2626 }
2627 },
2628 };
2629 request_value_reader
2630 .seek(std::io::SeekFrom::Start(0))
2631 .unwrap();
2632 let mut req_result = {
2633 let client = &self.hub.client;
2634 dlg.pre_request();
2635 let mut req_builder = hyper::Request::builder()
2636 .method(hyper::Method::PATCH)
2637 .uri(url.as_str())
2638 .header(USER_AGENT, self.hub._user_agent.clone());
2639
2640 if let Some(token) = token.as_ref() {
2641 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2642 }
2643
2644 let request = req_builder
2645 .header(CONTENT_TYPE, json_mime_type.to_string())
2646 .header(CONTENT_LENGTH, request_size as u64)
2647 .body(common::to_body(
2648 request_value_reader.get_ref().clone().into(),
2649 ));
2650
2651 client.request(request.unwrap()).await
2652 };
2653
2654 match req_result {
2655 Err(err) => {
2656 if let common::Retry::After(d) = dlg.http_error(&err) {
2657 sleep(d).await;
2658 continue;
2659 }
2660 dlg.finished(false);
2661 return Err(common::Error::HttpError(err));
2662 }
2663 Ok(res) => {
2664 let (mut parts, body) = res.into_parts();
2665 let mut body = common::Body::new(body);
2666 if !parts.status.is_success() {
2667 let bytes = common::to_bytes(body).await.unwrap_or_default();
2668 let error = serde_json::from_str(&common::to_string(&bytes));
2669 let response = common::to_response(parts, bytes.into());
2670
2671 if let common::Retry::After(d) =
2672 dlg.http_failure(&response, error.as_ref().ok())
2673 {
2674 sleep(d).await;
2675 continue;
2676 }
2677
2678 dlg.finished(false);
2679
2680 return Err(match error {
2681 Ok(value) => common::Error::BadRequest(value),
2682 _ => common::Error::Failure(response),
2683 });
2684 }
2685 let response = {
2686 let bytes = common::to_bytes(body).await.unwrap_or_default();
2687 let encoded = common::to_string(&bytes);
2688 match serde_json::from_str(&encoded) {
2689 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2690 Err(error) => {
2691 dlg.response_json_decode_error(&encoded, &error);
2692 return Err(common::Error::JsonDecodeError(
2693 encoded.to_string(),
2694 error,
2695 ));
2696 }
2697 }
2698 };
2699
2700 dlg.finished(true);
2701 return Ok(response);
2702 }
2703 }
2704 }
2705 }
2706
2707 ///
2708 /// Sets the *request* property to the given value.
2709 ///
2710 /// Even though the property as already been set when instantiating this call,
2711 /// we provide this method for API completeness.
2712 pub fn request(mut self, new_value: Endpoint) -> ProjectLocationEndpointPatchCall<'a, C> {
2713 self._request = new_value;
2714 self
2715 }
2716 /// Output only. The name of the endpoint.
2717 ///
2718 /// Sets the *name* path property to the given value.
2719 ///
2720 /// Even though the property as already been set when instantiating this call,
2721 /// we provide this method for API completeness.
2722 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointPatchCall<'a, C> {
2723 self._name = new_value.to_string();
2724 self
2725 }
2726 /// 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.
2727 ///
2728 /// Sets the *update mask* query property to the given value.
2729 pub fn update_mask(
2730 mut self,
2731 new_value: common::FieldMask,
2732 ) -> ProjectLocationEndpointPatchCall<'a, C> {
2733 self._update_mask = Some(new_value);
2734 self
2735 }
2736 /// 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).
2737 ///
2738 /// Sets the *request id* query property to the given value.
2739 pub fn request_id(mut self, new_value: &str) -> ProjectLocationEndpointPatchCall<'a, C> {
2740 self._request_id = Some(new_value.to_string());
2741 self
2742 }
2743 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2744 /// while executing the actual API request.
2745 ///
2746 /// ````text
2747 /// It should be used to handle progress information, and to implement a certain level of resilience.
2748 /// ````
2749 ///
2750 /// Sets the *delegate* property to the given value.
2751 pub fn delegate(
2752 mut self,
2753 new_value: &'a mut dyn common::Delegate,
2754 ) -> ProjectLocationEndpointPatchCall<'a, C> {
2755 self._delegate = Some(new_value);
2756 self
2757 }
2758
2759 /// Set any additional parameter of the query string used in the request.
2760 /// It should be used to set parameters which are not yet available through their own
2761 /// setters.
2762 ///
2763 /// Please note that this method must not be used to set any of the known parameters
2764 /// which have their own setter method. If done anyway, the request will fail.
2765 ///
2766 /// # Additional Parameters
2767 ///
2768 /// * *$.xgafv* (query-string) - V1 error format.
2769 /// * *access_token* (query-string) - OAuth access token.
2770 /// * *alt* (query-string) - Data format for response.
2771 /// * *callback* (query-string) - JSONP
2772 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2773 /// * *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.
2774 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2775 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2776 /// * *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.
2777 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2778 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2779 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPatchCall<'a, C>
2780 where
2781 T: AsRef<str>,
2782 {
2783 self._additional_params
2784 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2785 self
2786 }
2787
2788 /// Identifies the authorization scope for the method you are building.
2789 ///
2790 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2791 /// [`Scope::CloudPlatform`].
2792 ///
2793 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2794 /// tokens for more than one scope.
2795 ///
2796 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2797 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2798 /// sufficient, a read-write scope will do as well.
2799 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPatchCall<'a, C>
2800 where
2801 St: AsRef<str>,
2802 {
2803 self._scopes.insert(String::from(scope.as_ref()));
2804 self
2805 }
2806 /// Identifies the authorization scope(s) for the method you are building.
2807 ///
2808 /// See [`Self::add_scope()`] for details.
2809 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPatchCall<'a, C>
2810 where
2811 I: IntoIterator<Item = St>,
2812 St: AsRef<str>,
2813 {
2814 self._scopes
2815 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2816 self
2817 }
2818
2819 /// Removes all scopes, and no default scope will be used either.
2820 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2821 /// for details).
2822 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPatchCall<'a, C> {
2823 self._scopes.clear();
2824 self
2825 }
2826}
2827
2828/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2829///
2830/// A builder for the *locations.endpoints.setIamPolicy* method supported by a *project* resource.
2831/// It is not used directly, but through a [`ProjectMethods`] instance.
2832///
2833/// # Example
2834///
2835/// Instantiate a resource method builder
2836///
2837/// ```test_harness,no_run
2838/// # extern crate hyper;
2839/// # extern crate hyper_rustls;
2840/// # extern crate google_ids1 as ids1;
2841/// use ids1::api::SetIamPolicyRequest;
2842/// # async fn dox() {
2843/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2844///
2845/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2846/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2847/// # secret,
2848/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2849/// # ).build().await.unwrap();
2850///
2851/// # let client = hyper_util::client::legacy::Client::builder(
2852/// # hyper_util::rt::TokioExecutor::new()
2853/// # )
2854/// # .build(
2855/// # hyper_rustls::HttpsConnectorBuilder::new()
2856/// # .with_native_roots()
2857/// # .unwrap()
2858/// # .https_or_http()
2859/// # .enable_http1()
2860/// # .build()
2861/// # );
2862/// # let mut hub = IDS::new(client, auth);
2863/// // As the method needs a request, you would usually fill it with the desired information
2864/// // into the respective structure. Some of the parts shown here might not be applicable !
2865/// // Values shown here are possibly random and not representative !
2866/// let mut req = SetIamPolicyRequest::default();
2867///
2868/// // You can configure optional parameters by calling the respective setters at will, and
2869/// // execute the final call using `doit()`.
2870/// // Values shown here are possibly random and not representative !
2871/// let result = hub.projects().locations_endpoints_set_iam_policy(req, "resource")
2872/// .doit().await;
2873/// # }
2874/// ```
2875pub struct ProjectLocationEndpointSetIamPolicyCall<'a, C>
2876where
2877 C: 'a,
2878{
2879 hub: &'a IDS<C>,
2880 _request: SetIamPolicyRequest,
2881 _resource: String,
2882 _delegate: Option<&'a mut dyn common::Delegate>,
2883 _additional_params: HashMap<String, String>,
2884 _scopes: BTreeSet<String>,
2885}
2886
2887impl<'a, C> common::CallBuilder for ProjectLocationEndpointSetIamPolicyCall<'a, C> {}
2888
2889impl<'a, C> ProjectLocationEndpointSetIamPolicyCall<'a, C>
2890where
2891 C: common::Connector,
2892{
2893 /// Perform the operation you have build so far.
2894 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
2895 use std::borrow::Cow;
2896 use std::io::{Read, Seek};
2897
2898 use common::{url::Params, ToParts};
2899 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2900
2901 let mut dd = common::DefaultDelegate;
2902 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2903 dlg.begin(common::MethodInfo {
2904 id: "ids.projects.locations.endpoints.setIamPolicy",
2905 http_method: hyper::Method::POST,
2906 });
2907
2908 for &field in ["alt", "resource"].iter() {
2909 if self._additional_params.contains_key(field) {
2910 dlg.finished(false);
2911 return Err(common::Error::FieldClash(field));
2912 }
2913 }
2914
2915 let mut params = Params::with_capacity(4 + self._additional_params.len());
2916 params.push("resource", self._resource);
2917
2918 params.extend(self._additional_params.iter());
2919
2920 params.push("alt", "json");
2921 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
2922 if self._scopes.is_empty() {
2923 self._scopes
2924 .insert(Scope::CloudPlatform.as_ref().to_string());
2925 }
2926
2927 #[allow(clippy::single_element_loop)]
2928 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2929 url = params.uri_replacement(url, param_name, find_this, true);
2930 }
2931 {
2932 let to_remove = ["resource"];
2933 params.remove_params(&to_remove);
2934 }
2935
2936 let url = params.parse_with_url(&url);
2937
2938 let mut json_mime_type = mime::APPLICATION_JSON;
2939 let mut request_value_reader = {
2940 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2941 common::remove_json_null_values(&mut value);
2942 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2943 serde_json::to_writer(&mut dst, &value).unwrap();
2944 dst
2945 };
2946 let request_size = request_value_reader
2947 .seek(std::io::SeekFrom::End(0))
2948 .unwrap();
2949 request_value_reader
2950 .seek(std::io::SeekFrom::Start(0))
2951 .unwrap();
2952
2953 loop {
2954 let token = match self
2955 .hub
2956 .auth
2957 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2958 .await
2959 {
2960 Ok(token) => token,
2961 Err(e) => match dlg.token(e) {
2962 Ok(token) => token,
2963 Err(e) => {
2964 dlg.finished(false);
2965 return Err(common::Error::MissingToken(e));
2966 }
2967 },
2968 };
2969 request_value_reader
2970 .seek(std::io::SeekFrom::Start(0))
2971 .unwrap();
2972 let mut req_result = {
2973 let client = &self.hub.client;
2974 dlg.pre_request();
2975 let mut req_builder = hyper::Request::builder()
2976 .method(hyper::Method::POST)
2977 .uri(url.as_str())
2978 .header(USER_AGENT, self.hub._user_agent.clone());
2979
2980 if let Some(token) = token.as_ref() {
2981 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2982 }
2983
2984 let request = req_builder
2985 .header(CONTENT_TYPE, json_mime_type.to_string())
2986 .header(CONTENT_LENGTH, request_size as u64)
2987 .body(common::to_body(
2988 request_value_reader.get_ref().clone().into(),
2989 ));
2990
2991 client.request(request.unwrap()).await
2992 };
2993
2994 match req_result {
2995 Err(err) => {
2996 if let common::Retry::After(d) = dlg.http_error(&err) {
2997 sleep(d).await;
2998 continue;
2999 }
3000 dlg.finished(false);
3001 return Err(common::Error::HttpError(err));
3002 }
3003 Ok(res) => {
3004 let (mut parts, body) = res.into_parts();
3005 let mut body = common::Body::new(body);
3006 if !parts.status.is_success() {
3007 let bytes = common::to_bytes(body).await.unwrap_or_default();
3008 let error = serde_json::from_str(&common::to_string(&bytes));
3009 let response = common::to_response(parts, bytes.into());
3010
3011 if let common::Retry::After(d) =
3012 dlg.http_failure(&response, error.as_ref().ok())
3013 {
3014 sleep(d).await;
3015 continue;
3016 }
3017
3018 dlg.finished(false);
3019
3020 return Err(match error {
3021 Ok(value) => common::Error::BadRequest(value),
3022 _ => common::Error::Failure(response),
3023 });
3024 }
3025 let response = {
3026 let bytes = common::to_bytes(body).await.unwrap_or_default();
3027 let encoded = common::to_string(&bytes);
3028 match serde_json::from_str(&encoded) {
3029 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3030 Err(error) => {
3031 dlg.response_json_decode_error(&encoded, &error);
3032 return Err(common::Error::JsonDecodeError(
3033 encoded.to_string(),
3034 error,
3035 ));
3036 }
3037 }
3038 };
3039
3040 dlg.finished(true);
3041 return Ok(response);
3042 }
3043 }
3044 }
3045 }
3046
3047 ///
3048 /// Sets the *request* property to the given value.
3049 ///
3050 /// Even though the property as already been set when instantiating this call,
3051 /// we provide this method for API completeness.
3052 pub fn request(
3053 mut self,
3054 new_value: SetIamPolicyRequest,
3055 ) -> ProjectLocationEndpointSetIamPolicyCall<'a, C> {
3056 self._request = new_value;
3057 self
3058 }
3059 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3060 ///
3061 /// Sets the *resource* path property to the given value.
3062 ///
3063 /// Even though the property as already been set when instantiating this call,
3064 /// we provide this method for API completeness.
3065 pub fn resource(mut self, new_value: &str) -> ProjectLocationEndpointSetIamPolicyCall<'a, C> {
3066 self._resource = new_value.to_string();
3067 self
3068 }
3069 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3070 /// while executing the actual API request.
3071 ///
3072 /// ````text
3073 /// It should be used to handle progress information, and to implement a certain level of resilience.
3074 /// ````
3075 ///
3076 /// Sets the *delegate* property to the given value.
3077 pub fn delegate(
3078 mut self,
3079 new_value: &'a mut dyn common::Delegate,
3080 ) -> ProjectLocationEndpointSetIamPolicyCall<'a, C> {
3081 self._delegate = Some(new_value);
3082 self
3083 }
3084
3085 /// Set any additional parameter of the query string used in the request.
3086 /// It should be used to set parameters which are not yet available through their own
3087 /// setters.
3088 ///
3089 /// Please note that this method must not be used to set any of the known parameters
3090 /// which have their own setter method. If done anyway, the request will fail.
3091 ///
3092 /// # Additional Parameters
3093 ///
3094 /// * *$.xgafv* (query-string) - V1 error format.
3095 /// * *access_token* (query-string) - OAuth access token.
3096 /// * *alt* (query-string) - Data format for response.
3097 /// * *callback* (query-string) - JSONP
3098 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3099 /// * *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.
3100 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3101 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3102 /// * *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.
3103 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3104 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3105 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointSetIamPolicyCall<'a, C>
3106 where
3107 T: AsRef<str>,
3108 {
3109 self._additional_params
3110 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3111 self
3112 }
3113
3114 /// Identifies the authorization scope for the method you are building.
3115 ///
3116 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3117 /// [`Scope::CloudPlatform`].
3118 ///
3119 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3120 /// tokens for more than one scope.
3121 ///
3122 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3123 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3124 /// sufficient, a read-write scope will do as well.
3125 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointSetIamPolicyCall<'a, C>
3126 where
3127 St: AsRef<str>,
3128 {
3129 self._scopes.insert(String::from(scope.as_ref()));
3130 self
3131 }
3132 /// Identifies the authorization scope(s) for the method you are building.
3133 ///
3134 /// See [`Self::add_scope()`] for details.
3135 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointSetIamPolicyCall<'a, C>
3136 where
3137 I: IntoIterator<Item = St>,
3138 St: AsRef<str>,
3139 {
3140 self._scopes
3141 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3142 self
3143 }
3144
3145 /// Removes all scopes, and no default scope will be used either.
3146 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3147 /// for details).
3148 pub fn clear_scopes(mut self) -> ProjectLocationEndpointSetIamPolicyCall<'a, C> {
3149 self._scopes.clear();
3150 self
3151 }
3152}
3153
3154/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
3155///
3156/// A builder for the *locations.endpoints.testIamPermissions* method supported by a *project* resource.
3157/// It is not used directly, but through a [`ProjectMethods`] instance.
3158///
3159/// # Example
3160///
3161/// Instantiate a resource method builder
3162///
3163/// ```test_harness,no_run
3164/// # extern crate hyper;
3165/// # extern crate hyper_rustls;
3166/// # extern crate google_ids1 as ids1;
3167/// use ids1::api::TestIamPermissionsRequest;
3168/// # async fn dox() {
3169/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3170///
3171/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3172/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3173/// # secret,
3174/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3175/// # ).build().await.unwrap();
3176///
3177/// # let client = hyper_util::client::legacy::Client::builder(
3178/// # hyper_util::rt::TokioExecutor::new()
3179/// # )
3180/// # .build(
3181/// # hyper_rustls::HttpsConnectorBuilder::new()
3182/// # .with_native_roots()
3183/// # .unwrap()
3184/// # .https_or_http()
3185/// # .enable_http1()
3186/// # .build()
3187/// # );
3188/// # let mut hub = IDS::new(client, auth);
3189/// // As the method needs a request, you would usually fill it with the desired information
3190/// // into the respective structure. Some of the parts shown here might not be applicable !
3191/// // Values shown here are possibly random and not representative !
3192/// let mut req = TestIamPermissionsRequest::default();
3193///
3194/// // You can configure optional parameters by calling the respective setters at will, and
3195/// // execute the final call using `doit()`.
3196/// // Values shown here are possibly random and not representative !
3197/// let result = hub.projects().locations_endpoints_test_iam_permissions(req, "resource")
3198/// .doit().await;
3199/// # }
3200/// ```
3201pub struct ProjectLocationEndpointTestIamPermissionCall<'a, C>
3202where
3203 C: 'a,
3204{
3205 hub: &'a IDS<C>,
3206 _request: TestIamPermissionsRequest,
3207 _resource: String,
3208 _delegate: Option<&'a mut dyn common::Delegate>,
3209 _additional_params: HashMap<String, String>,
3210 _scopes: BTreeSet<String>,
3211}
3212
3213impl<'a, C> common::CallBuilder for ProjectLocationEndpointTestIamPermissionCall<'a, C> {}
3214
3215impl<'a, C> ProjectLocationEndpointTestIamPermissionCall<'a, C>
3216where
3217 C: common::Connector,
3218{
3219 /// Perform the operation you have build so far.
3220 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
3221 use std::borrow::Cow;
3222 use std::io::{Read, Seek};
3223
3224 use common::{url::Params, ToParts};
3225 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3226
3227 let mut dd = common::DefaultDelegate;
3228 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3229 dlg.begin(common::MethodInfo {
3230 id: "ids.projects.locations.endpoints.testIamPermissions",
3231 http_method: hyper::Method::POST,
3232 });
3233
3234 for &field in ["alt", "resource"].iter() {
3235 if self._additional_params.contains_key(field) {
3236 dlg.finished(false);
3237 return Err(common::Error::FieldClash(field));
3238 }
3239 }
3240
3241 let mut params = Params::with_capacity(4 + self._additional_params.len());
3242 params.push("resource", self._resource);
3243
3244 params.extend(self._additional_params.iter());
3245
3246 params.push("alt", "json");
3247 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
3248 if self._scopes.is_empty() {
3249 self._scopes
3250 .insert(Scope::CloudPlatform.as_ref().to_string());
3251 }
3252
3253 #[allow(clippy::single_element_loop)]
3254 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3255 url = params.uri_replacement(url, param_name, find_this, true);
3256 }
3257 {
3258 let to_remove = ["resource"];
3259 params.remove_params(&to_remove);
3260 }
3261
3262 let url = params.parse_with_url(&url);
3263
3264 let mut json_mime_type = mime::APPLICATION_JSON;
3265 let mut request_value_reader = {
3266 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3267 common::remove_json_null_values(&mut value);
3268 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3269 serde_json::to_writer(&mut dst, &value).unwrap();
3270 dst
3271 };
3272 let request_size = request_value_reader
3273 .seek(std::io::SeekFrom::End(0))
3274 .unwrap();
3275 request_value_reader
3276 .seek(std::io::SeekFrom::Start(0))
3277 .unwrap();
3278
3279 loop {
3280 let token = match self
3281 .hub
3282 .auth
3283 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3284 .await
3285 {
3286 Ok(token) => token,
3287 Err(e) => match dlg.token(e) {
3288 Ok(token) => token,
3289 Err(e) => {
3290 dlg.finished(false);
3291 return Err(common::Error::MissingToken(e));
3292 }
3293 },
3294 };
3295 request_value_reader
3296 .seek(std::io::SeekFrom::Start(0))
3297 .unwrap();
3298 let mut req_result = {
3299 let client = &self.hub.client;
3300 dlg.pre_request();
3301 let mut req_builder = hyper::Request::builder()
3302 .method(hyper::Method::POST)
3303 .uri(url.as_str())
3304 .header(USER_AGENT, self.hub._user_agent.clone());
3305
3306 if let Some(token) = token.as_ref() {
3307 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3308 }
3309
3310 let request = req_builder
3311 .header(CONTENT_TYPE, json_mime_type.to_string())
3312 .header(CONTENT_LENGTH, request_size as u64)
3313 .body(common::to_body(
3314 request_value_reader.get_ref().clone().into(),
3315 ));
3316
3317 client.request(request.unwrap()).await
3318 };
3319
3320 match req_result {
3321 Err(err) => {
3322 if let common::Retry::After(d) = dlg.http_error(&err) {
3323 sleep(d).await;
3324 continue;
3325 }
3326 dlg.finished(false);
3327 return Err(common::Error::HttpError(err));
3328 }
3329 Ok(res) => {
3330 let (mut parts, body) = res.into_parts();
3331 let mut body = common::Body::new(body);
3332 if !parts.status.is_success() {
3333 let bytes = common::to_bytes(body).await.unwrap_or_default();
3334 let error = serde_json::from_str(&common::to_string(&bytes));
3335 let response = common::to_response(parts, bytes.into());
3336
3337 if let common::Retry::After(d) =
3338 dlg.http_failure(&response, error.as_ref().ok())
3339 {
3340 sleep(d).await;
3341 continue;
3342 }
3343
3344 dlg.finished(false);
3345
3346 return Err(match error {
3347 Ok(value) => common::Error::BadRequest(value),
3348 _ => common::Error::Failure(response),
3349 });
3350 }
3351 let response = {
3352 let bytes = common::to_bytes(body).await.unwrap_or_default();
3353 let encoded = common::to_string(&bytes);
3354 match serde_json::from_str(&encoded) {
3355 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3356 Err(error) => {
3357 dlg.response_json_decode_error(&encoded, &error);
3358 return Err(common::Error::JsonDecodeError(
3359 encoded.to_string(),
3360 error,
3361 ));
3362 }
3363 }
3364 };
3365
3366 dlg.finished(true);
3367 return Ok(response);
3368 }
3369 }
3370 }
3371 }
3372
3373 ///
3374 /// Sets the *request* property to the given value.
3375 ///
3376 /// Even though the property as already been set when instantiating this call,
3377 /// we provide this method for API completeness.
3378 pub fn request(
3379 mut self,
3380 new_value: TestIamPermissionsRequest,
3381 ) -> ProjectLocationEndpointTestIamPermissionCall<'a, C> {
3382 self._request = new_value;
3383 self
3384 }
3385 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3386 ///
3387 /// Sets the *resource* path property to the given value.
3388 ///
3389 /// Even though the property as already been set when instantiating this call,
3390 /// we provide this method for API completeness.
3391 pub fn resource(
3392 mut self,
3393 new_value: &str,
3394 ) -> ProjectLocationEndpointTestIamPermissionCall<'a, C> {
3395 self._resource = new_value.to_string();
3396 self
3397 }
3398 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3399 /// while executing the actual API request.
3400 ///
3401 /// ````text
3402 /// It should be used to handle progress information, and to implement a certain level of resilience.
3403 /// ````
3404 ///
3405 /// Sets the *delegate* property to the given value.
3406 pub fn delegate(
3407 mut self,
3408 new_value: &'a mut dyn common::Delegate,
3409 ) -> ProjectLocationEndpointTestIamPermissionCall<'a, C> {
3410 self._delegate = Some(new_value);
3411 self
3412 }
3413
3414 /// Set any additional parameter of the query string used in the request.
3415 /// It should be used to set parameters which are not yet available through their own
3416 /// setters.
3417 ///
3418 /// Please note that this method must not be used to set any of the known parameters
3419 /// which have their own setter method. If done anyway, the request will fail.
3420 ///
3421 /// # Additional Parameters
3422 ///
3423 /// * *$.xgafv* (query-string) - V1 error format.
3424 /// * *access_token* (query-string) - OAuth access token.
3425 /// * *alt* (query-string) - Data format for response.
3426 /// * *callback* (query-string) - JSONP
3427 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3428 /// * *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.
3429 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3430 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3431 /// * *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.
3432 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3433 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3434 pub fn param<T>(
3435 mut self,
3436 name: T,
3437 value: T,
3438 ) -> ProjectLocationEndpointTestIamPermissionCall<'a, C>
3439 where
3440 T: AsRef<str>,
3441 {
3442 self._additional_params
3443 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3444 self
3445 }
3446
3447 /// Identifies the authorization scope for the method you are building.
3448 ///
3449 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3450 /// [`Scope::CloudPlatform`].
3451 ///
3452 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3453 /// tokens for more than one scope.
3454 ///
3455 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3456 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3457 /// sufficient, a read-write scope will do as well.
3458 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointTestIamPermissionCall<'a, C>
3459 where
3460 St: AsRef<str>,
3461 {
3462 self._scopes.insert(String::from(scope.as_ref()));
3463 self
3464 }
3465 /// Identifies the authorization scope(s) for the method you are building.
3466 ///
3467 /// See [`Self::add_scope()`] for details.
3468 pub fn add_scopes<I, St>(
3469 mut self,
3470 scopes: I,
3471 ) -> ProjectLocationEndpointTestIamPermissionCall<'a, C>
3472 where
3473 I: IntoIterator<Item = St>,
3474 St: AsRef<str>,
3475 {
3476 self._scopes
3477 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3478 self
3479 }
3480
3481 /// Removes all scopes, and no default scope will be used either.
3482 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3483 /// for details).
3484 pub fn clear_scopes(mut self) -> ProjectLocationEndpointTestIamPermissionCall<'a, C> {
3485 self._scopes.clear();
3486 self
3487 }
3488}
3489
3490/// 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`.
3491///
3492/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
3493/// It is not used directly, but through a [`ProjectMethods`] instance.
3494///
3495/// # Example
3496///
3497/// Instantiate a resource method builder
3498///
3499/// ```test_harness,no_run
3500/// # extern crate hyper;
3501/// # extern crate hyper_rustls;
3502/// # extern crate google_ids1 as ids1;
3503/// use ids1::api::CancelOperationRequest;
3504/// # async fn dox() {
3505/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3506///
3507/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3508/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3509/// # secret,
3510/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3511/// # ).build().await.unwrap();
3512///
3513/// # let client = hyper_util::client::legacy::Client::builder(
3514/// # hyper_util::rt::TokioExecutor::new()
3515/// # )
3516/// # .build(
3517/// # hyper_rustls::HttpsConnectorBuilder::new()
3518/// # .with_native_roots()
3519/// # .unwrap()
3520/// # .https_or_http()
3521/// # .enable_http1()
3522/// # .build()
3523/// # );
3524/// # let mut hub = IDS::new(client, auth);
3525/// // As the method needs a request, you would usually fill it with the desired information
3526/// // into the respective structure. Some of the parts shown here might not be applicable !
3527/// // Values shown here are possibly random and not representative !
3528/// let mut req = CancelOperationRequest::default();
3529///
3530/// // You can configure optional parameters by calling the respective setters at will, and
3531/// // execute the final call using `doit()`.
3532/// // Values shown here are possibly random and not representative !
3533/// let result = hub.projects().locations_operations_cancel(req, "name")
3534/// .doit().await;
3535/// # }
3536/// ```
3537pub struct ProjectLocationOperationCancelCall<'a, C>
3538where
3539 C: 'a,
3540{
3541 hub: &'a IDS<C>,
3542 _request: CancelOperationRequest,
3543 _name: String,
3544 _delegate: Option<&'a mut dyn common::Delegate>,
3545 _additional_params: HashMap<String, String>,
3546 _scopes: BTreeSet<String>,
3547}
3548
3549impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
3550
3551impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
3552where
3553 C: common::Connector,
3554{
3555 /// Perform the operation you have build so far.
3556 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3557 use std::borrow::Cow;
3558 use std::io::{Read, Seek};
3559
3560 use common::{url::Params, ToParts};
3561 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3562
3563 let mut dd = common::DefaultDelegate;
3564 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3565 dlg.begin(common::MethodInfo {
3566 id: "ids.projects.locations.operations.cancel",
3567 http_method: hyper::Method::POST,
3568 });
3569
3570 for &field in ["alt", "name"].iter() {
3571 if self._additional_params.contains_key(field) {
3572 dlg.finished(false);
3573 return Err(common::Error::FieldClash(field));
3574 }
3575 }
3576
3577 let mut params = Params::with_capacity(4 + self._additional_params.len());
3578 params.push("name", self._name);
3579
3580 params.extend(self._additional_params.iter());
3581
3582 params.push("alt", "json");
3583 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
3584 if self._scopes.is_empty() {
3585 self._scopes
3586 .insert(Scope::CloudPlatform.as_ref().to_string());
3587 }
3588
3589 #[allow(clippy::single_element_loop)]
3590 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3591 url = params.uri_replacement(url, param_name, find_this, true);
3592 }
3593 {
3594 let to_remove = ["name"];
3595 params.remove_params(&to_remove);
3596 }
3597
3598 let url = params.parse_with_url(&url);
3599
3600 let mut json_mime_type = mime::APPLICATION_JSON;
3601 let mut request_value_reader = {
3602 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3603 common::remove_json_null_values(&mut value);
3604 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3605 serde_json::to_writer(&mut dst, &value).unwrap();
3606 dst
3607 };
3608 let request_size = request_value_reader
3609 .seek(std::io::SeekFrom::End(0))
3610 .unwrap();
3611 request_value_reader
3612 .seek(std::io::SeekFrom::Start(0))
3613 .unwrap();
3614
3615 loop {
3616 let token = match self
3617 .hub
3618 .auth
3619 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3620 .await
3621 {
3622 Ok(token) => token,
3623 Err(e) => match dlg.token(e) {
3624 Ok(token) => token,
3625 Err(e) => {
3626 dlg.finished(false);
3627 return Err(common::Error::MissingToken(e));
3628 }
3629 },
3630 };
3631 request_value_reader
3632 .seek(std::io::SeekFrom::Start(0))
3633 .unwrap();
3634 let mut req_result = {
3635 let client = &self.hub.client;
3636 dlg.pre_request();
3637 let mut req_builder = hyper::Request::builder()
3638 .method(hyper::Method::POST)
3639 .uri(url.as_str())
3640 .header(USER_AGENT, self.hub._user_agent.clone());
3641
3642 if let Some(token) = token.as_ref() {
3643 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3644 }
3645
3646 let request = req_builder
3647 .header(CONTENT_TYPE, json_mime_type.to_string())
3648 .header(CONTENT_LENGTH, request_size as u64)
3649 .body(common::to_body(
3650 request_value_reader.get_ref().clone().into(),
3651 ));
3652
3653 client.request(request.unwrap()).await
3654 };
3655
3656 match req_result {
3657 Err(err) => {
3658 if let common::Retry::After(d) = dlg.http_error(&err) {
3659 sleep(d).await;
3660 continue;
3661 }
3662 dlg.finished(false);
3663 return Err(common::Error::HttpError(err));
3664 }
3665 Ok(res) => {
3666 let (mut parts, body) = res.into_parts();
3667 let mut body = common::Body::new(body);
3668 if !parts.status.is_success() {
3669 let bytes = common::to_bytes(body).await.unwrap_or_default();
3670 let error = serde_json::from_str(&common::to_string(&bytes));
3671 let response = common::to_response(parts, bytes.into());
3672
3673 if let common::Retry::After(d) =
3674 dlg.http_failure(&response, error.as_ref().ok())
3675 {
3676 sleep(d).await;
3677 continue;
3678 }
3679
3680 dlg.finished(false);
3681
3682 return Err(match error {
3683 Ok(value) => common::Error::BadRequest(value),
3684 _ => common::Error::Failure(response),
3685 });
3686 }
3687 let response = {
3688 let bytes = common::to_bytes(body).await.unwrap_or_default();
3689 let encoded = common::to_string(&bytes);
3690 match serde_json::from_str(&encoded) {
3691 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3692 Err(error) => {
3693 dlg.response_json_decode_error(&encoded, &error);
3694 return Err(common::Error::JsonDecodeError(
3695 encoded.to_string(),
3696 error,
3697 ));
3698 }
3699 }
3700 };
3701
3702 dlg.finished(true);
3703 return Ok(response);
3704 }
3705 }
3706 }
3707 }
3708
3709 ///
3710 /// Sets the *request* property to the given value.
3711 ///
3712 /// Even though the property as already been set when instantiating this call,
3713 /// we provide this method for API completeness.
3714 pub fn request(
3715 mut self,
3716 new_value: CancelOperationRequest,
3717 ) -> ProjectLocationOperationCancelCall<'a, C> {
3718 self._request = new_value;
3719 self
3720 }
3721 /// The name of the operation resource to be cancelled.
3722 ///
3723 /// Sets the *name* path property to the given value.
3724 ///
3725 /// Even though the property as already been set when instantiating this call,
3726 /// we provide this method for API completeness.
3727 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
3728 self._name = new_value.to_string();
3729 self
3730 }
3731 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3732 /// while executing the actual API request.
3733 ///
3734 /// ````text
3735 /// It should be used to handle progress information, and to implement a certain level of resilience.
3736 /// ````
3737 ///
3738 /// Sets the *delegate* property to the given value.
3739 pub fn delegate(
3740 mut self,
3741 new_value: &'a mut dyn common::Delegate,
3742 ) -> ProjectLocationOperationCancelCall<'a, C> {
3743 self._delegate = Some(new_value);
3744 self
3745 }
3746
3747 /// Set any additional parameter of the query string used in the request.
3748 /// It should be used to set parameters which are not yet available through their own
3749 /// setters.
3750 ///
3751 /// Please note that this method must not be used to set any of the known parameters
3752 /// which have their own setter method. If done anyway, the request will fail.
3753 ///
3754 /// # Additional Parameters
3755 ///
3756 /// * *$.xgafv* (query-string) - V1 error format.
3757 /// * *access_token* (query-string) - OAuth access token.
3758 /// * *alt* (query-string) - Data format for response.
3759 /// * *callback* (query-string) - JSONP
3760 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3761 /// * *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.
3762 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3763 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3764 /// * *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.
3765 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3766 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3767 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
3768 where
3769 T: AsRef<str>,
3770 {
3771 self._additional_params
3772 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3773 self
3774 }
3775
3776 /// Identifies the authorization scope for the method you are building.
3777 ///
3778 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3779 /// [`Scope::CloudPlatform`].
3780 ///
3781 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3782 /// tokens for more than one scope.
3783 ///
3784 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3785 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3786 /// sufficient, a read-write scope will do as well.
3787 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
3788 where
3789 St: AsRef<str>,
3790 {
3791 self._scopes.insert(String::from(scope.as_ref()));
3792 self
3793 }
3794 /// Identifies the authorization scope(s) for the method you are building.
3795 ///
3796 /// See [`Self::add_scope()`] for details.
3797 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
3798 where
3799 I: IntoIterator<Item = St>,
3800 St: AsRef<str>,
3801 {
3802 self._scopes
3803 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3804 self
3805 }
3806
3807 /// Removes all scopes, and no default scope will be used either.
3808 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3809 /// for details).
3810 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
3811 self._scopes.clear();
3812 self
3813 }
3814}
3815
3816/// 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`.
3817///
3818/// A builder for the *locations.operations.delete* method supported by a *project* resource.
3819/// It is not used directly, but through a [`ProjectMethods`] instance.
3820///
3821/// # Example
3822///
3823/// Instantiate a resource method builder
3824///
3825/// ```test_harness,no_run
3826/// # extern crate hyper;
3827/// # extern crate hyper_rustls;
3828/// # extern crate google_ids1 as ids1;
3829/// # async fn dox() {
3830/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3831///
3832/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3833/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3834/// # secret,
3835/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3836/// # ).build().await.unwrap();
3837///
3838/// # let client = hyper_util::client::legacy::Client::builder(
3839/// # hyper_util::rt::TokioExecutor::new()
3840/// # )
3841/// # .build(
3842/// # hyper_rustls::HttpsConnectorBuilder::new()
3843/// # .with_native_roots()
3844/// # .unwrap()
3845/// # .https_or_http()
3846/// # .enable_http1()
3847/// # .build()
3848/// # );
3849/// # let mut hub = IDS::new(client, auth);
3850/// // You can configure optional parameters by calling the respective setters at will, and
3851/// // execute the final call using `doit()`.
3852/// // Values shown here are possibly random and not representative !
3853/// let result = hub.projects().locations_operations_delete("name")
3854/// .doit().await;
3855/// # }
3856/// ```
3857pub struct ProjectLocationOperationDeleteCall<'a, C>
3858where
3859 C: 'a,
3860{
3861 hub: &'a IDS<C>,
3862 _name: String,
3863 _delegate: Option<&'a mut dyn common::Delegate>,
3864 _additional_params: HashMap<String, String>,
3865 _scopes: BTreeSet<String>,
3866}
3867
3868impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
3869
3870impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
3871where
3872 C: common::Connector,
3873{
3874 /// Perform the operation you have build so far.
3875 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3876 use std::borrow::Cow;
3877 use std::io::{Read, Seek};
3878
3879 use common::{url::Params, ToParts};
3880 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3881
3882 let mut dd = common::DefaultDelegate;
3883 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3884 dlg.begin(common::MethodInfo {
3885 id: "ids.projects.locations.operations.delete",
3886 http_method: hyper::Method::DELETE,
3887 });
3888
3889 for &field in ["alt", "name"].iter() {
3890 if self._additional_params.contains_key(field) {
3891 dlg.finished(false);
3892 return Err(common::Error::FieldClash(field));
3893 }
3894 }
3895
3896 let mut params = Params::with_capacity(3 + self._additional_params.len());
3897 params.push("name", self._name);
3898
3899 params.extend(self._additional_params.iter());
3900
3901 params.push("alt", "json");
3902 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3903 if self._scopes.is_empty() {
3904 self._scopes
3905 .insert(Scope::CloudPlatform.as_ref().to_string());
3906 }
3907
3908 #[allow(clippy::single_element_loop)]
3909 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3910 url = params.uri_replacement(url, param_name, find_this, true);
3911 }
3912 {
3913 let to_remove = ["name"];
3914 params.remove_params(&to_remove);
3915 }
3916
3917 let url = params.parse_with_url(&url);
3918
3919 loop {
3920 let token = match self
3921 .hub
3922 .auth
3923 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3924 .await
3925 {
3926 Ok(token) => token,
3927 Err(e) => match dlg.token(e) {
3928 Ok(token) => token,
3929 Err(e) => {
3930 dlg.finished(false);
3931 return Err(common::Error::MissingToken(e));
3932 }
3933 },
3934 };
3935 let mut req_result = {
3936 let client = &self.hub.client;
3937 dlg.pre_request();
3938 let mut req_builder = hyper::Request::builder()
3939 .method(hyper::Method::DELETE)
3940 .uri(url.as_str())
3941 .header(USER_AGENT, self.hub._user_agent.clone());
3942
3943 if let Some(token) = token.as_ref() {
3944 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3945 }
3946
3947 let request = req_builder
3948 .header(CONTENT_LENGTH, 0_u64)
3949 .body(common::to_body::<String>(None));
3950
3951 client.request(request.unwrap()).await
3952 };
3953
3954 match req_result {
3955 Err(err) => {
3956 if let common::Retry::After(d) = dlg.http_error(&err) {
3957 sleep(d).await;
3958 continue;
3959 }
3960 dlg.finished(false);
3961 return Err(common::Error::HttpError(err));
3962 }
3963 Ok(res) => {
3964 let (mut parts, body) = res.into_parts();
3965 let mut body = common::Body::new(body);
3966 if !parts.status.is_success() {
3967 let bytes = common::to_bytes(body).await.unwrap_or_default();
3968 let error = serde_json::from_str(&common::to_string(&bytes));
3969 let response = common::to_response(parts, bytes.into());
3970
3971 if let common::Retry::After(d) =
3972 dlg.http_failure(&response, error.as_ref().ok())
3973 {
3974 sleep(d).await;
3975 continue;
3976 }
3977
3978 dlg.finished(false);
3979
3980 return Err(match error {
3981 Ok(value) => common::Error::BadRequest(value),
3982 _ => common::Error::Failure(response),
3983 });
3984 }
3985 let response = {
3986 let bytes = common::to_bytes(body).await.unwrap_or_default();
3987 let encoded = common::to_string(&bytes);
3988 match serde_json::from_str(&encoded) {
3989 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3990 Err(error) => {
3991 dlg.response_json_decode_error(&encoded, &error);
3992 return Err(common::Error::JsonDecodeError(
3993 encoded.to_string(),
3994 error,
3995 ));
3996 }
3997 }
3998 };
3999
4000 dlg.finished(true);
4001 return Ok(response);
4002 }
4003 }
4004 }
4005 }
4006
4007 /// The name of the operation resource to be deleted.
4008 ///
4009 /// Sets the *name* path property to the given value.
4010 ///
4011 /// Even though the property as already been set when instantiating this call,
4012 /// we provide this method for API completeness.
4013 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
4014 self._name = new_value.to_string();
4015 self
4016 }
4017 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4018 /// while executing the actual API request.
4019 ///
4020 /// ````text
4021 /// It should be used to handle progress information, and to implement a certain level of resilience.
4022 /// ````
4023 ///
4024 /// Sets the *delegate* property to the given value.
4025 pub fn delegate(
4026 mut self,
4027 new_value: &'a mut dyn common::Delegate,
4028 ) -> ProjectLocationOperationDeleteCall<'a, C> {
4029 self._delegate = Some(new_value);
4030 self
4031 }
4032
4033 /// Set any additional parameter of the query string used in the request.
4034 /// It should be used to set parameters which are not yet available through their own
4035 /// setters.
4036 ///
4037 /// Please note that this method must not be used to set any of the known parameters
4038 /// which have their own setter method. If done anyway, the request will fail.
4039 ///
4040 /// # Additional Parameters
4041 ///
4042 /// * *$.xgafv* (query-string) - V1 error format.
4043 /// * *access_token* (query-string) - OAuth access token.
4044 /// * *alt* (query-string) - Data format for response.
4045 /// * *callback* (query-string) - JSONP
4046 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4047 /// * *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.
4048 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4049 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4050 /// * *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.
4051 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4052 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4053 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
4054 where
4055 T: AsRef<str>,
4056 {
4057 self._additional_params
4058 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4059 self
4060 }
4061
4062 /// Identifies the authorization scope for the method you are building.
4063 ///
4064 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4065 /// [`Scope::CloudPlatform`].
4066 ///
4067 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4068 /// tokens for more than one scope.
4069 ///
4070 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4071 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4072 /// sufficient, a read-write scope will do as well.
4073 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
4074 where
4075 St: AsRef<str>,
4076 {
4077 self._scopes.insert(String::from(scope.as_ref()));
4078 self
4079 }
4080 /// Identifies the authorization scope(s) for the method you are building.
4081 ///
4082 /// See [`Self::add_scope()`] for details.
4083 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
4084 where
4085 I: IntoIterator<Item = St>,
4086 St: AsRef<str>,
4087 {
4088 self._scopes
4089 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4090 self
4091 }
4092
4093 /// Removes all scopes, and no default scope will be used either.
4094 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4095 /// for details).
4096 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
4097 self._scopes.clear();
4098 self
4099 }
4100}
4101
4102/// 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.
4103///
4104/// A builder for the *locations.operations.get* method supported by a *project* resource.
4105/// It is not used directly, but through a [`ProjectMethods`] instance.
4106///
4107/// # Example
4108///
4109/// Instantiate a resource method builder
4110///
4111/// ```test_harness,no_run
4112/// # extern crate hyper;
4113/// # extern crate hyper_rustls;
4114/// # extern crate google_ids1 as ids1;
4115/// # async fn dox() {
4116/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4117///
4118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4120/// # secret,
4121/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4122/// # ).build().await.unwrap();
4123///
4124/// # let client = hyper_util::client::legacy::Client::builder(
4125/// # hyper_util::rt::TokioExecutor::new()
4126/// # )
4127/// # .build(
4128/// # hyper_rustls::HttpsConnectorBuilder::new()
4129/// # .with_native_roots()
4130/// # .unwrap()
4131/// # .https_or_http()
4132/// # .enable_http1()
4133/// # .build()
4134/// # );
4135/// # let mut hub = IDS::new(client, auth);
4136/// // You can configure optional parameters by calling the respective setters at will, and
4137/// // execute the final call using `doit()`.
4138/// // Values shown here are possibly random and not representative !
4139/// let result = hub.projects().locations_operations_get("name")
4140/// .doit().await;
4141/// # }
4142/// ```
4143pub struct ProjectLocationOperationGetCall<'a, C>
4144where
4145 C: 'a,
4146{
4147 hub: &'a IDS<C>,
4148 _name: String,
4149 _delegate: Option<&'a mut dyn common::Delegate>,
4150 _additional_params: HashMap<String, String>,
4151 _scopes: BTreeSet<String>,
4152}
4153
4154impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
4155
4156impl<'a, C> ProjectLocationOperationGetCall<'a, C>
4157where
4158 C: common::Connector,
4159{
4160 /// Perform the operation you have build so far.
4161 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4162 use std::borrow::Cow;
4163 use std::io::{Read, Seek};
4164
4165 use common::{url::Params, ToParts};
4166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4167
4168 let mut dd = common::DefaultDelegate;
4169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4170 dlg.begin(common::MethodInfo {
4171 id: "ids.projects.locations.operations.get",
4172 http_method: hyper::Method::GET,
4173 });
4174
4175 for &field in ["alt", "name"].iter() {
4176 if self._additional_params.contains_key(field) {
4177 dlg.finished(false);
4178 return Err(common::Error::FieldClash(field));
4179 }
4180 }
4181
4182 let mut params = Params::with_capacity(3 + self._additional_params.len());
4183 params.push("name", self._name);
4184
4185 params.extend(self._additional_params.iter());
4186
4187 params.push("alt", "json");
4188 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4189 if self._scopes.is_empty() {
4190 self._scopes
4191 .insert(Scope::CloudPlatform.as_ref().to_string());
4192 }
4193
4194 #[allow(clippy::single_element_loop)]
4195 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4196 url = params.uri_replacement(url, param_name, find_this, true);
4197 }
4198 {
4199 let to_remove = ["name"];
4200 params.remove_params(&to_remove);
4201 }
4202
4203 let url = params.parse_with_url(&url);
4204
4205 loop {
4206 let token = match self
4207 .hub
4208 .auth
4209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4210 .await
4211 {
4212 Ok(token) => token,
4213 Err(e) => match dlg.token(e) {
4214 Ok(token) => token,
4215 Err(e) => {
4216 dlg.finished(false);
4217 return Err(common::Error::MissingToken(e));
4218 }
4219 },
4220 };
4221 let mut req_result = {
4222 let client = &self.hub.client;
4223 dlg.pre_request();
4224 let mut req_builder = hyper::Request::builder()
4225 .method(hyper::Method::GET)
4226 .uri(url.as_str())
4227 .header(USER_AGENT, self.hub._user_agent.clone());
4228
4229 if let Some(token) = token.as_ref() {
4230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4231 }
4232
4233 let request = req_builder
4234 .header(CONTENT_LENGTH, 0_u64)
4235 .body(common::to_body::<String>(None));
4236
4237 client.request(request.unwrap()).await
4238 };
4239
4240 match req_result {
4241 Err(err) => {
4242 if let common::Retry::After(d) = dlg.http_error(&err) {
4243 sleep(d).await;
4244 continue;
4245 }
4246 dlg.finished(false);
4247 return Err(common::Error::HttpError(err));
4248 }
4249 Ok(res) => {
4250 let (mut parts, body) = res.into_parts();
4251 let mut body = common::Body::new(body);
4252 if !parts.status.is_success() {
4253 let bytes = common::to_bytes(body).await.unwrap_or_default();
4254 let error = serde_json::from_str(&common::to_string(&bytes));
4255 let response = common::to_response(parts, bytes.into());
4256
4257 if let common::Retry::After(d) =
4258 dlg.http_failure(&response, error.as_ref().ok())
4259 {
4260 sleep(d).await;
4261 continue;
4262 }
4263
4264 dlg.finished(false);
4265
4266 return Err(match error {
4267 Ok(value) => common::Error::BadRequest(value),
4268 _ => common::Error::Failure(response),
4269 });
4270 }
4271 let response = {
4272 let bytes = common::to_bytes(body).await.unwrap_or_default();
4273 let encoded = common::to_string(&bytes);
4274 match serde_json::from_str(&encoded) {
4275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4276 Err(error) => {
4277 dlg.response_json_decode_error(&encoded, &error);
4278 return Err(common::Error::JsonDecodeError(
4279 encoded.to_string(),
4280 error,
4281 ));
4282 }
4283 }
4284 };
4285
4286 dlg.finished(true);
4287 return Ok(response);
4288 }
4289 }
4290 }
4291 }
4292
4293 /// The name of the operation resource.
4294 ///
4295 /// Sets the *name* path property to the given value.
4296 ///
4297 /// Even though the property as already been set when instantiating this call,
4298 /// we provide this method for API completeness.
4299 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
4300 self._name = new_value.to_string();
4301 self
4302 }
4303 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4304 /// while executing the actual API request.
4305 ///
4306 /// ````text
4307 /// It should be used to handle progress information, and to implement a certain level of resilience.
4308 /// ````
4309 ///
4310 /// Sets the *delegate* property to the given value.
4311 pub fn delegate(
4312 mut self,
4313 new_value: &'a mut dyn common::Delegate,
4314 ) -> ProjectLocationOperationGetCall<'a, C> {
4315 self._delegate = Some(new_value);
4316 self
4317 }
4318
4319 /// Set any additional parameter of the query string used in the request.
4320 /// It should be used to set parameters which are not yet available through their own
4321 /// setters.
4322 ///
4323 /// Please note that this method must not be used to set any of the known parameters
4324 /// which have their own setter method. If done anyway, the request will fail.
4325 ///
4326 /// # Additional Parameters
4327 ///
4328 /// * *$.xgafv* (query-string) - V1 error format.
4329 /// * *access_token* (query-string) - OAuth access token.
4330 /// * *alt* (query-string) - Data format for response.
4331 /// * *callback* (query-string) - JSONP
4332 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4333 /// * *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.
4334 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4335 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4336 /// * *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.
4337 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4338 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4339 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
4340 where
4341 T: AsRef<str>,
4342 {
4343 self._additional_params
4344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4345 self
4346 }
4347
4348 /// Identifies the authorization scope for the method you are building.
4349 ///
4350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4351 /// [`Scope::CloudPlatform`].
4352 ///
4353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4354 /// tokens for more than one scope.
4355 ///
4356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4358 /// sufficient, a read-write scope will do as well.
4359 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
4360 where
4361 St: AsRef<str>,
4362 {
4363 self._scopes.insert(String::from(scope.as_ref()));
4364 self
4365 }
4366 /// Identifies the authorization scope(s) for the method you are building.
4367 ///
4368 /// See [`Self::add_scope()`] for details.
4369 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
4370 where
4371 I: IntoIterator<Item = St>,
4372 St: AsRef<str>,
4373 {
4374 self._scopes
4375 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4376 self
4377 }
4378
4379 /// Removes all scopes, and no default scope will be used either.
4380 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4381 /// for details).
4382 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
4383 self._scopes.clear();
4384 self
4385 }
4386}
4387
4388/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4389///
4390/// A builder for the *locations.operations.list* method supported by a *project* resource.
4391/// It is not used directly, but through a [`ProjectMethods`] instance.
4392///
4393/// # Example
4394///
4395/// Instantiate a resource method builder
4396///
4397/// ```test_harness,no_run
4398/// # extern crate hyper;
4399/// # extern crate hyper_rustls;
4400/// # extern crate google_ids1 as ids1;
4401/// # async fn dox() {
4402/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4403///
4404/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4405/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4406/// # secret,
4407/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4408/// # ).build().await.unwrap();
4409///
4410/// # let client = hyper_util::client::legacy::Client::builder(
4411/// # hyper_util::rt::TokioExecutor::new()
4412/// # )
4413/// # .build(
4414/// # hyper_rustls::HttpsConnectorBuilder::new()
4415/// # .with_native_roots()
4416/// # .unwrap()
4417/// # .https_or_http()
4418/// # .enable_http1()
4419/// # .build()
4420/// # );
4421/// # let mut hub = IDS::new(client, auth);
4422/// // You can configure optional parameters by calling the respective setters at will, and
4423/// // execute the final call using `doit()`.
4424/// // Values shown here are possibly random and not representative !
4425/// let result = hub.projects().locations_operations_list("name")
4426/// .page_token("ipsum")
4427/// .page_size(-7)
4428/// .filter("gubergren")
4429/// .doit().await;
4430/// # }
4431/// ```
4432pub struct ProjectLocationOperationListCall<'a, C>
4433where
4434 C: 'a,
4435{
4436 hub: &'a IDS<C>,
4437 _name: String,
4438 _page_token: Option<String>,
4439 _page_size: Option<i32>,
4440 _filter: Option<String>,
4441 _delegate: Option<&'a mut dyn common::Delegate>,
4442 _additional_params: HashMap<String, String>,
4443 _scopes: BTreeSet<String>,
4444}
4445
4446impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
4447
4448impl<'a, C> ProjectLocationOperationListCall<'a, C>
4449where
4450 C: common::Connector,
4451{
4452 /// Perform the operation you have build so far.
4453 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
4454 use std::borrow::Cow;
4455 use std::io::{Read, Seek};
4456
4457 use common::{url::Params, ToParts};
4458 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4459
4460 let mut dd = common::DefaultDelegate;
4461 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4462 dlg.begin(common::MethodInfo {
4463 id: "ids.projects.locations.operations.list",
4464 http_method: hyper::Method::GET,
4465 });
4466
4467 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
4468 if self._additional_params.contains_key(field) {
4469 dlg.finished(false);
4470 return Err(common::Error::FieldClash(field));
4471 }
4472 }
4473
4474 let mut params = Params::with_capacity(6 + self._additional_params.len());
4475 params.push("name", self._name);
4476 if let Some(value) = self._page_token.as_ref() {
4477 params.push("pageToken", value);
4478 }
4479 if let Some(value) = self._page_size.as_ref() {
4480 params.push("pageSize", value.to_string());
4481 }
4482 if let Some(value) = self._filter.as_ref() {
4483 params.push("filter", value);
4484 }
4485
4486 params.extend(self._additional_params.iter());
4487
4488 params.push("alt", "json");
4489 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
4490 if self._scopes.is_empty() {
4491 self._scopes
4492 .insert(Scope::CloudPlatform.as_ref().to_string());
4493 }
4494
4495 #[allow(clippy::single_element_loop)]
4496 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4497 url = params.uri_replacement(url, param_name, find_this, true);
4498 }
4499 {
4500 let to_remove = ["name"];
4501 params.remove_params(&to_remove);
4502 }
4503
4504 let url = params.parse_with_url(&url);
4505
4506 loop {
4507 let token = match self
4508 .hub
4509 .auth
4510 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4511 .await
4512 {
4513 Ok(token) => token,
4514 Err(e) => match dlg.token(e) {
4515 Ok(token) => token,
4516 Err(e) => {
4517 dlg.finished(false);
4518 return Err(common::Error::MissingToken(e));
4519 }
4520 },
4521 };
4522 let mut req_result = {
4523 let client = &self.hub.client;
4524 dlg.pre_request();
4525 let mut req_builder = hyper::Request::builder()
4526 .method(hyper::Method::GET)
4527 .uri(url.as_str())
4528 .header(USER_AGENT, self.hub._user_agent.clone());
4529
4530 if let Some(token) = token.as_ref() {
4531 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4532 }
4533
4534 let request = req_builder
4535 .header(CONTENT_LENGTH, 0_u64)
4536 .body(common::to_body::<String>(None));
4537
4538 client.request(request.unwrap()).await
4539 };
4540
4541 match req_result {
4542 Err(err) => {
4543 if let common::Retry::After(d) = dlg.http_error(&err) {
4544 sleep(d).await;
4545 continue;
4546 }
4547 dlg.finished(false);
4548 return Err(common::Error::HttpError(err));
4549 }
4550 Ok(res) => {
4551 let (mut parts, body) = res.into_parts();
4552 let mut body = common::Body::new(body);
4553 if !parts.status.is_success() {
4554 let bytes = common::to_bytes(body).await.unwrap_or_default();
4555 let error = serde_json::from_str(&common::to_string(&bytes));
4556 let response = common::to_response(parts, bytes.into());
4557
4558 if let common::Retry::After(d) =
4559 dlg.http_failure(&response, error.as_ref().ok())
4560 {
4561 sleep(d).await;
4562 continue;
4563 }
4564
4565 dlg.finished(false);
4566
4567 return Err(match error {
4568 Ok(value) => common::Error::BadRequest(value),
4569 _ => common::Error::Failure(response),
4570 });
4571 }
4572 let response = {
4573 let bytes = common::to_bytes(body).await.unwrap_or_default();
4574 let encoded = common::to_string(&bytes);
4575 match serde_json::from_str(&encoded) {
4576 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4577 Err(error) => {
4578 dlg.response_json_decode_error(&encoded, &error);
4579 return Err(common::Error::JsonDecodeError(
4580 encoded.to_string(),
4581 error,
4582 ));
4583 }
4584 }
4585 };
4586
4587 dlg.finished(true);
4588 return Ok(response);
4589 }
4590 }
4591 }
4592 }
4593
4594 /// The name of the operation's parent resource.
4595 ///
4596 /// Sets the *name* path property to the given value.
4597 ///
4598 /// Even though the property as already been set when instantiating this call,
4599 /// we provide this method for API completeness.
4600 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4601 self._name = new_value.to_string();
4602 self
4603 }
4604 /// The standard list page token.
4605 ///
4606 /// Sets the *page token* query property to the given value.
4607 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4608 self._page_token = Some(new_value.to_string());
4609 self
4610 }
4611 /// The standard list page size.
4612 ///
4613 /// Sets the *page size* query property to the given value.
4614 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
4615 self._page_size = Some(new_value);
4616 self
4617 }
4618 /// The standard list filter.
4619 ///
4620 /// Sets the *filter* query property to the given value.
4621 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4622 self._filter = Some(new_value.to_string());
4623 self
4624 }
4625 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4626 /// while executing the actual API request.
4627 ///
4628 /// ````text
4629 /// It should be used to handle progress information, and to implement a certain level of resilience.
4630 /// ````
4631 ///
4632 /// Sets the *delegate* property to the given value.
4633 pub fn delegate(
4634 mut self,
4635 new_value: &'a mut dyn common::Delegate,
4636 ) -> ProjectLocationOperationListCall<'a, C> {
4637 self._delegate = Some(new_value);
4638 self
4639 }
4640
4641 /// Set any additional parameter of the query string used in the request.
4642 /// It should be used to set parameters which are not yet available through their own
4643 /// setters.
4644 ///
4645 /// Please note that this method must not be used to set any of the known parameters
4646 /// which have their own setter method. If done anyway, the request will fail.
4647 ///
4648 /// # Additional Parameters
4649 ///
4650 /// * *$.xgafv* (query-string) - V1 error format.
4651 /// * *access_token* (query-string) - OAuth access token.
4652 /// * *alt* (query-string) - Data format for response.
4653 /// * *callback* (query-string) - JSONP
4654 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4655 /// * *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.
4656 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4657 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4658 /// * *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.
4659 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4660 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4661 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
4662 where
4663 T: AsRef<str>,
4664 {
4665 self._additional_params
4666 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4667 self
4668 }
4669
4670 /// Identifies the authorization scope for the method you are building.
4671 ///
4672 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4673 /// [`Scope::CloudPlatform`].
4674 ///
4675 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4676 /// tokens for more than one scope.
4677 ///
4678 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4679 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4680 /// sufficient, a read-write scope will do as well.
4681 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
4682 where
4683 St: AsRef<str>,
4684 {
4685 self._scopes.insert(String::from(scope.as_ref()));
4686 self
4687 }
4688 /// Identifies the authorization scope(s) for the method you are building.
4689 ///
4690 /// See [`Self::add_scope()`] for details.
4691 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
4692 where
4693 I: IntoIterator<Item = St>,
4694 St: AsRef<str>,
4695 {
4696 self._scopes
4697 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4698 self
4699 }
4700
4701 /// Removes all scopes, and no default scope will be used either.
4702 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4703 /// for details).
4704 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
4705 self._scopes.clear();
4706 self
4707 }
4708}
4709
4710/// Gets information about a location.
4711///
4712/// A builder for the *locations.get* method supported by a *project* resource.
4713/// It is not used directly, but through a [`ProjectMethods`] instance.
4714///
4715/// # Example
4716///
4717/// Instantiate a resource method builder
4718///
4719/// ```test_harness,no_run
4720/// # extern crate hyper;
4721/// # extern crate hyper_rustls;
4722/// # extern crate google_ids1 as ids1;
4723/// # async fn dox() {
4724/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4725///
4726/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4727/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4728/// # secret,
4729/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4730/// # ).build().await.unwrap();
4731///
4732/// # let client = hyper_util::client::legacy::Client::builder(
4733/// # hyper_util::rt::TokioExecutor::new()
4734/// # )
4735/// # .build(
4736/// # hyper_rustls::HttpsConnectorBuilder::new()
4737/// # .with_native_roots()
4738/// # .unwrap()
4739/// # .https_or_http()
4740/// # .enable_http1()
4741/// # .build()
4742/// # );
4743/// # let mut hub = IDS::new(client, auth);
4744/// // You can configure optional parameters by calling the respective setters at will, and
4745/// // execute the final call using `doit()`.
4746/// // Values shown here are possibly random and not representative !
4747/// let result = hub.projects().locations_get("name")
4748/// .doit().await;
4749/// # }
4750/// ```
4751pub struct ProjectLocationGetCall<'a, C>
4752where
4753 C: 'a,
4754{
4755 hub: &'a IDS<C>,
4756 _name: String,
4757 _delegate: Option<&'a mut dyn common::Delegate>,
4758 _additional_params: HashMap<String, String>,
4759 _scopes: BTreeSet<String>,
4760}
4761
4762impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
4763
4764impl<'a, C> ProjectLocationGetCall<'a, C>
4765where
4766 C: common::Connector,
4767{
4768 /// Perform the operation you have build so far.
4769 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
4770 use std::borrow::Cow;
4771 use std::io::{Read, Seek};
4772
4773 use common::{url::Params, ToParts};
4774 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4775
4776 let mut dd = common::DefaultDelegate;
4777 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4778 dlg.begin(common::MethodInfo {
4779 id: "ids.projects.locations.get",
4780 http_method: hyper::Method::GET,
4781 });
4782
4783 for &field in ["alt", "name"].iter() {
4784 if self._additional_params.contains_key(field) {
4785 dlg.finished(false);
4786 return Err(common::Error::FieldClash(field));
4787 }
4788 }
4789
4790 let mut params = Params::with_capacity(3 + self._additional_params.len());
4791 params.push("name", self._name);
4792
4793 params.extend(self._additional_params.iter());
4794
4795 params.push("alt", "json");
4796 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4797 if self._scopes.is_empty() {
4798 self._scopes
4799 .insert(Scope::CloudPlatform.as_ref().to_string());
4800 }
4801
4802 #[allow(clippy::single_element_loop)]
4803 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4804 url = params.uri_replacement(url, param_name, find_this, true);
4805 }
4806 {
4807 let to_remove = ["name"];
4808 params.remove_params(&to_remove);
4809 }
4810
4811 let url = params.parse_with_url(&url);
4812
4813 loop {
4814 let token = match self
4815 .hub
4816 .auth
4817 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4818 .await
4819 {
4820 Ok(token) => token,
4821 Err(e) => match dlg.token(e) {
4822 Ok(token) => token,
4823 Err(e) => {
4824 dlg.finished(false);
4825 return Err(common::Error::MissingToken(e));
4826 }
4827 },
4828 };
4829 let mut req_result = {
4830 let client = &self.hub.client;
4831 dlg.pre_request();
4832 let mut req_builder = hyper::Request::builder()
4833 .method(hyper::Method::GET)
4834 .uri(url.as_str())
4835 .header(USER_AGENT, self.hub._user_agent.clone());
4836
4837 if let Some(token) = token.as_ref() {
4838 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4839 }
4840
4841 let request = req_builder
4842 .header(CONTENT_LENGTH, 0_u64)
4843 .body(common::to_body::<String>(None));
4844
4845 client.request(request.unwrap()).await
4846 };
4847
4848 match req_result {
4849 Err(err) => {
4850 if let common::Retry::After(d) = dlg.http_error(&err) {
4851 sleep(d).await;
4852 continue;
4853 }
4854 dlg.finished(false);
4855 return Err(common::Error::HttpError(err));
4856 }
4857 Ok(res) => {
4858 let (mut parts, body) = res.into_parts();
4859 let mut body = common::Body::new(body);
4860 if !parts.status.is_success() {
4861 let bytes = common::to_bytes(body).await.unwrap_or_default();
4862 let error = serde_json::from_str(&common::to_string(&bytes));
4863 let response = common::to_response(parts, bytes.into());
4864
4865 if let common::Retry::After(d) =
4866 dlg.http_failure(&response, error.as_ref().ok())
4867 {
4868 sleep(d).await;
4869 continue;
4870 }
4871
4872 dlg.finished(false);
4873
4874 return Err(match error {
4875 Ok(value) => common::Error::BadRequest(value),
4876 _ => common::Error::Failure(response),
4877 });
4878 }
4879 let response = {
4880 let bytes = common::to_bytes(body).await.unwrap_or_default();
4881 let encoded = common::to_string(&bytes);
4882 match serde_json::from_str(&encoded) {
4883 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4884 Err(error) => {
4885 dlg.response_json_decode_error(&encoded, &error);
4886 return Err(common::Error::JsonDecodeError(
4887 encoded.to_string(),
4888 error,
4889 ));
4890 }
4891 }
4892 };
4893
4894 dlg.finished(true);
4895 return Ok(response);
4896 }
4897 }
4898 }
4899 }
4900
4901 /// Resource name for the location.
4902 ///
4903 /// Sets the *name* path property to the given value.
4904 ///
4905 /// Even though the property as already been set when instantiating this call,
4906 /// we provide this method for API completeness.
4907 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
4908 self._name = new_value.to_string();
4909 self
4910 }
4911 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4912 /// while executing the actual API request.
4913 ///
4914 /// ````text
4915 /// It should be used to handle progress information, and to implement a certain level of resilience.
4916 /// ````
4917 ///
4918 /// Sets the *delegate* property to the given value.
4919 pub fn delegate(
4920 mut self,
4921 new_value: &'a mut dyn common::Delegate,
4922 ) -> ProjectLocationGetCall<'a, C> {
4923 self._delegate = Some(new_value);
4924 self
4925 }
4926
4927 /// Set any additional parameter of the query string used in the request.
4928 /// It should be used to set parameters which are not yet available through their own
4929 /// setters.
4930 ///
4931 /// Please note that this method must not be used to set any of the known parameters
4932 /// which have their own setter method. If done anyway, the request will fail.
4933 ///
4934 /// # Additional Parameters
4935 ///
4936 /// * *$.xgafv* (query-string) - V1 error format.
4937 /// * *access_token* (query-string) - OAuth access token.
4938 /// * *alt* (query-string) - Data format for response.
4939 /// * *callback* (query-string) - JSONP
4940 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4941 /// * *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.
4942 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4943 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4944 /// * *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.
4945 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4946 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4947 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
4948 where
4949 T: AsRef<str>,
4950 {
4951 self._additional_params
4952 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4953 self
4954 }
4955
4956 /// Identifies the authorization scope for the method you are building.
4957 ///
4958 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4959 /// [`Scope::CloudPlatform`].
4960 ///
4961 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4962 /// tokens for more than one scope.
4963 ///
4964 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4965 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4966 /// sufficient, a read-write scope will do as well.
4967 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
4968 where
4969 St: AsRef<str>,
4970 {
4971 self._scopes.insert(String::from(scope.as_ref()));
4972 self
4973 }
4974 /// Identifies the authorization scope(s) for the method you are building.
4975 ///
4976 /// See [`Self::add_scope()`] for details.
4977 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
4978 where
4979 I: IntoIterator<Item = St>,
4980 St: AsRef<str>,
4981 {
4982 self._scopes
4983 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4984 self
4985 }
4986
4987 /// Removes all scopes, and no default scope will be used either.
4988 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4989 /// for details).
4990 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
4991 self._scopes.clear();
4992 self
4993 }
4994}
4995
4996/// Lists information about the supported locations for this service.
4997///
4998/// A builder for the *locations.list* method supported by a *project* resource.
4999/// It is not used directly, but through a [`ProjectMethods`] instance.
5000///
5001/// # Example
5002///
5003/// Instantiate a resource method builder
5004///
5005/// ```test_harness,no_run
5006/// # extern crate hyper;
5007/// # extern crate hyper_rustls;
5008/// # extern crate google_ids1 as ids1;
5009/// # async fn dox() {
5010/// # use ids1::{IDS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5011///
5012/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5013/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5014/// # secret,
5015/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5016/// # ).build().await.unwrap();
5017///
5018/// # let client = hyper_util::client::legacy::Client::builder(
5019/// # hyper_util::rt::TokioExecutor::new()
5020/// # )
5021/// # .build(
5022/// # hyper_rustls::HttpsConnectorBuilder::new()
5023/// # .with_native_roots()
5024/// # .unwrap()
5025/// # .https_or_http()
5026/// # .enable_http1()
5027/// # .build()
5028/// # );
5029/// # let mut hub = IDS::new(client, auth);
5030/// // You can configure optional parameters by calling the respective setters at will, and
5031/// // execute the final call using `doit()`.
5032/// // Values shown here are possibly random and not representative !
5033/// let result = hub.projects().locations_list("name")
5034/// .page_token("Lorem")
5035/// .page_size(-25)
5036/// .filter("labore")
5037/// .doit().await;
5038/// # }
5039/// ```
5040pub struct ProjectLocationListCall<'a, C>
5041where
5042 C: 'a,
5043{
5044 hub: &'a IDS<C>,
5045 _name: String,
5046 _page_token: Option<String>,
5047 _page_size: Option<i32>,
5048 _filter: Option<String>,
5049 _delegate: Option<&'a mut dyn common::Delegate>,
5050 _additional_params: HashMap<String, String>,
5051 _scopes: BTreeSet<String>,
5052}
5053
5054impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
5055
5056impl<'a, C> ProjectLocationListCall<'a, C>
5057where
5058 C: common::Connector,
5059{
5060 /// Perform the operation you have build so far.
5061 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
5062 use std::borrow::Cow;
5063 use std::io::{Read, Seek};
5064
5065 use common::{url::Params, ToParts};
5066 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5067
5068 let mut dd = common::DefaultDelegate;
5069 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5070 dlg.begin(common::MethodInfo {
5071 id: "ids.projects.locations.list",
5072 http_method: hyper::Method::GET,
5073 });
5074
5075 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
5076 if self._additional_params.contains_key(field) {
5077 dlg.finished(false);
5078 return Err(common::Error::FieldClash(field));
5079 }
5080 }
5081
5082 let mut params = Params::with_capacity(6 + self._additional_params.len());
5083 params.push("name", self._name);
5084 if let Some(value) = self._page_token.as_ref() {
5085 params.push("pageToken", value);
5086 }
5087 if let Some(value) = self._page_size.as_ref() {
5088 params.push("pageSize", value.to_string());
5089 }
5090 if let Some(value) = self._filter.as_ref() {
5091 params.push("filter", value);
5092 }
5093
5094 params.extend(self._additional_params.iter());
5095
5096 params.push("alt", "json");
5097 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
5098 if self._scopes.is_empty() {
5099 self._scopes
5100 .insert(Scope::CloudPlatform.as_ref().to_string());
5101 }
5102
5103 #[allow(clippy::single_element_loop)]
5104 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5105 url = params.uri_replacement(url, param_name, find_this, true);
5106 }
5107 {
5108 let to_remove = ["name"];
5109 params.remove_params(&to_remove);
5110 }
5111
5112 let url = params.parse_with_url(&url);
5113
5114 loop {
5115 let token = match self
5116 .hub
5117 .auth
5118 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5119 .await
5120 {
5121 Ok(token) => token,
5122 Err(e) => match dlg.token(e) {
5123 Ok(token) => token,
5124 Err(e) => {
5125 dlg.finished(false);
5126 return Err(common::Error::MissingToken(e));
5127 }
5128 },
5129 };
5130 let mut req_result = {
5131 let client = &self.hub.client;
5132 dlg.pre_request();
5133 let mut req_builder = hyper::Request::builder()
5134 .method(hyper::Method::GET)
5135 .uri(url.as_str())
5136 .header(USER_AGENT, self.hub._user_agent.clone());
5137
5138 if let Some(token) = token.as_ref() {
5139 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5140 }
5141
5142 let request = req_builder
5143 .header(CONTENT_LENGTH, 0_u64)
5144 .body(common::to_body::<String>(None));
5145
5146 client.request(request.unwrap()).await
5147 };
5148
5149 match req_result {
5150 Err(err) => {
5151 if let common::Retry::After(d) = dlg.http_error(&err) {
5152 sleep(d).await;
5153 continue;
5154 }
5155 dlg.finished(false);
5156 return Err(common::Error::HttpError(err));
5157 }
5158 Ok(res) => {
5159 let (mut parts, body) = res.into_parts();
5160 let mut body = common::Body::new(body);
5161 if !parts.status.is_success() {
5162 let bytes = common::to_bytes(body).await.unwrap_or_default();
5163 let error = serde_json::from_str(&common::to_string(&bytes));
5164 let response = common::to_response(parts, bytes.into());
5165
5166 if let common::Retry::After(d) =
5167 dlg.http_failure(&response, error.as_ref().ok())
5168 {
5169 sleep(d).await;
5170 continue;
5171 }
5172
5173 dlg.finished(false);
5174
5175 return Err(match error {
5176 Ok(value) => common::Error::BadRequest(value),
5177 _ => common::Error::Failure(response),
5178 });
5179 }
5180 let response = {
5181 let bytes = common::to_bytes(body).await.unwrap_or_default();
5182 let encoded = common::to_string(&bytes);
5183 match serde_json::from_str(&encoded) {
5184 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5185 Err(error) => {
5186 dlg.response_json_decode_error(&encoded, &error);
5187 return Err(common::Error::JsonDecodeError(
5188 encoded.to_string(),
5189 error,
5190 ));
5191 }
5192 }
5193 };
5194
5195 dlg.finished(true);
5196 return Ok(response);
5197 }
5198 }
5199 }
5200 }
5201
5202 /// The resource that owns the locations collection, if applicable.
5203 ///
5204 /// Sets the *name* path property to the given value.
5205 ///
5206 /// Even though the property as already been set when instantiating this call,
5207 /// we provide this method for API completeness.
5208 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5209 self._name = new_value.to_string();
5210 self
5211 }
5212 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
5213 ///
5214 /// Sets the *page token* query property to the given value.
5215 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5216 self._page_token = Some(new_value.to_string());
5217 self
5218 }
5219 /// The maximum number of results to return. If not set, the service selects a default.
5220 ///
5221 /// Sets the *page size* query property to the given value.
5222 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
5223 self._page_size = Some(new_value);
5224 self
5225 }
5226 /// 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).
5227 ///
5228 /// Sets the *filter* query property to the given value.
5229 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5230 self._filter = Some(new_value.to_string());
5231 self
5232 }
5233 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5234 /// while executing the actual API request.
5235 ///
5236 /// ````text
5237 /// It should be used to handle progress information, and to implement a certain level of resilience.
5238 /// ````
5239 ///
5240 /// Sets the *delegate* property to the given value.
5241 pub fn delegate(
5242 mut self,
5243 new_value: &'a mut dyn common::Delegate,
5244 ) -> ProjectLocationListCall<'a, C> {
5245 self._delegate = Some(new_value);
5246 self
5247 }
5248
5249 /// Set any additional parameter of the query string used in the request.
5250 /// It should be used to set parameters which are not yet available through their own
5251 /// setters.
5252 ///
5253 /// Please note that this method must not be used to set any of the known parameters
5254 /// which have their own setter method. If done anyway, the request will fail.
5255 ///
5256 /// # Additional Parameters
5257 ///
5258 /// * *$.xgafv* (query-string) - V1 error format.
5259 /// * *access_token* (query-string) - OAuth access token.
5260 /// * *alt* (query-string) - Data format for response.
5261 /// * *callback* (query-string) - JSONP
5262 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5263 /// * *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.
5264 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5265 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5266 /// * *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.
5267 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5268 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5269 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
5270 where
5271 T: AsRef<str>,
5272 {
5273 self._additional_params
5274 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5275 self
5276 }
5277
5278 /// Identifies the authorization scope for the method you are building.
5279 ///
5280 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5281 /// [`Scope::CloudPlatform`].
5282 ///
5283 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5284 /// tokens for more than one scope.
5285 ///
5286 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5287 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5288 /// sufficient, a read-write scope will do as well.
5289 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
5290 where
5291 St: AsRef<str>,
5292 {
5293 self._scopes.insert(String::from(scope.as_ref()));
5294 self
5295 }
5296 /// Identifies the authorization scope(s) for the method you are building.
5297 ///
5298 /// See [`Self::add_scope()`] for details.
5299 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
5300 where
5301 I: IntoIterator<Item = St>,
5302 St: AsRef<str>,
5303 {
5304 self._scopes
5305 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5306 self
5307 }
5308
5309 /// Removes all scopes, and no default scope will be used either.
5310 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5311 /// for details).
5312 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
5313 self._scopes.clear();
5314 self
5315 }
5316}