google_networksecurity1/
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 NetworkSecurity 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_networksecurity1 as networksecurity1;
49/// use networksecurity1::api::AddressGroup;
50/// use networksecurity1::{Result, Error};
51/// # async fn dox() {
52/// use networksecurity1::{NetworkSecurity, 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 = NetworkSecurity::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 = AddressGroup::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.organizations().locations_address_groups_create(req, "parent")
88///              .request_id("sed")
89///              .address_group_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 NetworkSecurity<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 NetworkSecurity<C> {}
121
122impl<'a, C> NetworkSecurity<C> {
123    pub fn new<A: 'static + common::GetToken>(
124        client: common::Client<C>,
125        auth: A,
126    ) -> NetworkSecurity<C> {
127        NetworkSecurity {
128            client,
129            auth: Box::new(auth),
130            _user_agent: "google-api-rust-client/6.0.0".to_string(),
131            _base_url: "https://networksecurity.googleapis.com/".to_string(),
132            _root_url: "https://networksecurity.googleapis.com/".to_string(),
133        }
134    }
135
136    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
137        OrganizationMethods { hub: self }
138    }
139    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
140        ProjectMethods { hub: self }
141    }
142
143    /// Set the user-agent header field to use in all requests to the server.
144    /// It defaults to `google-api-rust-client/6.0.0`.
145    ///
146    /// Returns the previously set user-agent.
147    pub fn user_agent(&mut self, agent_name: String) -> String {
148        std::mem::replace(&mut self._user_agent, agent_name)
149    }
150
151    /// Set the base url to use in all requests to the server.
152    /// It defaults to `https://networksecurity.googleapis.com/`.
153    ///
154    /// Returns the previously set base url.
155    pub fn base_url(&mut self, new_base_url: String) -> String {
156        std::mem::replace(&mut self._base_url, new_base_url)
157    }
158
159    /// Set the root url to use in all requests to the server.
160    /// It defaults to `https://networksecurity.googleapis.com/`.
161    ///
162    /// Returns the previously set root url.
163    pub fn root_url(&mut self, new_root_url: String) -> String {
164        std::mem::replace(&mut self._root_url, new_root_url)
165    }
166}
167
168// ############
169// SCHEMAS ###
170// ##########
171/// Request used by the AddAddressGroupItems method.
172///
173/// # Activities
174///
175/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
176/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
177///
178/// * [locations address groups add items organizations](OrganizationLocationAddressGroupAddItemCall) (request)
179/// * [locations address groups add items projects](ProjectLocationAddressGroupAddItemCall) (request)
180#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
181#[serde_with::serde_as]
182#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
183pub struct AddAddressGroupItemsRequest {
184    /// Required. List of items to add.
185    pub items: Option<Vec<String>>,
186    /// Optional. 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).
187    #[serde(rename = "requestId")]
188    pub request_id: Option<String>,
189}
190
191impl common::RequestValue for AddAddressGroupItemsRequest {}
192
193/// AddressGroup is a resource that specifies how a collection of IP/DNS used in Firewall Policy.
194///
195/// # Activities
196///
197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
199///
200/// * [locations address groups create organizations](OrganizationLocationAddressGroupCreateCall) (request)
201/// * [locations address groups get organizations](OrganizationLocationAddressGroupGetCall) (response)
202/// * [locations address groups patch organizations](OrganizationLocationAddressGroupPatchCall) (request)
203/// * [locations address groups create projects](ProjectLocationAddressGroupCreateCall) (request)
204/// * [locations address groups get projects](ProjectLocationAddressGroupGetCall) (response)
205/// * [locations address groups patch projects](ProjectLocationAddressGroupPatchCall) (request)
206#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
207#[serde_with::serde_as]
208#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
209pub struct AddressGroup {
210    /// Required. Capacity of the Address Group
211    pub capacity: Option<i32>,
212    /// Output only. The timestamp when the resource was created.
213    #[serde(rename = "createTime")]
214    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
215    /// Optional. Free-text description of the resource.
216    pub description: Option<String>,
217    /// Optional. List of items.
218    pub items: Option<Vec<String>>,
219    /// Optional. Set of label tags associated with the AddressGroup resource.
220    pub labels: Option<HashMap<String, String>>,
221    /// Required. Name of the AddressGroup resource. It matches pattern `projects/*/locations/{location}/addressGroups/`.
222    pub name: Option<String>,
223    /// Output only. Server-defined fully-qualified URL for this resource.
224    #[serde(rename = "selfLink")]
225    pub self_link: Option<String>,
226    /// Required. The type of the Address Group. Possible values are "IPv4" or "IPV6".
227    #[serde(rename = "type")]
228    pub type_: Option<String>,
229    /// Output only. The timestamp when the resource was updated.
230    #[serde(rename = "updateTime")]
231    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
232}
233
234impl common::RequestValue for AddressGroup {}
235impl common::ResponseResult for AddressGroup {}
236
237/// AuthorizationPolicy is a resource that specifies how a server should authorize incoming connections. This resource in itself does not change the configuration unless it’s attached to a target https proxy or endpoint config selector resource.
238///
239/// # Activities
240///
241/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
242/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
243///
244/// * [locations authorization policies create projects](ProjectLocationAuthorizationPolicyCreateCall) (request)
245/// * [locations authorization policies get projects](ProjectLocationAuthorizationPolicyGetCall) (response)
246/// * [locations authorization policies patch projects](ProjectLocationAuthorizationPolicyPatchCall) (request)
247#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
248#[serde_with::serde_as]
249#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
250pub struct AuthorizationPolicy {
251    /// Required. The action to take when a rule match is found. Possible values are "ALLOW" or "DENY".
252    pub action: Option<String>,
253    /// Output only. The timestamp when the resource was created.
254    #[serde(rename = "createTime")]
255    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
256    /// Optional. Free-text description of the resource.
257    pub description: Option<String>,
258    /// Optional. Set of label tags associated with the AuthorizationPolicy resource.
259    pub labels: Option<HashMap<String, String>>,
260    /// Required. Name of the AuthorizationPolicy resource. It matches pattern `projects/{project}/locations/{location}/authorizationPolicies/`.
261    pub name: Option<String>,
262    /// Optional. List of rules to match. Note that at least one of the rules must match in order for the action specified in the 'action' field to be taken. A rule is a match if there is a matching source and destination. If left blank, the action specified in the `action` field will be applied on every request.
263    pub rules: Option<Vec<Rule>>,
264    /// Output only. The timestamp when the resource was updated.
265    #[serde(rename = "updateTime")]
266    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
267}
268
269impl common::RequestValue for AuthorizationPolicy {}
270impl common::ResponseResult for AuthorizationPolicy {}
271
272/// The request message for Operations.CancelOperation.
273///
274/// # Activities
275///
276/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
277/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
278///
279/// * [locations operations cancel organizations](OrganizationLocationOperationCancelCall) (request)
280/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
282#[serde_with::serde_as]
283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
284pub struct CancelOperationRequest {
285    _never_set: Option<bool>,
286}
287
288impl common::RequestValue for CancelOperationRequest {}
289
290/// Specification of a TLS certificate provider instance. Workloads may have one or more CertificateProvider instances (plugins) and one of them is enabled and configured by specifying this message. Workloads use the values from this message to locate and load the CertificateProvider instance configuration.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct CertificateProviderInstance {
298    /// Required. Plugin instance name, used to locate and load CertificateProvider instance configuration. Set to "google_cloud_private_spiffe" to use Certificate Authority Service certificate provider instance.
299    #[serde(rename = "pluginInstance")]
300    pub plugin_instance: Option<String>,
301}
302
303impl common::Part for CertificateProviderInstance {}
304
305/// ClientTlsPolicy is a resource that specifies how a client should authenticate connections to backends of a service. This resource itself does not affect configuration unless it is attached to a backend service resource.
306///
307/// # Activities
308///
309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
311///
312/// * [locations client tls policies create projects](ProjectLocationClientTlsPolicyCreateCall) (request)
313/// * [locations client tls policies get projects](ProjectLocationClientTlsPolicyGetCall) (response)
314/// * [locations client tls policies patch projects](ProjectLocationClientTlsPolicyPatchCall) (request)
315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
316#[serde_with::serde_as]
317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
318pub struct ClientTlsPolicy {
319    /// Optional. Defines a mechanism to provision client identity (public and private keys) for peer to peer authentication. The presence of this dictates mTLS.
320    #[serde(rename = "clientCertificate")]
321    pub client_certificate: Option<GoogleCloudNetworksecurityV1CertificateProvider>,
322    /// Output only. The timestamp when the resource was created.
323    #[serde(rename = "createTime")]
324    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
325    /// Optional. Free-text description of the resource.
326    pub description: Option<String>,
327    /// Optional. Set of label tags associated with the resource.
328    pub labels: Option<HashMap<String, String>>,
329    /// Required. Name of the ClientTlsPolicy resource. It matches the pattern `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}`
330    pub name: Option<String>,
331    /// Optional. Defines the mechanism to obtain the Certificate Authority certificate to validate the server certificate. If empty, client does not validate the server certificate.
332    #[serde(rename = "serverValidationCa")]
333    pub server_validation_ca: Option<Vec<ValidationCA>>,
334    /// Optional. Server Name Indication string to present to the server during TLS handshake. E.g: "secure.example.com".
335    pub sni: Option<String>,
336    /// Output only. The timestamp when the resource was updated.
337    #[serde(rename = "updateTime")]
338    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
339}
340
341impl common::RequestValue for ClientTlsPolicy {}
342impl common::ResponseResult for ClientTlsPolicy {}
343
344/// Request used by the CloneAddressGroupItems method.
345///
346/// # Activities
347///
348/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
349/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
350///
351/// * [locations address groups clone items organizations](OrganizationLocationAddressGroupCloneItemCall) (request)
352/// * [locations address groups clone items projects](ProjectLocationAddressGroupCloneItemCall) (request)
353#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
354#[serde_with::serde_as]
355#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
356pub struct CloneAddressGroupItemsRequest {
357    /// Optional. 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).
358    #[serde(rename = "requestId")]
359    pub request_id: Option<String>,
360    /// Required. Source address group to clone items from.
361    #[serde(rename = "sourceAddressGroup")]
362    pub source_address_group: Option<String>,
363}
364
365impl common::RequestValue for CloneAddressGroupItemsRequest {}
366
367/// Specification of traffic destination attributes.
368///
369/// This type is not used in any activity, and only used as *part* of another schema.
370///
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct Destination {
375    /// Required. List of host names to match. Matched against the ":authority" header in http requests. At least one host should match. Each host can be an exact match, or a prefix match (example "mydomain.*") or a suffix match (example "*.myorg.com") or a presence (any) match "*".
376    pub hosts: Option<Vec<String>>,
377    /// Optional. Match against key:value pair in http header. Provides a flexible match based on HTTP headers, for potentially advanced use cases. At least one header should match. Avoid using header matches to make authorization decisions unless there is a strong guarantee that requests arrive through a trusted client or proxy.
378    #[serde(rename = "httpHeaderMatch")]
379    pub http_header_match: Option<HttpHeaderMatch>,
380    /// Optional. A list of HTTP methods to match. At least one method should match. Should not be set for gRPC services.
381    pub methods: Option<Vec<String>>,
382    /// Required. List of destination ports to match. At least one port should match.
383    pub ports: Option<Vec<u32>>,
384}
385
386impl common::Part for Destination {}
387
388/// 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); }
389///
390/// # Activities
391///
392/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
393/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
394///
395/// * [locations operations cancel organizations](OrganizationLocationOperationCancelCall) (response)
396/// * [locations operations delete organizations](OrganizationLocationOperationDeleteCall) (response)
397/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
398/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
399#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
400#[serde_with::serde_as]
401#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
402pub struct Empty {
403    _never_set: Option<bool>,
404}
405
406impl common::ResponseResult for Empty {}
407
408/// 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.
409///
410/// This type is not used in any activity, and only used as *part* of another schema.
411///
412#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
413#[serde_with::serde_as]
414#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
415pub struct Expr {
416    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
417    pub description: Option<String>,
418    /// Textual representation of an expression in Common Expression Language syntax.
419    pub expression: Option<String>,
420    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
421    pub location: Option<String>,
422    /// 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.
423    pub title: Option<String>,
424}
425
426impl common::Part for Expr {}
427
428/// Message describing Endpoint object
429///
430/// # Activities
431///
432/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
433/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
434///
435/// * [locations firewall endpoints create organizations](OrganizationLocationFirewallEndpointCreateCall) (request)
436/// * [locations firewall endpoints get organizations](OrganizationLocationFirewallEndpointGetCall) (response)
437/// * [locations firewall endpoints patch organizations](OrganizationLocationFirewallEndpointPatchCall) (request)
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct FirewallEndpoint {
442    /// Output only. List of networks that are associated with this endpoint in the local zone. This is a projection of the FirewallEndpointAssociations pointing at this endpoint. A network will only appear in this list after traffic routing is fully configured. Format: projects/{project}/global/networks/{name}.
443    #[serde(rename = "associatedNetworks")]
444    pub associated_networks: Option<Vec<String>>,
445    /// Output only. List of FirewallEndpointAssociations that are associated to this endpoint. An association will only appear in this list after traffic routing is fully configured.
446    pub associations: Option<Vec<FirewallEndpointAssociationReference>>,
447    /// Required. Project to bill on endpoint uptime usage.
448    #[serde(rename = "billingProjectId")]
449    pub billing_project_id: Option<String>,
450    /// Output only. Create time stamp
451    #[serde(rename = "createTime")]
452    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
453    /// Optional. Description of the firewall endpoint. Max length 2048 characters.
454    pub description: Option<String>,
455    /// Optional. Labels as key value pairs
456    pub labels: Option<HashMap<String, String>>,
457    /// Immutable. Identifier. name of resource
458    pub name: Option<String>,
459    /// Output only. Whether reconciling is in progress, recommended per https://google.aip.dev/128.
460    pub reconciling: Option<bool>,
461    /// Output only. Current state of the endpoint.
462    pub state: Option<String>,
463    /// Output only. Update time stamp
464    #[serde(rename = "updateTime")]
465    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
466}
467
468impl common::RequestValue for FirewallEndpoint {}
469impl common::ResponseResult for FirewallEndpoint {}
470
471/// Message describing Association object
472///
473/// # Activities
474///
475/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
476/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
477///
478/// * [locations firewall endpoint associations create projects](ProjectLocationFirewallEndpointAssociationCreateCall) (request)
479/// * [locations firewall endpoint associations get projects](ProjectLocationFirewallEndpointAssociationGetCall) (response)
480/// * [locations firewall endpoint associations patch projects](ProjectLocationFirewallEndpointAssociationPatchCall) (request)
481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
482#[serde_with::serde_as]
483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
484pub struct FirewallEndpointAssociation {
485    /// Output only. Create time stamp
486    #[serde(rename = "createTime")]
487    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
488    /// Optional. Whether the association is disabled. True indicates that traffic won't be intercepted
489    pub disabled: Option<bool>,
490    /// Required. The URL of the FirewallEndpoint that is being associated.
491    #[serde(rename = "firewallEndpoint")]
492    pub firewall_endpoint: Option<String>,
493    /// Optional. Labels as key value pairs
494    pub labels: Option<HashMap<String, String>>,
495    /// Immutable. Identifier. name of resource
496    pub name: Option<String>,
497    /// Required. The URL of the network that is being associated.
498    pub network: Option<String>,
499    /// Output only. Whether reconciling is in progress, recommended per https://google.aip.dev/128.
500    pub reconciling: Option<bool>,
501    /// Output only. Current state of the association.
502    pub state: Option<String>,
503    /// Optional. The URL of the TlsInspectionPolicy that is being associated.
504    #[serde(rename = "tlsInspectionPolicy")]
505    pub tls_inspection_policy: Option<String>,
506    /// Output only. Update time stamp
507    #[serde(rename = "updateTime")]
508    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
509}
510
511impl common::RequestValue for FirewallEndpointAssociation {}
512impl common::ResponseResult for FirewallEndpointAssociation {}
513
514/// This is a subset of the FirewallEndpointAssociation message, containing fields to be used by the consumer.
515///
516/// This type is not used in any activity, and only used as *part* of another schema.
517///
518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
519#[serde_with::serde_as]
520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
521pub struct FirewallEndpointAssociationReference {
522    /// Output only. The resource name of the FirewallEndpointAssociation. Format: projects/{project}/locations/{location}/firewallEndpointAssociations/{id}
523    pub name: Option<String>,
524    /// Output only. The VPC network associated. Format: projects/{project}/global/networks/{name}.
525    pub network: Option<String>,
526}
527
528impl common::Part for FirewallEndpointAssociationReference {}
529
530/// The GatewaySecurityPolicy resource contains a collection of GatewaySecurityPolicyRules and associated metadata.
531///
532/// # Activities
533///
534/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
535/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
536///
537/// * [locations gateway security policies create projects](ProjectLocationGatewaySecurityPolicyCreateCall) (request)
538/// * [locations gateway security policies get projects](ProjectLocationGatewaySecurityPolicyGetCall) (response)
539/// * [locations gateway security policies patch projects](ProjectLocationGatewaySecurityPolicyPatchCall) (request)
540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
541#[serde_with::serde_as]
542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
543pub struct GatewaySecurityPolicy {
544    /// Output only. The timestamp when the resource was created.
545    #[serde(rename = "createTime")]
546    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
547    /// Optional. Free-text description of the resource.
548    pub description: Option<String>,
549    /// Required. Name of the resource. Name is of the form projects/{project}/locations/{location}/gatewaySecurityPolicies/{gateway_security_policy} gateway_security_policy should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
550    pub name: Option<String>,
551    /// Optional. Name of a TLS Inspection Policy resource that defines how TLS inspection will be performed for any rule(s) which enables it.
552    #[serde(rename = "tlsInspectionPolicy")]
553    pub tls_inspection_policy: Option<String>,
554    /// Output only. The timestamp when the resource was updated.
555    #[serde(rename = "updateTime")]
556    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
557}
558
559impl common::RequestValue for GatewaySecurityPolicy {}
560impl common::ResponseResult for GatewaySecurityPolicy {}
561
562/// The GatewaySecurityPolicyRule resource is in a nested collection within a GatewaySecurityPolicy and represents a traffic matching condition and associated action to perform.
563///
564/// # Activities
565///
566/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
567/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
568///
569/// * [locations gateway security policies rules create projects](ProjectLocationGatewaySecurityPolicyRuleCreateCall) (request)
570/// * [locations gateway security policies rules get projects](ProjectLocationGatewaySecurityPolicyRuleGetCall) (response)
571/// * [locations gateway security policies rules patch projects](ProjectLocationGatewaySecurityPolicyRulePatchCall) (request)
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct GatewaySecurityPolicyRule {
576    /// Optional. CEL expression for matching on L7/application level criteria.
577    #[serde(rename = "applicationMatcher")]
578    pub application_matcher: Option<String>,
579    /// Required. Profile which tells what the primitive action should be.
580    #[serde(rename = "basicProfile")]
581    pub basic_profile: Option<String>,
582    /// Output only. Time when the rule was created.
583    #[serde(rename = "createTime")]
584    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
585    /// Optional. Free-text description of the resource.
586    pub description: Option<String>,
587    /// Required. Whether the rule is enforced.
588    pub enabled: Option<bool>,
589    /// Required. Immutable. Name of the resource. ame is the full resource name so projects/{project}/locations/{location}/gatewaySecurityPolicies/{gateway_security_policy}/rules/{rule} rule should match the pattern: (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
590    pub name: Option<String>,
591    /// Required. Priority of the rule. Lower number corresponds to higher precedence.
592    pub priority: Option<i32>,
593    /// Required. CEL expression for matching on session criteria.
594    #[serde(rename = "sessionMatcher")]
595    pub session_matcher: Option<String>,
596    /// Optional. Flag to enable TLS inspection of traffic matching on , can only be true if the parent GatewaySecurityPolicy references a TLSInspectionConfig.
597    #[serde(rename = "tlsInspectionEnabled")]
598    pub tls_inspection_enabled: Option<bool>,
599    /// Output only. Time when the rule was updated.
600    #[serde(rename = "updateTime")]
601    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
602}
603
604impl common::RequestValue for GatewaySecurityPolicyRule {}
605impl common::ResponseResult for GatewaySecurityPolicyRule {}
606
607/// Specification of certificate provider. Defines the mechanism to obtain the certificate and private key for peer to peer authentication.
608///
609/// This type is not used in any activity, and only used as *part* of another schema.
610///
611#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
612#[serde_with::serde_as]
613#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
614pub struct GoogleCloudNetworksecurityV1CertificateProvider {
615    /// The certificate provider instance specification that will be passed to the data plane, which will be used to load necessary credential information.
616    #[serde(rename = "certificateProviderInstance")]
617    pub certificate_provider_instance: Option<CertificateProviderInstance>,
618    /// gRPC specific configuration to access the gRPC server to obtain the cert and private key.
619    #[serde(rename = "grpcEndpoint")]
620    pub grpc_endpoint: Option<GoogleCloudNetworksecurityV1GrpcEndpoint>,
621}
622
623impl common::Part for GoogleCloudNetworksecurityV1CertificateProvider {}
624
625/// Specification of the GRPC Endpoint.
626///
627/// This type is not used in any activity, and only used as *part* of another schema.
628///
629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
630#[serde_with::serde_as]
631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
632pub struct GoogleCloudNetworksecurityV1GrpcEndpoint {
633    /// Required. The target URI of the gRPC endpoint. Only UDS path is supported, and should start with "unix:".
634    #[serde(rename = "targetUri")]
635    pub target_uri: Option<String>,
636}
637
638impl common::Part for GoogleCloudNetworksecurityV1GrpcEndpoint {}
639
640/// 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.
641///
642/// This type is not used in any activity, and only used as *part* of another schema.
643///
644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
645#[serde_with::serde_as]
646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
647pub struct GoogleIamV1AuditConfig {
648    /// The configuration for logging of each type of permission.
649    #[serde(rename = "auditLogConfigs")]
650    pub audit_log_configs: Option<Vec<GoogleIamV1AuditLogConfig>>,
651    /// 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.
652    pub service: Option<String>,
653}
654
655impl common::Part for GoogleIamV1AuditConfig {}
656
657/// 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.
658///
659/// This type is not used in any activity, and only used as *part* of another schema.
660///
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct GoogleIamV1AuditLogConfig {
665    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
666    #[serde(rename = "exemptedMembers")]
667    pub exempted_members: Option<Vec<String>>,
668    /// The log type that this config enables.
669    #[serde(rename = "logType")]
670    pub log_type: Option<String>,
671}
672
673impl common::Part for GoogleIamV1AuditLogConfig {}
674
675/// Associates `members`, or principals, with a `role`.
676///
677/// This type is not used in any activity, and only used as *part* of another schema.
678///
679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
680#[serde_with::serde_as]
681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
682pub struct GoogleIamV1Binding {
683    /// 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).
684    pub condition: Option<Expr>,
685    /// 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`.
686    pub members: Option<Vec<String>>,
687    /// 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).
688    pub role: Option<String>,
689}
690
691impl common::Part for GoogleIamV1Binding {}
692
693/// 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/).
694///
695/// # Activities
696///
697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
699///
700/// * [locations address groups get iam policy projects](ProjectLocationAddressGroupGetIamPolicyCall) (response)
701/// * [locations address groups set iam policy projects](ProjectLocationAddressGroupSetIamPolicyCall) (response)
702/// * [locations authorization policies get iam policy projects](ProjectLocationAuthorizationPolicyGetIamPolicyCall) (response)
703/// * [locations authorization policies set iam policy projects](ProjectLocationAuthorizationPolicySetIamPolicyCall) (response)
704/// * [locations client tls policies get iam policy projects](ProjectLocationClientTlsPolicyGetIamPolicyCall) (response)
705/// * [locations client tls policies set iam policy projects](ProjectLocationClientTlsPolicySetIamPolicyCall) (response)
706/// * [locations server tls policies get iam policy projects](ProjectLocationServerTlsPolicyGetIamPolicyCall) (response)
707/// * [locations server tls policies set iam policy projects](ProjectLocationServerTlsPolicySetIamPolicyCall) (response)
708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
709#[serde_with::serde_as]
710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
711pub struct GoogleIamV1Policy {
712    /// Specifies cloud audit logging configuration for this policy.
713    #[serde(rename = "auditConfigs")]
714    pub audit_configs: Option<Vec<GoogleIamV1AuditConfig>>,
715    /// 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`.
716    pub bindings: Option<Vec<GoogleIamV1Binding>>,
717    /// `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.
718    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
719    pub etag: Option<Vec<u8>>,
720    /// 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).
721    pub version: Option<i32>,
722}
723
724impl common::ResponseResult for GoogleIamV1Policy {}
725
726/// Request message for `SetIamPolicy` method.
727///
728/// # Activities
729///
730/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
732///
733/// * [locations address groups set iam policy projects](ProjectLocationAddressGroupSetIamPolicyCall) (request)
734/// * [locations authorization policies set iam policy projects](ProjectLocationAuthorizationPolicySetIamPolicyCall) (request)
735/// * [locations client tls policies set iam policy projects](ProjectLocationClientTlsPolicySetIamPolicyCall) (request)
736/// * [locations server tls policies set iam policy projects](ProjectLocationServerTlsPolicySetIamPolicyCall) (request)
737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
738#[serde_with::serde_as]
739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
740pub struct GoogleIamV1SetIamPolicyRequest {
741    /// 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.
742    pub policy: Option<GoogleIamV1Policy>,
743    /// 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"`
744    #[serde(rename = "updateMask")]
745    pub update_mask: Option<common::FieldMask>,
746}
747
748impl common::RequestValue for GoogleIamV1SetIamPolicyRequest {}
749
750/// Request message for `TestIamPermissions` method.
751///
752/// # Activities
753///
754/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
755/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
756///
757/// * [locations address groups test iam permissions projects](ProjectLocationAddressGroupTestIamPermissionCall) (request)
758/// * [locations authorization policies test iam permissions projects](ProjectLocationAuthorizationPolicyTestIamPermissionCall) (request)
759/// * [locations client tls policies test iam permissions projects](ProjectLocationClientTlsPolicyTestIamPermissionCall) (request)
760/// * [locations server tls policies test iam permissions projects](ProjectLocationServerTlsPolicyTestIamPermissionCall) (request)
761#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
762#[serde_with::serde_as]
763#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
764pub struct GoogleIamV1TestIamPermissionsRequest {
765    /// 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).
766    pub permissions: Option<Vec<String>>,
767}
768
769impl common::RequestValue for GoogleIamV1TestIamPermissionsRequest {}
770
771/// Response message for `TestIamPermissions` method.
772///
773/// # Activities
774///
775/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
776/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
777///
778/// * [locations address groups test iam permissions projects](ProjectLocationAddressGroupTestIamPermissionCall) (response)
779/// * [locations authorization policies test iam permissions projects](ProjectLocationAuthorizationPolicyTestIamPermissionCall) (response)
780/// * [locations client tls policies test iam permissions projects](ProjectLocationClientTlsPolicyTestIamPermissionCall) (response)
781/// * [locations server tls policies test iam permissions projects](ProjectLocationServerTlsPolicyTestIamPermissionCall) (response)
782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
783#[serde_with::serde_as]
784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
785pub struct GoogleIamV1TestIamPermissionsResponse {
786    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
787    pub permissions: Option<Vec<String>>,
788}
789
790impl common::ResponseResult for GoogleIamV1TestIamPermissionsResponse {}
791
792/// Specification of HTTP header match attributes.
793///
794/// This type is not used in any activity, and only used as *part* of another schema.
795///
796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
797#[serde_with::serde_as]
798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
799pub struct HttpHeaderMatch {
800    /// Required. The name of the HTTP header to match. For matching against the HTTP request's authority, use a headerMatch with the header name ":authority". For matching a request's method, use the headerName ":method".
801    #[serde(rename = "headerName")]
802    pub header_name: Option<String>,
803    /// Required. The value of the header must match the regular expression specified in regexMatch. For regular expression grammar, please see: en.cppreference.com/w/cpp/regex/ecmascript For matching against a port specified in the HTTP request, use a headerMatch with headerName set to Host and a regular expression that satisfies the RFC2616 Host header's port specifier.
804    #[serde(rename = "regexMatch")]
805    pub regex_match: Option<String>,
806}
807
808impl common::Part for HttpHeaderMatch {}
809
810/// Response of the ListAddressGroupReferences method.
811///
812/// # Activities
813///
814/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
815/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
816///
817/// * [locations address groups list references organizations](OrganizationLocationAddressGroupListReferenceCall) (response)
818/// * [locations address groups list references projects](ProjectLocationAddressGroupListReferenceCall) (response)
819#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
820#[serde_with::serde_as]
821#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
822pub struct ListAddressGroupReferencesResponse {
823    /// A list of references that matches the specified filter in the request.
824    #[serde(rename = "addressGroupReferences")]
825    pub address_group_references:
826        Option<Vec<ListAddressGroupReferencesResponseAddressGroupReference>>,
827    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
828    #[serde(rename = "nextPageToken")]
829    pub next_page_token: Option<String>,
830}
831
832impl common::ResponseResult for ListAddressGroupReferencesResponse {}
833
834/// The Reference of AddressGroup.
835///
836/// This type is not used in any activity, and only used as *part* of another schema.
837///
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct ListAddressGroupReferencesResponseAddressGroupReference {
842    /// FirewallPolicy that is using the Address Group.
843    #[serde(rename = "firewallPolicy")]
844    pub firewall_policy: Option<String>,
845    /// Rule priority of the FirewallPolicy that is using the Address Group.
846    #[serde(rename = "rulePriority")]
847    pub rule_priority: Option<i32>,
848    /// Cloud Armor SecurityPolicy that is using the Address Group.
849    #[serde(rename = "securityPolicy")]
850    pub security_policy: Option<String>,
851}
852
853impl common::Part for ListAddressGroupReferencesResponseAddressGroupReference {}
854
855/// Response returned by the ListAddressGroups method.
856///
857/// # Activities
858///
859/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
860/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
861///
862/// * [locations address groups list organizations](OrganizationLocationAddressGroupListCall) (response)
863/// * [locations address groups list projects](ProjectLocationAddressGroupListCall) (response)
864#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
865#[serde_with::serde_as]
866#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
867pub struct ListAddressGroupsResponse {
868    /// List of AddressGroups resources.
869    #[serde(rename = "addressGroups")]
870    pub address_groups: Option<Vec<AddressGroup>>,
871    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
872    #[serde(rename = "nextPageToken")]
873    pub next_page_token: Option<String>,
874}
875
876impl common::ResponseResult for ListAddressGroupsResponse {}
877
878/// Response returned by the ListAuthorizationPolicies method.
879///
880/// # Activities
881///
882/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
883/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
884///
885/// * [locations authorization policies list projects](ProjectLocationAuthorizationPolicyListCall) (response)
886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
887#[serde_with::serde_as]
888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
889pub struct ListAuthorizationPoliciesResponse {
890    /// List of AuthorizationPolicies resources.
891    #[serde(rename = "authorizationPolicies")]
892    pub authorization_policies: Option<Vec<AuthorizationPolicy>>,
893    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
894    #[serde(rename = "nextPageToken")]
895    pub next_page_token: Option<String>,
896}
897
898impl common::ResponseResult for ListAuthorizationPoliciesResponse {}
899
900/// Response returned by the ListClientTlsPolicies method.
901///
902/// # Activities
903///
904/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
905/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
906///
907/// * [locations client tls policies list projects](ProjectLocationClientTlsPolicyListCall) (response)
908#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
909#[serde_with::serde_as]
910#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
911pub struct ListClientTlsPoliciesResponse {
912    /// List of ClientTlsPolicy resources.
913    #[serde(rename = "clientTlsPolicies")]
914    pub client_tls_policies: Option<Vec<ClientTlsPolicy>>,
915    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
916    #[serde(rename = "nextPageToken")]
917    pub next_page_token: Option<String>,
918}
919
920impl common::ResponseResult for ListClientTlsPoliciesResponse {}
921
922/// Message for response to listing Associations
923///
924/// # Activities
925///
926/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
927/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
928///
929/// * [locations firewall endpoint associations list projects](ProjectLocationFirewallEndpointAssociationListCall) (response)
930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
931#[serde_with::serde_as]
932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
933pub struct ListFirewallEndpointAssociationsResponse {
934    /// The list of Association
935    #[serde(rename = "firewallEndpointAssociations")]
936    pub firewall_endpoint_associations: Option<Vec<FirewallEndpointAssociation>>,
937    /// A token identifying a page of results the server should return.
938    #[serde(rename = "nextPageToken")]
939    pub next_page_token: Option<String>,
940    /// Locations that could not be reached.
941    pub unreachable: Option<Vec<String>>,
942}
943
944impl common::ResponseResult for ListFirewallEndpointAssociationsResponse {}
945
946/// Message for response to listing Endpoints
947///
948/// # Activities
949///
950/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
951/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
952///
953/// * [locations firewall endpoints list organizations](OrganizationLocationFirewallEndpointListCall) (response)
954#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
955#[serde_with::serde_as]
956#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
957pub struct ListFirewallEndpointsResponse {
958    /// The list of Endpoint
959    #[serde(rename = "firewallEndpoints")]
960    pub firewall_endpoints: Option<Vec<FirewallEndpoint>>,
961    /// A token identifying a page of results the server should return.
962    #[serde(rename = "nextPageToken")]
963    pub next_page_token: Option<String>,
964    /// Locations that could not be reached.
965    pub unreachable: Option<Vec<String>>,
966}
967
968impl common::ResponseResult for ListFirewallEndpointsResponse {}
969
970/// Response returned by the ListGatewaySecurityPolicies method.
971///
972/// # Activities
973///
974/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
975/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
976///
977/// * [locations gateway security policies list projects](ProjectLocationGatewaySecurityPolicyListCall) (response)
978#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
979#[serde_with::serde_as]
980#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
981pub struct ListGatewaySecurityPoliciesResponse {
982    /// List of GatewaySecurityPolicies resources.
983    #[serde(rename = "gatewaySecurityPolicies")]
984    pub gateway_security_policies: Option<Vec<GatewaySecurityPolicy>>,
985    /// If there might be more results than those appearing in this response, then 'next_page_token' is included. To get the next set of results, call this method again using the value of 'next_page_token' as 'page_token'.
986    #[serde(rename = "nextPageToken")]
987    pub next_page_token: Option<String>,
988    /// Locations that could not be reached.
989    pub unreachable: Option<Vec<String>>,
990}
991
992impl common::ResponseResult for ListGatewaySecurityPoliciesResponse {}
993
994/// Response returned by the ListGatewaySecurityPolicyRules method.
995///
996/// # Activities
997///
998/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
999/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1000///
1001/// * [locations gateway security policies rules list projects](ProjectLocationGatewaySecurityPolicyRuleListCall) (response)
1002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1003#[serde_with::serde_as]
1004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1005pub struct ListGatewaySecurityPolicyRulesResponse {
1006    /// List of GatewaySecurityPolicyRule resources.
1007    #[serde(rename = "gatewaySecurityPolicyRules")]
1008    pub gateway_security_policy_rules: Option<Vec<GatewaySecurityPolicyRule>>,
1009    /// If there might be more results than those appearing in this response, then 'next_page_token' is included. To get the next set of results, call this method again using the value of 'next_page_token' as 'page_token'.
1010    #[serde(rename = "nextPageToken")]
1011    pub next_page_token: Option<String>,
1012    /// Locations that could not be reached.
1013    pub unreachable: Option<Vec<String>>,
1014}
1015
1016impl common::ResponseResult for ListGatewaySecurityPolicyRulesResponse {}
1017
1018/// The response message for Locations.ListLocations.
1019///
1020/// # Activities
1021///
1022/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1023/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1024///
1025/// * [locations list projects](ProjectLocationListCall) (response)
1026#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1027#[serde_with::serde_as]
1028#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1029pub struct ListLocationsResponse {
1030    /// A list of locations that matches the specified filter in the request.
1031    pub locations: Option<Vec<Location>>,
1032    /// The standard List next-page token.
1033    #[serde(rename = "nextPageToken")]
1034    pub next_page_token: Option<String>,
1035}
1036
1037impl common::ResponseResult for ListLocationsResponse {}
1038
1039/// The response message for Operations.ListOperations.
1040///
1041/// # Activities
1042///
1043/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1044/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1045///
1046/// * [locations operations list organizations](OrganizationLocationOperationListCall) (response)
1047/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
1048#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1049#[serde_with::serde_as]
1050#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1051pub struct ListOperationsResponse {
1052    /// The standard List next-page token.
1053    #[serde(rename = "nextPageToken")]
1054    pub next_page_token: Option<String>,
1055    /// A list of operations that matches the specified filter in the request.
1056    pub operations: Option<Vec<Operation>>,
1057}
1058
1059impl common::ResponseResult for ListOperationsResponse {}
1060
1061/// Response returned by the ListSecurityProfileGroups method.
1062///
1063/// # Activities
1064///
1065/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1066/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1067///
1068/// * [locations security profile groups list organizations](OrganizationLocationSecurityProfileGroupListCall) (response)
1069#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1070#[serde_with::serde_as]
1071#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1072pub struct ListSecurityProfileGroupsResponse {
1073    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
1074    #[serde(rename = "nextPageToken")]
1075    pub next_page_token: Option<String>,
1076    /// List of SecurityProfileGroups resources.
1077    #[serde(rename = "securityProfileGroups")]
1078    pub security_profile_groups: Option<Vec<SecurityProfileGroup>>,
1079}
1080
1081impl common::ResponseResult for ListSecurityProfileGroupsResponse {}
1082
1083/// Response returned by the ListSecurityProfiles method.
1084///
1085/// # Activities
1086///
1087/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1088/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1089///
1090/// * [locations security profiles list organizations](OrganizationLocationSecurityProfileListCall) (response)
1091#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1092#[serde_with::serde_as]
1093#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1094pub struct ListSecurityProfilesResponse {
1095    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
1096    #[serde(rename = "nextPageToken")]
1097    pub next_page_token: Option<String>,
1098    /// List of SecurityProfile resources.
1099    #[serde(rename = "securityProfiles")]
1100    pub security_profiles: Option<Vec<SecurityProfile>>,
1101}
1102
1103impl common::ResponseResult for ListSecurityProfilesResponse {}
1104
1105/// Response returned by the ListServerTlsPolicies method.
1106///
1107/// # Activities
1108///
1109/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1110/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1111///
1112/// * [locations server tls policies list projects](ProjectLocationServerTlsPolicyListCall) (response)
1113#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1114#[serde_with::serde_as]
1115#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1116pub struct ListServerTlsPoliciesResponse {
1117    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
1118    #[serde(rename = "nextPageToken")]
1119    pub next_page_token: Option<String>,
1120    /// List of ServerTlsPolicy resources.
1121    #[serde(rename = "serverTlsPolicies")]
1122    pub server_tls_policies: Option<Vec<ServerTlsPolicy>>,
1123}
1124
1125impl common::ResponseResult for ListServerTlsPoliciesResponse {}
1126
1127/// Response returned by the ListTlsInspectionPolicies method.
1128///
1129/// # Activities
1130///
1131/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1132/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1133///
1134/// * [locations tls inspection policies list projects](ProjectLocationTlsInspectionPolicyListCall) (response)
1135#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1136#[serde_with::serde_as]
1137#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1138pub struct ListTlsInspectionPoliciesResponse {
1139    /// If there might be more results than those appearing in this response, then 'next_page_token' is included. To get the next set of results, call this method again using the value of 'next_page_token' as 'page_token'.
1140    #[serde(rename = "nextPageToken")]
1141    pub next_page_token: Option<String>,
1142    /// List of TlsInspectionPolicies resources.
1143    #[serde(rename = "tlsInspectionPolicies")]
1144    pub tls_inspection_policies: Option<Vec<TlsInspectionPolicy>>,
1145    /// Locations that could not be reached.
1146    pub unreachable: Option<Vec<String>>,
1147}
1148
1149impl common::ResponseResult for ListTlsInspectionPoliciesResponse {}
1150
1151/// Response returned by the ListUrlLists method.
1152///
1153/// # Activities
1154///
1155/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1156/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1157///
1158/// * [locations url lists list projects](ProjectLocationUrlListListCall) (response)
1159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1160#[serde_with::serde_as]
1161#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1162pub struct ListUrlListsResponse {
1163    /// If there might be more results than those appearing in this response, then `next_page_token` is included. To get the next set of results, call this method again using the value of `next_page_token` as `page_token`.
1164    #[serde(rename = "nextPageToken")]
1165    pub next_page_token: Option<String>,
1166    /// Locations that could not be reached.
1167    pub unreachable: Option<Vec<String>>,
1168    /// List of UrlList resources.
1169    #[serde(rename = "urlLists")]
1170    pub url_lists: Option<Vec<UrlList>>,
1171}
1172
1173impl common::ResponseResult for ListUrlListsResponse {}
1174
1175/// A resource that represents a Google Cloud location.
1176///
1177/// # Activities
1178///
1179/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1180/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1181///
1182/// * [locations get projects](ProjectLocationGetCall) (response)
1183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1184#[serde_with::serde_as]
1185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1186pub struct Location {
1187    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1188    #[serde(rename = "displayName")]
1189    pub display_name: Option<String>,
1190    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1191    pub labels: Option<HashMap<String, String>>,
1192    /// The canonical id for this location. For example: `"us-east1"`.
1193    #[serde(rename = "locationId")]
1194    pub location_id: Option<String>,
1195    /// Service-specific metadata. For example the available capacity at the given location.
1196    pub metadata: Option<HashMap<String, serde_json::Value>>,
1197    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1198    pub name: Option<String>,
1199}
1200
1201impl common::ResponseResult for Location {}
1202
1203/// Specification of the MTLSPolicy.
1204///
1205/// This type is not used in any activity, and only used as *part* of another schema.
1206///
1207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1208#[serde_with::serde_as]
1209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1210pub struct MTLSPolicy {
1211    /// Required if the policy is to be used with Traffic Director. For external HTTPS load balancers it must be empty. Defines the mechanism to obtain the Certificate Authority certificate to validate the client certificate.
1212    #[serde(rename = "clientValidationCa")]
1213    pub client_validation_ca: Option<Vec<ValidationCA>>,
1214    /// When the client presents an invalid certificate or no certificate to the load balancer, the `client_validation_mode` specifies how the client connection is handled. Required if the policy is to be used with the external HTTPS load balancing. For Traffic Director it must be empty.
1215    #[serde(rename = "clientValidationMode")]
1216    pub client_validation_mode: Option<String>,
1217    /// Reference to the TrustConfig from certificatemanager.googleapis.com namespace. If specified, the chain validation will be performed against certificates configured in the given TrustConfig. Allowed only if the policy is to be used with external HTTPS load balancers.
1218    #[serde(rename = "clientValidationTrustConfig")]
1219    pub client_validation_trust_config: Option<String>,
1220}
1221
1222impl common::Part for MTLSPolicy {}
1223
1224/// This resource represents a long-running operation that is the result of a network API call.
1225///
1226/// # Activities
1227///
1228/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1229/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1230///
1231/// * [locations address groups add items organizations](OrganizationLocationAddressGroupAddItemCall) (response)
1232/// * [locations address groups clone items organizations](OrganizationLocationAddressGroupCloneItemCall) (response)
1233/// * [locations address groups create organizations](OrganizationLocationAddressGroupCreateCall) (response)
1234/// * [locations address groups delete organizations](OrganizationLocationAddressGroupDeleteCall) (response)
1235/// * [locations address groups patch organizations](OrganizationLocationAddressGroupPatchCall) (response)
1236/// * [locations address groups remove items organizations](OrganizationLocationAddressGroupRemoveItemCall) (response)
1237/// * [locations firewall endpoints create organizations](OrganizationLocationFirewallEndpointCreateCall) (response)
1238/// * [locations firewall endpoints delete organizations](OrganizationLocationFirewallEndpointDeleteCall) (response)
1239/// * [locations firewall endpoints patch organizations](OrganizationLocationFirewallEndpointPatchCall) (response)
1240/// * [locations operations get organizations](OrganizationLocationOperationGetCall) (response)
1241/// * [locations security profile groups create organizations](OrganizationLocationSecurityProfileGroupCreateCall) (response)
1242/// * [locations security profile groups delete organizations](OrganizationLocationSecurityProfileGroupDeleteCall) (response)
1243/// * [locations security profile groups patch organizations](OrganizationLocationSecurityProfileGroupPatchCall) (response)
1244/// * [locations security profiles create organizations](OrganizationLocationSecurityProfileCreateCall) (response)
1245/// * [locations security profiles delete organizations](OrganizationLocationSecurityProfileDeleteCall) (response)
1246/// * [locations security profiles patch organizations](OrganizationLocationSecurityProfilePatchCall) (response)
1247/// * [locations address groups add items projects](ProjectLocationAddressGroupAddItemCall) (response)
1248/// * [locations address groups clone items projects](ProjectLocationAddressGroupCloneItemCall) (response)
1249/// * [locations address groups create projects](ProjectLocationAddressGroupCreateCall) (response)
1250/// * [locations address groups delete projects](ProjectLocationAddressGroupDeleteCall) (response)
1251/// * [locations address groups patch projects](ProjectLocationAddressGroupPatchCall) (response)
1252/// * [locations address groups remove items projects](ProjectLocationAddressGroupRemoveItemCall) (response)
1253/// * [locations authorization policies create projects](ProjectLocationAuthorizationPolicyCreateCall) (response)
1254/// * [locations authorization policies delete projects](ProjectLocationAuthorizationPolicyDeleteCall) (response)
1255/// * [locations authorization policies patch projects](ProjectLocationAuthorizationPolicyPatchCall) (response)
1256/// * [locations client tls policies create projects](ProjectLocationClientTlsPolicyCreateCall) (response)
1257/// * [locations client tls policies delete projects](ProjectLocationClientTlsPolicyDeleteCall) (response)
1258/// * [locations client tls policies patch projects](ProjectLocationClientTlsPolicyPatchCall) (response)
1259/// * [locations firewall endpoint associations create projects](ProjectLocationFirewallEndpointAssociationCreateCall) (response)
1260/// * [locations firewall endpoint associations delete projects](ProjectLocationFirewallEndpointAssociationDeleteCall) (response)
1261/// * [locations firewall endpoint associations patch projects](ProjectLocationFirewallEndpointAssociationPatchCall) (response)
1262/// * [locations gateway security policies rules create projects](ProjectLocationGatewaySecurityPolicyRuleCreateCall) (response)
1263/// * [locations gateway security policies rules delete projects](ProjectLocationGatewaySecurityPolicyRuleDeleteCall) (response)
1264/// * [locations gateway security policies rules patch projects](ProjectLocationGatewaySecurityPolicyRulePatchCall) (response)
1265/// * [locations gateway security policies create projects](ProjectLocationGatewaySecurityPolicyCreateCall) (response)
1266/// * [locations gateway security policies delete projects](ProjectLocationGatewaySecurityPolicyDeleteCall) (response)
1267/// * [locations gateway security policies patch projects](ProjectLocationGatewaySecurityPolicyPatchCall) (response)
1268/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1269/// * [locations server tls policies create projects](ProjectLocationServerTlsPolicyCreateCall) (response)
1270/// * [locations server tls policies delete projects](ProjectLocationServerTlsPolicyDeleteCall) (response)
1271/// * [locations server tls policies patch projects](ProjectLocationServerTlsPolicyPatchCall) (response)
1272/// * [locations tls inspection policies create projects](ProjectLocationTlsInspectionPolicyCreateCall) (response)
1273/// * [locations tls inspection policies delete projects](ProjectLocationTlsInspectionPolicyDeleteCall) (response)
1274/// * [locations tls inspection policies patch projects](ProjectLocationTlsInspectionPolicyPatchCall) (response)
1275/// * [locations url lists create projects](ProjectLocationUrlListCreateCall) (response)
1276/// * [locations url lists delete projects](ProjectLocationUrlListDeleteCall) (response)
1277/// * [locations url lists patch projects](ProjectLocationUrlListPatchCall) (response)
1278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1279#[serde_with::serde_as]
1280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1281pub struct Operation {
1282    /// 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.
1283    pub done: Option<bool>,
1284    /// The error result of the operation in case of failure or cancellation.
1285    pub error: Option<Status>,
1286    /// 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.
1287    pub metadata: Option<HashMap<String, serde_json::Value>>,
1288    /// 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}`.
1289    pub name: Option<String>,
1290    /// 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`.
1291    pub response: Option<HashMap<String, serde_json::Value>>,
1292}
1293
1294impl common::ResponseResult for Operation {}
1295
1296/// Request used by the RemoveAddressGroupItems method.
1297///
1298/// # Activities
1299///
1300/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1302///
1303/// * [locations address groups remove items organizations](OrganizationLocationAddressGroupRemoveItemCall) (request)
1304/// * [locations address groups remove items projects](ProjectLocationAddressGroupRemoveItemCall) (request)
1305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1306#[serde_with::serde_as]
1307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1308pub struct RemoveAddressGroupItemsRequest {
1309    /// Required. List of items to remove.
1310    pub items: Option<Vec<String>>,
1311    /// Optional. 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).
1312    #[serde(rename = "requestId")]
1313    pub request_id: Option<String>,
1314}
1315
1316impl common::RequestValue for RemoveAddressGroupItemsRequest {}
1317
1318/// Specification of rules.
1319///
1320/// This type is not used in any activity, and only used as *part* of another schema.
1321///
1322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1323#[serde_with::serde_as]
1324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1325pub struct Rule {
1326    /// Optional. List of attributes for the traffic destination. All of the destinations must match. A destination is a match if a request matches all the specified hosts, ports, methods and headers. If not set, the action specified in the 'action' field will be applied without any rule checks for the destination.
1327    pub destinations: Option<Vec<Destination>>,
1328    /// Optional. List of attributes for the traffic source. All of the sources must match. A source is a match if both principals and ip_blocks match. If not set, the action specified in the 'action' field will be applied without any rule checks for the source.
1329    pub sources: Option<Vec<Source>>,
1330}
1331
1332impl common::Part for Rule {}
1333
1334/// SecurityProfile is a resource that defines the behavior for one of many ProfileTypes. Next ID: 10
1335///
1336/// # Activities
1337///
1338/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1339/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1340///
1341/// * [locations security profiles create organizations](OrganizationLocationSecurityProfileCreateCall) (request)
1342/// * [locations security profiles get organizations](OrganizationLocationSecurityProfileGetCall) (response)
1343/// * [locations security profiles patch organizations](OrganizationLocationSecurityProfilePatchCall) (request)
1344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1345#[serde_with::serde_as]
1346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1347pub struct SecurityProfile {
1348    /// Output only. Resource creation timestamp.
1349    #[serde(rename = "createTime")]
1350    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1351    /// Optional. An optional description of the profile. Max length 512 characters.
1352    pub description: Option<String>,
1353    /// Output only. This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
1354    pub etag: Option<String>,
1355    /// Optional. Labels as key value pairs.
1356    pub labels: Option<HashMap<String, String>>,
1357    /// Immutable. Identifier. Name of the SecurityProfile resource. It matches pattern `projects|organizations/*/locations/{location}/securityProfiles/{security_profile}`.
1358    pub name: Option<String>,
1359    /// The threat prevention configuration for the SecurityProfile.
1360    #[serde(rename = "threatPreventionProfile")]
1361    pub threat_prevention_profile: Option<ThreatPreventionProfile>,
1362    /// Immutable. The single ProfileType that the SecurityProfile resource configures.
1363    #[serde(rename = "type")]
1364    pub type_: Option<String>,
1365    /// Output only. Last resource update timestamp.
1366    #[serde(rename = "updateTime")]
1367    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1368}
1369
1370impl common::RequestValue for SecurityProfile {}
1371impl common::ResponseResult for SecurityProfile {}
1372
1373/// SecurityProfileGroup is a resource that defines the behavior for various ProfileTypes. Next ID: 9
1374///
1375/// # Activities
1376///
1377/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1378/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1379///
1380/// * [locations security profile groups create organizations](OrganizationLocationSecurityProfileGroupCreateCall) (request)
1381/// * [locations security profile groups get organizations](OrganizationLocationSecurityProfileGroupGetCall) (response)
1382/// * [locations security profile groups patch organizations](OrganizationLocationSecurityProfileGroupPatchCall) (request)
1383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1384#[serde_with::serde_as]
1385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1386pub struct SecurityProfileGroup {
1387    /// Output only. Resource creation timestamp.
1388    #[serde(rename = "createTime")]
1389    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1390    /// Optional. An optional description of the profile group. Max length 2048 characters.
1391    pub description: Option<String>,
1392    /// Output only. This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
1393    pub etag: Option<String>,
1394    /// Optional. Labels as key value pairs.
1395    pub labels: Option<HashMap<String, String>>,
1396    /// Immutable. Identifier. Name of the SecurityProfileGroup resource. It matches pattern `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
1397    pub name: Option<String>,
1398    /// Optional. Reference to a SecurityProfile with the threat prevention configuration for the SecurityProfileGroup.
1399    #[serde(rename = "threatPreventionProfile")]
1400    pub threat_prevention_profile: Option<String>,
1401    /// Output only. Last resource update timestamp.
1402    #[serde(rename = "updateTime")]
1403    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1404}
1405
1406impl common::RequestValue for SecurityProfileGroup {}
1407impl common::ResponseResult for SecurityProfileGroup {}
1408
1409/// ServerTlsPolicy is a resource that specifies how a server should authenticate incoming requests. This resource itself does not affect configuration unless it is attached to a target HTTPS proxy or endpoint config selector resource. ServerTlsPolicy in the form accepted by external HTTPS load balancers can be attached only to TargetHttpsProxy with an `EXTERNAL` or `EXTERNAL_MANAGED` load balancing scheme. Traffic Director compatible ServerTlsPolicies can be attached to EndpointPolicy and TargetHttpsProxy with Traffic Director `INTERNAL_SELF_MANAGED` load balancing scheme.
1410///
1411/// # Activities
1412///
1413/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1414/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1415///
1416/// * [locations server tls policies create projects](ProjectLocationServerTlsPolicyCreateCall) (request)
1417/// * [locations server tls policies get projects](ProjectLocationServerTlsPolicyGetCall) (response)
1418/// * [locations server tls policies patch projects](ProjectLocationServerTlsPolicyPatchCall) (request)
1419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1420#[serde_with::serde_as]
1421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1422pub struct ServerTlsPolicy {
1423    /// This field applies only for Traffic Director policies. It is must be set to false for external HTTPS load balancer policies. Determines if server allows plaintext connections. If set to true, server allows plain text connections. By default, it is set to false. This setting is not exclusive of other encryption modes. For example, if `allow_open` and `mtls_policy` are set, server allows both plain text and mTLS connections. See documentation of other encryption modes to confirm compatibility. Consider using it if you wish to upgrade in place your deployment to TLS while having mixed TLS and non-TLS traffic reaching port :80.
1424    #[serde(rename = "allowOpen")]
1425    pub allow_open: Option<bool>,
1426    /// Output only. The timestamp when the resource was created.
1427    #[serde(rename = "createTime")]
1428    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1429    /// Free-text description of the resource.
1430    pub description: Option<String>,
1431    /// Set of label tags associated with the resource.
1432    pub labels: Option<HashMap<String, String>>,
1433    /// This field is required if the policy is used with external HTTPS load balancers. This field can be empty for Traffic Director. Defines a mechanism to provision peer validation certificates for peer to peer authentication (Mutual TLS - mTLS). If not specified, client certificate will not be requested. The connection is treated as TLS and not mTLS. If `allow_open` and `mtls_policy` are set, server allows both plain text and mTLS connections.
1434    #[serde(rename = "mtlsPolicy")]
1435    pub mtls_policy: Option<MTLSPolicy>,
1436    /// Required. Name of the ServerTlsPolicy resource. It matches the pattern `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}`
1437    pub name: Option<String>,
1438    /// Optional if policy is to be used with Traffic Director. For external HTTPS load balancer must be empty. Defines a mechanism to provision server identity (public and private keys). Cannot be combined with `allow_open` as a permissive mode that allows both plain text and TLS is not supported.
1439    #[serde(rename = "serverCertificate")]
1440    pub server_certificate: Option<GoogleCloudNetworksecurityV1CertificateProvider>,
1441    /// Output only. The timestamp when the resource was updated.
1442    #[serde(rename = "updateTime")]
1443    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1444}
1445
1446impl common::RequestValue for ServerTlsPolicy {}
1447impl common::ResponseResult for ServerTlsPolicy {}
1448
1449/// Defines what action to take for a specific severity match.
1450///
1451/// This type is not used in any activity, and only used as *part* of another schema.
1452///
1453#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1454#[serde_with::serde_as]
1455#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1456pub struct SeverityOverride {
1457    /// Required. Threat action override.
1458    pub action: Option<String>,
1459    /// Required. Severity level to match.
1460    pub severity: Option<String>,
1461}
1462
1463impl common::Part for SeverityOverride {}
1464
1465/// Specification of traffic source attributes.
1466///
1467/// This type is not used in any activity, and only used as *part* of another schema.
1468///
1469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1470#[serde_with::serde_as]
1471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1472pub struct Source {
1473    /// Optional. List of CIDR ranges to match based on source IP address. At least one IP block should match. Single IP (e.g., "1.2.3.4") and CIDR (e.g., "1.2.3.0/24") are supported. Authorization based on source IP alone should be avoided. The IP addresses of any load balancers or proxies should be considered untrusted.
1474    #[serde(rename = "ipBlocks")]
1475    pub ip_blocks: Option<Vec<String>>,
1476    /// Optional. List of peer identities to match for authorization. At least one principal should match. Each peer can be an exact match, or a prefix match (example, "namespace/*") or a suffix match (example, "*/service-account") or a presence match "*". Authorization based on the principal name without certificate validation (configured by ServerTlsPolicy resource) is considered insecure.
1477    pub principals: Option<Vec<String>>,
1478}
1479
1480impl common::Part for Source {}
1481
1482/// 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).
1483///
1484/// This type is not used in any activity, and only used as *part* of another schema.
1485///
1486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1487#[serde_with::serde_as]
1488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1489pub struct Status {
1490    /// The status code, which should be an enum value of google.rpc.Code.
1491    pub code: Option<i32>,
1492    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1493    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1494    /// 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.
1495    pub message: Option<String>,
1496}
1497
1498impl common::Part for Status {}
1499
1500/// Defines what action to take for a specific threat_id match.
1501///
1502/// This type is not used in any activity, and only used as *part* of another schema.
1503///
1504#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1505#[serde_with::serde_as]
1506#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1507pub struct ThreatOverride {
1508    /// Required. Threat action override. For some threat types, only a subset of actions applies.
1509    pub action: Option<String>,
1510    /// Required. Vendor-specific ID of a threat to override.
1511    #[serde(rename = "threatId")]
1512    pub threat_id: Option<String>,
1513    /// Output only. Type of the threat (read only).
1514    #[serde(rename = "type")]
1515    pub type_: Option<String>,
1516}
1517
1518impl common::Part for ThreatOverride {}
1519
1520/// ThreatPreventionProfile defines an action for specific threat signatures or severity levels.
1521///
1522/// This type is not used in any activity, and only used as *part* of another schema.
1523///
1524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1525#[serde_with::serde_as]
1526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1527pub struct ThreatPreventionProfile {
1528    /// Optional. Configuration for overriding threats actions by severity match.
1529    #[serde(rename = "severityOverrides")]
1530    pub severity_overrides: Option<Vec<SeverityOverride>>,
1531    /// Optional. Configuration for overriding threats actions by threat_id match. If a threat is matched both by configuration provided in severity_overrides and threat_overrides, the threat_overrides action is applied.
1532    #[serde(rename = "threatOverrides")]
1533    pub threat_overrides: Option<Vec<ThreatOverride>>,
1534}
1535
1536impl common::Part for ThreatPreventionProfile {}
1537
1538/// The TlsInspectionPolicy resource contains references to CA pools in Certificate Authority Service and associated metadata.
1539///
1540/// # Activities
1541///
1542/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1543/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1544///
1545/// * [locations tls inspection policies create projects](ProjectLocationTlsInspectionPolicyCreateCall) (request)
1546/// * [locations tls inspection policies get projects](ProjectLocationTlsInspectionPolicyGetCall) (response)
1547/// * [locations tls inspection policies patch projects](ProjectLocationTlsInspectionPolicyPatchCall) (request)
1548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1549#[serde_with::serde_as]
1550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1551pub struct TlsInspectionPolicy {
1552    /// Required. A CA pool resource used to issue interception certificates. The CA pool string has a relative resource path following the form "projects/{project}/locations/{location}/caPools/{ca_pool}".
1553    #[serde(rename = "caPool")]
1554    pub ca_pool: Option<String>,
1555    /// Output only. The timestamp when the resource was created.
1556    #[serde(rename = "createTime")]
1557    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1558    /// Optional. List of custom TLS cipher suites selected. This field is valid only if the selected tls_feature_profile is CUSTOM. The compute.SslPoliciesService.ListAvailableFeatures method returns the set of features that can be specified in this list. Note that Secure Web Proxy does not yet honor this field.
1559    #[serde(rename = "customTlsFeatures")]
1560    pub custom_tls_features: Option<Vec<String>>,
1561    /// Optional. Free-text description of the resource.
1562    pub description: Option<String>,
1563    /// Optional. If FALSE (the default), use our default set of public CAs in addition to any CAs specified in trust_config. These public CAs are currently based on the Mozilla Root Program and are subject to change over time. If TRUE, do not accept our default set of public CAs. Only CAs specified in trust_config will be accepted. This defaults to FALSE (use public CAs in addition to trust_config) for backwards compatibility, but trusting public root CAs is *not recommended* unless the traffic in question is outbound to public web servers. When possible, prefer setting this to "false" and explicitly specifying trusted CAs and certificates in a TrustConfig. Note that Secure Web Proxy does not yet honor this field.
1564    #[serde(rename = "excludePublicCaSet")]
1565    pub exclude_public_ca_set: Option<bool>,
1566    /// Optional. Minimum TLS version that the firewall should use when negotiating connections with both clients and servers. If this is not set, then the default value is to allow the broadest set of clients and servers (TLS 1.0 or higher). Setting this to more restrictive values may improve security, but may also prevent the firewall from connecting to some clients or servers. Note that Secure Web Proxy does not yet honor this field.
1567    #[serde(rename = "minTlsVersion")]
1568    pub min_tls_version: Option<String>,
1569    /// Required. Name of the resource. Name is of the form projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy} tls_inspection_policy should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
1570    pub name: Option<String>,
1571    /// Optional. The selected Profile. If this is not set, then the default value is to allow the broadest set of clients and servers ("PROFILE_COMPATIBLE"). Setting this to more restrictive values may improve security, but may also prevent the TLS inspection proxy from connecting to some clients or servers. Note that Secure Web Proxy does not yet honor this field.
1572    #[serde(rename = "tlsFeatureProfile")]
1573    pub tls_feature_profile: Option<String>,
1574    /// Optional. A TrustConfig resource used when making a connection to the TLS server. This is a relative resource path following the form "projects/{project}/locations/{location}/trustConfigs/{trust_config}". This is necessary to intercept TLS connections to servers with certificates signed by a private CA or self-signed certificates. Note that Secure Web Proxy does not yet honor this field.
1575    #[serde(rename = "trustConfig")]
1576    pub trust_config: Option<String>,
1577    /// Output only. The timestamp when the resource was updated.
1578    #[serde(rename = "updateTime")]
1579    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1580}
1581
1582impl common::RequestValue for TlsInspectionPolicy {}
1583impl common::ResponseResult for TlsInspectionPolicy {}
1584
1585/// UrlList proto helps users to set reusable, independently manageable lists of hosts, host patterns, URLs, URL patterns.
1586///
1587/// # Activities
1588///
1589/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1590/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1591///
1592/// * [locations url lists create projects](ProjectLocationUrlListCreateCall) (request)
1593/// * [locations url lists get projects](ProjectLocationUrlListGetCall) (response)
1594/// * [locations url lists patch projects](ProjectLocationUrlListPatchCall) (request)
1595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1596#[serde_with::serde_as]
1597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1598pub struct UrlList {
1599    /// Output only. Time when the security policy was created.
1600    #[serde(rename = "createTime")]
1601    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1602    /// Optional. Free-text description of the resource.
1603    pub description: Option<String>,
1604    /// Required. Name of the resource provided by the user. Name is of the form projects/{project}/locations/{location}/urlLists/{url_list} url_list should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
1605    pub name: Option<String>,
1606    /// Output only. Time when the security policy was updated.
1607    #[serde(rename = "updateTime")]
1608    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1609    /// Required. FQDNs and URLs.
1610    pub values: Option<Vec<String>>,
1611}
1612
1613impl common::RequestValue for UrlList {}
1614impl common::ResponseResult for UrlList {}
1615
1616/// Specification of ValidationCA. Defines the mechanism to obtain the Certificate Authority certificate to validate the peer certificate.
1617///
1618/// This type is not used in any activity, and only used as *part* of another schema.
1619///
1620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1621#[serde_with::serde_as]
1622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1623pub struct ValidationCA {
1624    /// The certificate provider instance specification that will be passed to the data plane, which will be used to load necessary credential information.
1625    #[serde(rename = "certificateProviderInstance")]
1626    pub certificate_provider_instance: Option<CertificateProviderInstance>,
1627    /// gRPC specific configuration to access the gRPC server to obtain the CA certificate.
1628    #[serde(rename = "grpcEndpoint")]
1629    pub grpc_endpoint: Option<GoogleCloudNetworksecurityV1GrpcEndpoint>,
1630}
1631
1632impl common::Part for ValidationCA {}
1633
1634// ###################
1635// MethodBuilders ###
1636// #################
1637
1638/// A builder providing access to all methods supported on *organization* resources.
1639/// It is not used directly, but through the [`NetworkSecurity`] hub.
1640///
1641/// # Example
1642///
1643/// Instantiate a resource builder
1644///
1645/// ```test_harness,no_run
1646/// extern crate hyper;
1647/// extern crate hyper_rustls;
1648/// extern crate google_networksecurity1 as networksecurity1;
1649///
1650/// # async fn dox() {
1651/// use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1652///
1653/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1654/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1655///     secret,
1656///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1657/// ).build().await.unwrap();
1658///
1659/// let client = hyper_util::client::legacy::Client::builder(
1660///     hyper_util::rt::TokioExecutor::new()
1661/// )
1662/// .build(
1663///     hyper_rustls::HttpsConnectorBuilder::new()
1664///         .with_native_roots()
1665///         .unwrap()
1666///         .https_or_http()
1667///         .enable_http1()
1668///         .build()
1669/// );
1670/// let mut hub = NetworkSecurity::new(client, auth);
1671/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1672/// // like `locations_address_groups_add_items(...)`, `locations_address_groups_clone_items(...)`, `locations_address_groups_create(...)`, `locations_address_groups_delete(...)`, `locations_address_groups_get(...)`, `locations_address_groups_list(...)`, `locations_address_groups_list_references(...)`, `locations_address_groups_patch(...)`, `locations_address_groups_remove_items(...)`, `locations_firewall_endpoints_create(...)`, `locations_firewall_endpoints_delete(...)`, `locations_firewall_endpoints_get(...)`, `locations_firewall_endpoints_list(...)`, `locations_firewall_endpoints_patch(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_security_profile_groups_create(...)`, `locations_security_profile_groups_delete(...)`, `locations_security_profile_groups_get(...)`, `locations_security_profile_groups_list(...)`, `locations_security_profile_groups_patch(...)`, `locations_security_profiles_create(...)`, `locations_security_profiles_delete(...)`, `locations_security_profiles_get(...)`, `locations_security_profiles_list(...)` and `locations_security_profiles_patch(...)`
1673/// // to build up your call.
1674/// let rb = hub.organizations();
1675/// # }
1676/// ```
1677pub struct OrganizationMethods<'a, C>
1678where
1679    C: 'a,
1680{
1681    hub: &'a NetworkSecurity<C>,
1682}
1683
1684impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1685
1686impl<'a, C> OrganizationMethods<'a, C> {
1687    /// Create a builder to help you perform the following task:
1688    ///
1689    /// Adds items to an address group.
1690    ///
1691    /// # Arguments
1692    ///
1693    /// * `request` - No description provided.
1694    /// * `addressGroup` - Required. A name of the AddressGroup to add items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
1695    pub fn locations_address_groups_add_items(
1696        &self,
1697        request: AddAddressGroupItemsRequest,
1698        address_group: &str,
1699    ) -> OrganizationLocationAddressGroupAddItemCall<'a, C> {
1700        OrganizationLocationAddressGroupAddItemCall {
1701            hub: self.hub,
1702            _request: request,
1703            _address_group: address_group.to_string(),
1704            _delegate: Default::default(),
1705            _additional_params: Default::default(),
1706            _scopes: Default::default(),
1707        }
1708    }
1709
1710    /// Create a builder to help you perform the following task:
1711    ///
1712    /// Clones items from one address group to another.
1713    ///
1714    /// # Arguments
1715    ///
1716    /// * `request` - No description provided.
1717    /// * `addressGroup` - Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
1718    pub fn locations_address_groups_clone_items(
1719        &self,
1720        request: CloneAddressGroupItemsRequest,
1721        address_group: &str,
1722    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C> {
1723        OrganizationLocationAddressGroupCloneItemCall {
1724            hub: self.hub,
1725            _request: request,
1726            _address_group: address_group.to_string(),
1727            _delegate: Default::default(),
1728            _additional_params: Default::default(),
1729            _scopes: Default::default(),
1730        }
1731    }
1732
1733    /// Create a builder to help you perform the following task:
1734    ///
1735    /// Creates a new address group in a given project and location.
1736    ///
1737    /// # Arguments
1738    ///
1739    /// * `request` - No description provided.
1740    /// * `parent` - Required. The parent resource of the AddressGroup. Must be in the format `projects/*/locations/{location}`.
1741    pub fn locations_address_groups_create(
1742        &self,
1743        request: AddressGroup,
1744        parent: &str,
1745    ) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
1746        OrganizationLocationAddressGroupCreateCall {
1747            hub: self.hub,
1748            _request: request,
1749            _parent: parent.to_string(),
1750            _request_id: Default::default(),
1751            _address_group_id: Default::default(),
1752            _delegate: Default::default(),
1753            _additional_params: Default::default(),
1754            _scopes: Default::default(),
1755        }
1756    }
1757
1758    /// Create a builder to help you perform the following task:
1759    ///
1760    /// Deletes an address group.
1761    ///
1762    /// # Arguments
1763    ///
1764    /// * `name` - Required. A name of the AddressGroup to delete. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
1765    pub fn locations_address_groups_delete(
1766        &self,
1767        name: &str,
1768    ) -> OrganizationLocationAddressGroupDeleteCall<'a, C> {
1769        OrganizationLocationAddressGroupDeleteCall {
1770            hub: self.hub,
1771            _name: name.to_string(),
1772            _request_id: Default::default(),
1773            _delegate: Default::default(),
1774            _additional_params: Default::default(),
1775            _scopes: Default::default(),
1776        }
1777    }
1778
1779    /// Create a builder to help you perform the following task:
1780    ///
1781    /// Gets details of a single address group.
1782    ///
1783    /// # Arguments
1784    ///
1785    /// * `name` - Required. A name of the AddressGroup to get. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
1786    pub fn locations_address_groups_get(
1787        &self,
1788        name: &str,
1789    ) -> OrganizationLocationAddressGroupGetCall<'a, C> {
1790        OrganizationLocationAddressGroupGetCall {
1791            hub: self.hub,
1792            _name: name.to_string(),
1793            _delegate: Default::default(),
1794            _additional_params: Default::default(),
1795            _scopes: Default::default(),
1796        }
1797    }
1798
1799    /// Create a builder to help you perform the following task:
1800    ///
1801    /// Lists address groups in a given project and location.
1802    ///
1803    /// # Arguments
1804    ///
1805    /// * `parent` - Required. The project and location from which the AddressGroups should be listed, specified in the format `projects/*/locations/{location}`.
1806    pub fn locations_address_groups_list(
1807        &self,
1808        parent: &str,
1809    ) -> OrganizationLocationAddressGroupListCall<'a, C> {
1810        OrganizationLocationAddressGroupListCall {
1811            hub: self.hub,
1812            _parent: parent.to_string(),
1813            _page_token: Default::default(),
1814            _page_size: Default::default(),
1815            _delegate: Default::default(),
1816            _additional_params: Default::default(),
1817            _scopes: Default::default(),
1818        }
1819    }
1820
1821    /// Create a builder to help you perform the following task:
1822    ///
1823    /// Lists references of an address group.
1824    ///
1825    /// # Arguments
1826    ///
1827    /// * `addressGroup` - Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
1828    pub fn locations_address_groups_list_references(
1829        &self,
1830        address_group: &str,
1831    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C> {
1832        OrganizationLocationAddressGroupListReferenceCall {
1833            hub: self.hub,
1834            _address_group: address_group.to_string(),
1835            _page_token: Default::default(),
1836            _page_size: Default::default(),
1837            _delegate: Default::default(),
1838            _additional_params: Default::default(),
1839            _scopes: Default::default(),
1840        }
1841    }
1842
1843    /// Create a builder to help you perform the following task:
1844    ///
1845    /// Updates parameters of an address group.
1846    ///
1847    /// # Arguments
1848    ///
1849    /// * `request` - No description provided.
1850    /// * `name` - Required. Name of the AddressGroup resource. It matches pattern `projects/*/locations/{location}/addressGroups/`.
1851    pub fn locations_address_groups_patch(
1852        &self,
1853        request: AddressGroup,
1854        name: &str,
1855    ) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
1856        OrganizationLocationAddressGroupPatchCall {
1857            hub: self.hub,
1858            _request: request,
1859            _name: name.to_string(),
1860            _update_mask: Default::default(),
1861            _request_id: Default::default(),
1862            _delegate: Default::default(),
1863            _additional_params: Default::default(),
1864            _scopes: Default::default(),
1865        }
1866    }
1867
1868    /// Create a builder to help you perform the following task:
1869    ///
1870    /// Removes items from an address group.
1871    ///
1872    /// # Arguments
1873    ///
1874    /// * `request` - No description provided.
1875    /// * `addressGroup` - Required. A name of the AddressGroup to remove items from. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
1876    pub fn locations_address_groups_remove_items(
1877        &self,
1878        request: RemoveAddressGroupItemsRequest,
1879        address_group: &str,
1880    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C> {
1881        OrganizationLocationAddressGroupRemoveItemCall {
1882            hub: self.hub,
1883            _request: request,
1884            _address_group: address_group.to_string(),
1885            _delegate: Default::default(),
1886            _additional_params: Default::default(),
1887            _scopes: Default::default(),
1888        }
1889    }
1890
1891    /// Create a builder to help you perform the following task:
1892    ///
1893    /// Creates a new FirewallEndpoint in a given project and location.
1894    ///
1895    /// # Arguments
1896    ///
1897    /// * `request` - No description provided.
1898    /// * `parent` - Required. Value for parent.
1899    pub fn locations_firewall_endpoints_create(
1900        &self,
1901        request: FirewallEndpoint,
1902        parent: &str,
1903    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
1904        OrganizationLocationFirewallEndpointCreateCall {
1905            hub: self.hub,
1906            _request: request,
1907            _parent: parent.to_string(),
1908            _request_id: Default::default(),
1909            _firewall_endpoint_id: Default::default(),
1910            _delegate: Default::default(),
1911            _additional_params: Default::default(),
1912            _scopes: Default::default(),
1913        }
1914    }
1915
1916    /// Create a builder to help you perform the following task:
1917    ///
1918    /// Deletes a single Endpoint.
1919    ///
1920    /// # Arguments
1921    ///
1922    /// * `name` - Required. Name of the resource
1923    pub fn locations_firewall_endpoints_delete(
1924        &self,
1925        name: &str,
1926    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C> {
1927        OrganizationLocationFirewallEndpointDeleteCall {
1928            hub: self.hub,
1929            _name: name.to_string(),
1930            _request_id: Default::default(),
1931            _delegate: Default::default(),
1932            _additional_params: Default::default(),
1933            _scopes: Default::default(),
1934        }
1935    }
1936
1937    /// Create a builder to help you perform the following task:
1938    ///
1939    /// Gets details of a single Endpoint.
1940    ///
1941    /// # Arguments
1942    ///
1943    /// * `name` - Required. Name of the resource
1944    pub fn locations_firewall_endpoints_get(
1945        &self,
1946        name: &str,
1947    ) -> OrganizationLocationFirewallEndpointGetCall<'a, C> {
1948        OrganizationLocationFirewallEndpointGetCall {
1949            hub: self.hub,
1950            _name: name.to_string(),
1951            _delegate: Default::default(),
1952            _additional_params: Default::default(),
1953            _scopes: Default::default(),
1954        }
1955    }
1956
1957    /// Create a builder to help you perform the following task:
1958    ///
1959    /// Lists FirewallEndpoints in a given project and location.
1960    ///
1961    /// # Arguments
1962    ///
1963    /// * `parent` - Required. Parent value for ListEndpointsRequest
1964    pub fn locations_firewall_endpoints_list(
1965        &self,
1966        parent: &str,
1967    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
1968        OrganizationLocationFirewallEndpointListCall {
1969            hub: self.hub,
1970            _parent: parent.to_string(),
1971            _page_token: Default::default(),
1972            _page_size: Default::default(),
1973            _order_by: Default::default(),
1974            _filter: Default::default(),
1975            _delegate: Default::default(),
1976            _additional_params: Default::default(),
1977            _scopes: Default::default(),
1978        }
1979    }
1980
1981    /// Create a builder to help you perform the following task:
1982    ///
1983    /// Update a single Endpoint.
1984    ///
1985    /// # Arguments
1986    ///
1987    /// * `request` - No description provided.
1988    /// * `name` - Immutable. Identifier. name of resource
1989    pub fn locations_firewall_endpoints_patch(
1990        &self,
1991        request: FirewallEndpoint,
1992        name: &str,
1993    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
1994        OrganizationLocationFirewallEndpointPatchCall {
1995            hub: self.hub,
1996            _request: request,
1997            _name: name.to_string(),
1998            _update_mask: Default::default(),
1999            _request_id: Default::default(),
2000            _delegate: Default::default(),
2001            _additional_params: Default::default(),
2002            _scopes: Default::default(),
2003        }
2004    }
2005
2006    /// Create a builder to help you perform the following task:
2007    ///
2008    /// 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`.
2009    ///
2010    /// # Arguments
2011    ///
2012    /// * `request` - No description provided.
2013    /// * `name` - The name of the operation resource to be cancelled.
2014    pub fn locations_operations_cancel(
2015        &self,
2016        request: CancelOperationRequest,
2017        name: &str,
2018    ) -> OrganizationLocationOperationCancelCall<'a, C> {
2019        OrganizationLocationOperationCancelCall {
2020            hub: self.hub,
2021            _request: request,
2022            _name: name.to_string(),
2023            _delegate: Default::default(),
2024            _additional_params: Default::default(),
2025            _scopes: Default::default(),
2026        }
2027    }
2028
2029    /// Create a builder to help you perform the following task:
2030    ///
2031    /// 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`.
2032    ///
2033    /// # Arguments
2034    ///
2035    /// * `name` - The name of the operation resource to be deleted.
2036    pub fn locations_operations_delete(
2037        &self,
2038        name: &str,
2039    ) -> OrganizationLocationOperationDeleteCall<'a, C> {
2040        OrganizationLocationOperationDeleteCall {
2041            hub: self.hub,
2042            _name: name.to_string(),
2043            _delegate: Default::default(),
2044            _additional_params: Default::default(),
2045            _scopes: Default::default(),
2046        }
2047    }
2048
2049    /// Create a builder to help you perform the following task:
2050    ///
2051    /// 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.
2052    ///
2053    /// # Arguments
2054    ///
2055    /// * `name` - The name of the operation resource.
2056    pub fn locations_operations_get(
2057        &self,
2058        name: &str,
2059    ) -> OrganizationLocationOperationGetCall<'a, C> {
2060        OrganizationLocationOperationGetCall {
2061            hub: self.hub,
2062            _name: name.to_string(),
2063            _delegate: Default::default(),
2064            _additional_params: Default::default(),
2065            _scopes: Default::default(),
2066        }
2067    }
2068
2069    /// Create a builder to help you perform the following task:
2070    ///
2071    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2072    ///
2073    /// # Arguments
2074    ///
2075    /// * `name` - The name of the operation's parent resource.
2076    pub fn locations_operations_list(
2077        &self,
2078        name: &str,
2079    ) -> OrganizationLocationOperationListCall<'a, C> {
2080        OrganizationLocationOperationListCall {
2081            hub: self.hub,
2082            _name: name.to_string(),
2083            _page_token: Default::default(),
2084            _page_size: Default::default(),
2085            _filter: Default::default(),
2086            _delegate: Default::default(),
2087            _additional_params: Default::default(),
2088            _scopes: Default::default(),
2089        }
2090    }
2091
2092    /// Create a builder to help you perform the following task:
2093    ///
2094    /// Creates a new SecurityProfileGroup in a given organization and location.
2095    ///
2096    /// # Arguments
2097    ///
2098    /// * `request` - No description provided.
2099    /// * `parent` - Required. The parent resource of the SecurityProfileGroup. Must be in the format `projects|organizations/*/locations/{location}`.
2100    pub fn locations_security_profile_groups_create(
2101        &self,
2102        request: SecurityProfileGroup,
2103        parent: &str,
2104    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {
2105        OrganizationLocationSecurityProfileGroupCreateCall {
2106            hub: self.hub,
2107            _request: request,
2108            _parent: parent.to_string(),
2109            _security_profile_group_id: Default::default(),
2110            _delegate: Default::default(),
2111            _additional_params: Default::default(),
2112            _scopes: Default::default(),
2113        }
2114    }
2115
2116    /// Create a builder to help you perform the following task:
2117    ///
2118    /// Deletes a single SecurityProfileGroup.
2119    ///
2120    /// # Arguments
2121    ///
2122    /// * `name` - Required. A name of the SecurityProfileGroup to delete. Must be in the format `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
2123    pub fn locations_security_profile_groups_delete(
2124        &self,
2125        name: &str,
2126    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C> {
2127        OrganizationLocationSecurityProfileGroupDeleteCall {
2128            hub: self.hub,
2129            _name: name.to_string(),
2130            _etag: Default::default(),
2131            _delegate: Default::default(),
2132            _additional_params: Default::default(),
2133            _scopes: Default::default(),
2134        }
2135    }
2136
2137    /// Create a builder to help you perform the following task:
2138    ///
2139    /// Gets details of a single SecurityProfileGroup.
2140    ///
2141    /// # Arguments
2142    ///
2143    /// * `name` - Required. A name of the SecurityProfileGroup to get. Must be in the format `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
2144    pub fn locations_security_profile_groups_get(
2145        &self,
2146        name: &str,
2147    ) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C> {
2148        OrganizationLocationSecurityProfileGroupGetCall {
2149            hub: self.hub,
2150            _name: name.to_string(),
2151            _delegate: Default::default(),
2152            _additional_params: Default::default(),
2153            _scopes: Default::default(),
2154        }
2155    }
2156
2157    /// Create a builder to help you perform the following task:
2158    ///
2159    /// Lists SecurityProfileGroups in a given organization and location.
2160    ///
2161    /// # Arguments
2162    ///
2163    /// * `parent` - Required. The project or organization and location from which the SecurityProfileGroups should be listed, specified in the format `projects|organizations/*/locations/{location}`.
2164    pub fn locations_security_profile_groups_list(
2165        &self,
2166        parent: &str,
2167    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C> {
2168        OrganizationLocationSecurityProfileGroupListCall {
2169            hub: self.hub,
2170            _parent: parent.to_string(),
2171            _page_token: Default::default(),
2172            _page_size: Default::default(),
2173            _delegate: Default::default(),
2174            _additional_params: Default::default(),
2175            _scopes: Default::default(),
2176        }
2177    }
2178
2179    /// Create a builder to help you perform the following task:
2180    ///
2181    /// Updates the parameters of a single SecurityProfileGroup.
2182    ///
2183    /// # Arguments
2184    ///
2185    /// * `request` - No description provided.
2186    /// * `name` - Immutable. Identifier. Name of the SecurityProfileGroup resource. It matches pattern `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
2187    pub fn locations_security_profile_groups_patch(
2188        &self,
2189        request: SecurityProfileGroup,
2190        name: &str,
2191    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {
2192        OrganizationLocationSecurityProfileGroupPatchCall {
2193            hub: self.hub,
2194            _request: request,
2195            _name: name.to_string(),
2196            _update_mask: Default::default(),
2197            _delegate: Default::default(),
2198            _additional_params: Default::default(),
2199            _scopes: Default::default(),
2200        }
2201    }
2202
2203    /// Create a builder to help you perform the following task:
2204    ///
2205    /// Creates a new SecurityProfile in a given organization and location.
2206    ///
2207    /// # Arguments
2208    ///
2209    /// * `request` - No description provided.
2210    /// * `parent` - Required. The parent resource of the SecurityProfile. Must be in the format `projects|organizations/*/locations/{location}`.
2211    pub fn locations_security_profiles_create(
2212        &self,
2213        request: SecurityProfile,
2214        parent: &str,
2215    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C> {
2216        OrganizationLocationSecurityProfileCreateCall {
2217            hub: self.hub,
2218            _request: request,
2219            _parent: parent.to_string(),
2220            _security_profile_id: Default::default(),
2221            _delegate: Default::default(),
2222            _additional_params: Default::default(),
2223            _scopes: Default::default(),
2224        }
2225    }
2226
2227    /// Create a builder to help you perform the following task:
2228    ///
2229    /// Deletes a single SecurityProfile.
2230    ///
2231    /// # Arguments
2232    ///
2233    /// * `name` - Required. A name of the SecurityProfile to delete. Must be in the format `projects|organizations/*/locations/{location}/securityProfiles/{security_profile_id}`.
2234    pub fn locations_security_profiles_delete(
2235        &self,
2236        name: &str,
2237    ) -> OrganizationLocationSecurityProfileDeleteCall<'a, C> {
2238        OrganizationLocationSecurityProfileDeleteCall {
2239            hub: self.hub,
2240            _name: name.to_string(),
2241            _etag: Default::default(),
2242            _delegate: Default::default(),
2243            _additional_params: Default::default(),
2244            _scopes: Default::default(),
2245        }
2246    }
2247
2248    /// Create a builder to help you perform the following task:
2249    ///
2250    /// Gets details of a single SecurityProfile.
2251    ///
2252    /// # Arguments
2253    ///
2254    /// * `name` - Required. A name of the SecurityProfile to get. Must be in the format `projects|organizations/*/locations/{location}/securityProfiles/{security_profile_id}`.
2255    pub fn locations_security_profiles_get(
2256        &self,
2257        name: &str,
2258    ) -> OrganizationLocationSecurityProfileGetCall<'a, C> {
2259        OrganizationLocationSecurityProfileGetCall {
2260            hub: self.hub,
2261            _name: name.to_string(),
2262            _delegate: Default::default(),
2263            _additional_params: Default::default(),
2264            _scopes: Default::default(),
2265        }
2266    }
2267
2268    /// Create a builder to help you perform the following task:
2269    ///
2270    /// Lists SecurityProfiles in a given organization and location.
2271    ///
2272    /// # Arguments
2273    ///
2274    /// * `parent` - Required. The project or organization and location from which the SecurityProfiles should be listed, specified in the format `projects|organizations/*/locations/{location}`.
2275    pub fn locations_security_profiles_list(
2276        &self,
2277        parent: &str,
2278    ) -> OrganizationLocationSecurityProfileListCall<'a, C> {
2279        OrganizationLocationSecurityProfileListCall {
2280            hub: self.hub,
2281            _parent: parent.to_string(),
2282            _page_token: Default::default(),
2283            _page_size: Default::default(),
2284            _delegate: Default::default(),
2285            _additional_params: Default::default(),
2286            _scopes: Default::default(),
2287        }
2288    }
2289
2290    /// Create a builder to help you perform the following task:
2291    ///
2292    /// Updates the parameters of a single SecurityProfile.
2293    ///
2294    /// # Arguments
2295    ///
2296    /// * `request` - No description provided.
2297    /// * `name` - Immutable. Identifier. Name of the SecurityProfile resource. It matches pattern `projects|organizations/*/locations/{location}/securityProfiles/{security_profile}`.
2298    pub fn locations_security_profiles_patch(
2299        &self,
2300        request: SecurityProfile,
2301        name: &str,
2302    ) -> OrganizationLocationSecurityProfilePatchCall<'a, C> {
2303        OrganizationLocationSecurityProfilePatchCall {
2304            hub: self.hub,
2305            _request: request,
2306            _name: name.to_string(),
2307            _update_mask: Default::default(),
2308            _delegate: Default::default(),
2309            _additional_params: Default::default(),
2310            _scopes: Default::default(),
2311        }
2312    }
2313}
2314
2315/// A builder providing access to all methods supported on *project* resources.
2316/// It is not used directly, but through the [`NetworkSecurity`] hub.
2317///
2318/// # Example
2319///
2320/// Instantiate a resource builder
2321///
2322/// ```test_harness,no_run
2323/// extern crate hyper;
2324/// extern crate hyper_rustls;
2325/// extern crate google_networksecurity1 as networksecurity1;
2326///
2327/// # async fn dox() {
2328/// use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2329///
2330/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2331/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2332///     secret,
2333///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2334/// ).build().await.unwrap();
2335///
2336/// let client = hyper_util::client::legacy::Client::builder(
2337///     hyper_util::rt::TokioExecutor::new()
2338/// )
2339/// .build(
2340///     hyper_rustls::HttpsConnectorBuilder::new()
2341///         .with_native_roots()
2342///         .unwrap()
2343///         .https_or_http()
2344///         .enable_http1()
2345///         .build()
2346/// );
2347/// let mut hub = NetworkSecurity::new(client, auth);
2348/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2349/// // like `locations_address_groups_add_items(...)`, `locations_address_groups_clone_items(...)`, `locations_address_groups_create(...)`, `locations_address_groups_delete(...)`, `locations_address_groups_get(...)`, `locations_address_groups_get_iam_policy(...)`, `locations_address_groups_list(...)`, `locations_address_groups_list_references(...)`, `locations_address_groups_patch(...)`, `locations_address_groups_remove_items(...)`, `locations_address_groups_set_iam_policy(...)`, `locations_address_groups_test_iam_permissions(...)`, `locations_authorization_policies_create(...)`, `locations_authorization_policies_delete(...)`, `locations_authorization_policies_get(...)`, `locations_authorization_policies_get_iam_policy(...)`, `locations_authorization_policies_list(...)`, `locations_authorization_policies_patch(...)`, `locations_authorization_policies_set_iam_policy(...)`, `locations_authorization_policies_test_iam_permissions(...)`, `locations_client_tls_policies_create(...)`, `locations_client_tls_policies_delete(...)`, `locations_client_tls_policies_get(...)`, `locations_client_tls_policies_get_iam_policy(...)`, `locations_client_tls_policies_list(...)`, `locations_client_tls_policies_patch(...)`, `locations_client_tls_policies_set_iam_policy(...)`, `locations_client_tls_policies_test_iam_permissions(...)`, `locations_firewall_endpoint_associations_create(...)`, `locations_firewall_endpoint_associations_delete(...)`, `locations_firewall_endpoint_associations_get(...)`, `locations_firewall_endpoint_associations_list(...)`, `locations_firewall_endpoint_associations_patch(...)`, `locations_gateway_security_policies_create(...)`, `locations_gateway_security_policies_delete(...)`, `locations_gateway_security_policies_get(...)`, `locations_gateway_security_policies_list(...)`, `locations_gateway_security_policies_patch(...)`, `locations_gateway_security_policies_rules_create(...)`, `locations_gateway_security_policies_rules_delete(...)`, `locations_gateway_security_policies_rules_get(...)`, `locations_gateway_security_policies_rules_list(...)`, `locations_gateway_security_policies_rules_patch(...)`, `locations_get(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_server_tls_policies_create(...)`, `locations_server_tls_policies_delete(...)`, `locations_server_tls_policies_get(...)`, `locations_server_tls_policies_get_iam_policy(...)`, `locations_server_tls_policies_list(...)`, `locations_server_tls_policies_patch(...)`, `locations_server_tls_policies_set_iam_policy(...)`, `locations_server_tls_policies_test_iam_permissions(...)`, `locations_tls_inspection_policies_create(...)`, `locations_tls_inspection_policies_delete(...)`, `locations_tls_inspection_policies_get(...)`, `locations_tls_inspection_policies_list(...)`, `locations_tls_inspection_policies_patch(...)`, `locations_url_lists_create(...)`, `locations_url_lists_delete(...)`, `locations_url_lists_get(...)`, `locations_url_lists_list(...)` and `locations_url_lists_patch(...)`
2350/// // to build up your call.
2351/// let rb = hub.projects();
2352/// # }
2353/// ```
2354pub struct ProjectMethods<'a, C>
2355where
2356    C: 'a,
2357{
2358    hub: &'a NetworkSecurity<C>,
2359}
2360
2361impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2362
2363impl<'a, C> ProjectMethods<'a, C> {
2364    /// Create a builder to help you perform the following task:
2365    ///
2366    /// Adds items to an address group.
2367    ///
2368    /// # Arguments
2369    ///
2370    /// * `request` - No description provided.
2371    /// * `addressGroup` - Required. A name of the AddressGroup to add items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
2372    pub fn locations_address_groups_add_items(
2373        &self,
2374        request: AddAddressGroupItemsRequest,
2375        address_group: &str,
2376    ) -> ProjectLocationAddressGroupAddItemCall<'a, C> {
2377        ProjectLocationAddressGroupAddItemCall {
2378            hub: self.hub,
2379            _request: request,
2380            _address_group: address_group.to_string(),
2381            _delegate: Default::default(),
2382            _additional_params: Default::default(),
2383            _scopes: Default::default(),
2384        }
2385    }
2386
2387    /// Create a builder to help you perform the following task:
2388    ///
2389    /// Clones items from one address group to another.
2390    ///
2391    /// # Arguments
2392    ///
2393    /// * `request` - No description provided.
2394    /// * `addressGroup` - Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
2395    pub fn locations_address_groups_clone_items(
2396        &self,
2397        request: CloneAddressGroupItemsRequest,
2398        address_group: &str,
2399    ) -> ProjectLocationAddressGroupCloneItemCall<'a, C> {
2400        ProjectLocationAddressGroupCloneItemCall {
2401            hub: self.hub,
2402            _request: request,
2403            _address_group: address_group.to_string(),
2404            _delegate: Default::default(),
2405            _additional_params: Default::default(),
2406            _scopes: Default::default(),
2407        }
2408    }
2409
2410    /// Create a builder to help you perform the following task:
2411    ///
2412    /// Creates a new address group in a given project and location.
2413    ///
2414    /// # Arguments
2415    ///
2416    /// * `request` - No description provided.
2417    /// * `parent` - Required. The parent resource of the AddressGroup. Must be in the format `projects/*/locations/{location}`.
2418    pub fn locations_address_groups_create(
2419        &self,
2420        request: AddressGroup,
2421        parent: &str,
2422    ) -> ProjectLocationAddressGroupCreateCall<'a, C> {
2423        ProjectLocationAddressGroupCreateCall {
2424            hub: self.hub,
2425            _request: request,
2426            _parent: parent.to_string(),
2427            _request_id: Default::default(),
2428            _address_group_id: Default::default(),
2429            _delegate: Default::default(),
2430            _additional_params: Default::default(),
2431            _scopes: Default::default(),
2432        }
2433    }
2434
2435    /// Create a builder to help you perform the following task:
2436    ///
2437    /// Deletes a single address group.
2438    ///
2439    /// # Arguments
2440    ///
2441    /// * `name` - Required. A name of the AddressGroup to delete. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
2442    pub fn locations_address_groups_delete(
2443        &self,
2444        name: &str,
2445    ) -> ProjectLocationAddressGroupDeleteCall<'a, C> {
2446        ProjectLocationAddressGroupDeleteCall {
2447            hub: self.hub,
2448            _name: name.to_string(),
2449            _request_id: Default::default(),
2450            _delegate: Default::default(),
2451            _additional_params: Default::default(),
2452            _scopes: Default::default(),
2453        }
2454    }
2455
2456    /// Create a builder to help you perform the following task:
2457    ///
2458    /// Gets details of a single address group.
2459    ///
2460    /// # Arguments
2461    ///
2462    /// * `name` - Required. A name of the AddressGroup to get. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
2463    pub fn locations_address_groups_get(
2464        &self,
2465        name: &str,
2466    ) -> ProjectLocationAddressGroupGetCall<'a, C> {
2467        ProjectLocationAddressGroupGetCall {
2468            hub: self.hub,
2469            _name: name.to_string(),
2470            _delegate: Default::default(),
2471            _additional_params: Default::default(),
2472            _scopes: Default::default(),
2473        }
2474    }
2475
2476    /// Create a builder to help you perform the following task:
2477    ///
2478    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2479    ///
2480    /// # Arguments
2481    ///
2482    /// * `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.
2483    pub fn locations_address_groups_get_iam_policy(
2484        &self,
2485        resource: &str,
2486    ) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C> {
2487        ProjectLocationAddressGroupGetIamPolicyCall {
2488            hub: self.hub,
2489            _resource: resource.to_string(),
2490            _options_requested_policy_version: Default::default(),
2491            _delegate: Default::default(),
2492            _additional_params: Default::default(),
2493            _scopes: Default::default(),
2494        }
2495    }
2496
2497    /// Create a builder to help you perform the following task:
2498    ///
2499    /// Lists address groups in a given project and location.
2500    ///
2501    /// # Arguments
2502    ///
2503    /// * `parent` - Required. The project and location from which the AddressGroups should be listed, specified in the format `projects/*/locations/{location}`.
2504    pub fn locations_address_groups_list(
2505        &self,
2506        parent: &str,
2507    ) -> ProjectLocationAddressGroupListCall<'a, C> {
2508        ProjectLocationAddressGroupListCall {
2509            hub: self.hub,
2510            _parent: parent.to_string(),
2511            _page_token: Default::default(),
2512            _page_size: Default::default(),
2513            _delegate: Default::default(),
2514            _additional_params: Default::default(),
2515            _scopes: Default::default(),
2516        }
2517    }
2518
2519    /// Create a builder to help you perform the following task:
2520    ///
2521    /// Lists references of an address group.
2522    ///
2523    /// # Arguments
2524    ///
2525    /// * `addressGroup` - Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
2526    pub fn locations_address_groups_list_references(
2527        &self,
2528        address_group: &str,
2529    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C> {
2530        ProjectLocationAddressGroupListReferenceCall {
2531            hub: self.hub,
2532            _address_group: address_group.to_string(),
2533            _page_token: Default::default(),
2534            _page_size: Default::default(),
2535            _delegate: Default::default(),
2536            _additional_params: Default::default(),
2537            _scopes: Default::default(),
2538        }
2539    }
2540
2541    /// Create a builder to help you perform the following task:
2542    ///
2543    /// Updates the parameters of a single address group.
2544    ///
2545    /// # Arguments
2546    ///
2547    /// * `request` - No description provided.
2548    /// * `name` - Required. Name of the AddressGroup resource. It matches pattern `projects/*/locations/{location}/addressGroups/`.
2549    pub fn locations_address_groups_patch(
2550        &self,
2551        request: AddressGroup,
2552        name: &str,
2553    ) -> ProjectLocationAddressGroupPatchCall<'a, C> {
2554        ProjectLocationAddressGroupPatchCall {
2555            hub: self.hub,
2556            _request: request,
2557            _name: name.to_string(),
2558            _update_mask: Default::default(),
2559            _request_id: Default::default(),
2560            _delegate: Default::default(),
2561            _additional_params: Default::default(),
2562            _scopes: Default::default(),
2563        }
2564    }
2565
2566    /// Create a builder to help you perform the following task:
2567    ///
2568    /// Removes items from an address group.
2569    ///
2570    /// # Arguments
2571    ///
2572    /// * `request` - No description provided.
2573    /// * `addressGroup` - Required. A name of the AddressGroup to remove items from. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
2574    pub fn locations_address_groups_remove_items(
2575        &self,
2576        request: RemoveAddressGroupItemsRequest,
2577        address_group: &str,
2578    ) -> ProjectLocationAddressGroupRemoveItemCall<'a, C> {
2579        ProjectLocationAddressGroupRemoveItemCall {
2580            hub: self.hub,
2581            _request: request,
2582            _address_group: address_group.to_string(),
2583            _delegate: Default::default(),
2584            _additional_params: Default::default(),
2585            _scopes: Default::default(),
2586        }
2587    }
2588
2589    /// Create a builder to help you perform the following task:
2590    ///
2591    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2592    ///
2593    /// # Arguments
2594    ///
2595    /// * `request` - No description provided.
2596    /// * `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.
2597    pub fn locations_address_groups_set_iam_policy(
2598        &self,
2599        request: GoogleIamV1SetIamPolicyRequest,
2600        resource: &str,
2601    ) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C> {
2602        ProjectLocationAddressGroupSetIamPolicyCall {
2603            hub: self.hub,
2604            _request: request,
2605            _resource: resource.to_string(),
2606            _delegate: Default::default(),
2607            _additional_params: Default::default(),
2608            _scopes: Default::default(),
2609        }
2610    }
2611
2612    /// Create a builder to help you perform the following task:
2613    ///
2614    /// 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.
2615    ///
2616    /// # Arguments
2617    ///
2618    /// * `request` - No description provided.
2619    /// * `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.
2620    pub fn locations_address_groups_test_iam_permissions(
2621        &self,
2622        request: GoogleIamV1TestIamPermissionsRequest,
2623        resource: &str,
2624    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C> {
2625        ProjectLocationAddressGroupTestIamPermissionCall {
2626            hub: self.hub,
2627            _request: request,
2628            _resource: resource.to_string(),
2629            _delegate: Default::default(),
2630            _additional_params: Default::default(),
2631            _scopes: Default::default(),
2632        }
2633    }
2634
2635    /// Create a builder to help you perform the following task:
2636    ///
2637    /// Creates a new AuthorizationPolicy in a given project and location.
2638    ///
2639    /// # Arguments
2640    ///
2641    /// * `request` - No description provided.
2642    /// * `parent` - Required. The parent resource of the AuthorizationPolicy. Must be in the format `projects/{project}/locations/{location}`.
2643    pub fn locations_authorization_policies_create(
2644        &self,
2645        request: AuthorizationPolicy,
2646        parent: &str,
2647    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C> {
2648        ProjectLocationAuthorizationPolicyCreateCall {
2649            hub: self.hub,
2650            _request: request,
2651            _parent: parent.to_string(),
2652            _authorization_policy_id: Default::default(),
2653            _delegate: Default::default(),
2654            _additional_params: Default::default(),
2655            _scopes: Default::default(),
2656        }
2657    }
2658
2659    /// Create a builder to help you perform the following task:
2660    ///
2661    /// Deletes a single AuthorizationPolicy.
2662    ///
2663    /// # Arguments
2664    ///
2665    /// * `name` - Required. A name of the AuthorizationPolicy to delete. Must be in the format `projects/{project}/locations/{location}/authorizationPolicies/*`.
2666    pub fn locations_authorization_policies_delete(
2667        &self,
2668        name: &str,
2669    ) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C> {
2670        ProjectLocationAuthorizationPolicyDeleteCall {
2671            hub: self.hub,
2672            _name: name.to_string(),
2673            _delegate: Default::default(),
2674            _additional_params: Default::default(),
2675            _scopes: Default::default(),
2676        }
2677    }
2678
2679    /// Create a builder to help you perform the following task:
2680    ///
2681    /// Gets details of a single AuthorizationPolicy.
2682    ///
2683    /// # Arguments
2684    ///
2685    /// * `name` - Required. A name of the AuthorizationPolicy to get. Must be in the format `projects/{project}/locations/{location}/authorizationPolicies/*`.
2686    pub fn locations_authorization_policies_get(
2687        &self,
2688        name: &str,
2689    ) -> ProjectLocationAuthorizationPolicyGetCall<'a, C> {
2690        ProjectLocationAuthorizationPolicyGetCall {
2691            hub: self.hub,
2692            _name: name.to_string(),
2693            _delegate: Default::default(),
2694            _additional_params: Default::default(),
2695            _scopes: Default::default(),
2696        }
2697    }
2698
2699    /// Create a builder to help you perform the following task:
2700    ///
2701    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2702    ///
2703    /// # Arguments
2704    ///
2705    /// * `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.
2706    pub fn locations_authorization_policies_get_iam_policy(
2707        &self,
2708        resource: &str,
2709    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C> {
2710        ProjectLocationAuthorizationPolicyGetIamPolicyCall {
2711            hub: self.hub,
2712            _resource: resource.to_string(),
2713            _options_requested_policy_version: Default::default(),
2714            _delegate: Default::default(),
2715            _additional_params: Default::default(),
2716            _scopes: Default::default(),
2717        }
2718    }
2719
2720    /// Create a builder to help you perform the following task:
2721    ///
2722    /// Lists AuthorizationPolicies in a given project and location.
2723    ///
2724    /// # Arguments
2725    ///
2726    /// * `parent` - Required. The project and location from which the AuthorizationPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
2727    pub fn locations_authorization_policies_list(
2728        &self,
2729        parent: &str,
2730    ) -> ProjectLocationAuthorizationPolicyListCall<'a, C> {
2731        ProjectLocationAuthorizationPolicyListCall {
2732            hub: self.hub,
2733            _parent: parent.to_string(),
2734            _page_token: Default::default(),
2735            _page_size: Default::default(),
2736            _delegate: Default::default(),
2737            _additional_params: Default::default(),
2738            _scopes: Default::default(),
2739        }
2740    }
2741
2742    /// Create a builder to help you perform the following task:
2743    ///
2744    /// Updates the parameters of a single AuthorizationPolicy.
2745    ///
2746    /// # Arguments
2747    ///
2748    /// * `request` - No description provided.
2749    /// * `name` - Required. Name of the AuthorizationPolicy resource. It matches pattern `projects/{project}/locations/{location}/authorizationPolicies/`.
2750    pub fn locations_authorization_policies_patch(
2751        &self,
2752        request: AuthorizationPolicy,
2753        name: &str,
2754    ) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C> {
2755        ProjectLocationAuthorizationPolicyPatchCall {
2756            hub: self.hub,
2757            _request: request,
2758            _name: name.to_string(),
2759            _update_mask: Default::default(),
2760            _delegate: Default::default(),
2761            _additional_params: Default::default(),
2762            _scopes: Default::default(),
2763        }
2764    }
2765
2766    /// Create a builder to help you perform the following task:
2767    ///
2768    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2769    ///
2770    /// # Arguments
2771    ///
2772    /// * `request` - No description provided.
2773    /// * `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.
2774    pub fn locations_authorization_policies_set_iam_policy(
2775        &self,
2776        request: GoogleIamV1SetIamPolicyRequest,
2777        resource: &str,
2778    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C> {
2779        ProjectLocationAuthorizationPolicySetIamPolicyCall {
2780            hub: self.hub,
2781            _request: request,
2782            _resource: resource.to_string(),
2783            _delegate: Default::default(),
2784            _additional_params: Default::default(),
2785            _scopes: Default::default(),
2786        }
2787    }
2788
2789    /// Create a builder to help you perform the following task:
2790    ///
2791    /// 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.
2792    ///
2793    /// # Arguments
2794    ///
2795    /// * `request` - No description provided.
2796    /// * `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.
2797    pub fn locations_authorization_policies_test_iam_permissions(
2798        &self,
2799        request: GoogleIamV1TestIamPermissionsRequest,
2800        resource: &str,
2801    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C> {
2802        ProjectLocationAuthorizationPolicyTestIamPermissionCall {
2803            hub: self.hub,
2804            _request: request,
2805            _resource: resource.to_string(),
2806            _delegate: Default::default(),
2807            _additional_params: Default::default(),
2808            _scopes: Default::default(),
2809        }
2810    }
2811
2812    /// Create a builder to help you perform the following task:
2813    ///
2814    /// Creates a new ClientTlsPolicy in a given project and location.
2815    ///
2816    /// # Arguments
2817    ///
2818    /// * `request` - No description provided.
2819    /// * `parent` - Required. The parent resource of the ClientTlsPolicy. Must be in the format `projects/*/locations/{location}`.
2820    pub fn locations_client_tls_policies_create(
2821        &self,
2822        request: ClientTlsPolicy,
2823        parent: &str,
2824    ) -> ProjectLocationClientTlsPolicyCreateCall<'a, C> {
2825        ProjectLocationClientTlsPolicyCreateCall {
2826            hub: self.hub,
2827            _request: request,
2828            _parent: parent.to_string(),
2829            _client_tls_policy_id: Default::default(),
2830            _delegate: Default::default(),
2831            _additional_params: Default::default(),
2832            _scopes: Default::default(),
2833        }
2834    }
2835
2836    /// Create a builder to help you perform the following task:
2837    ///
2838    /// Deletes a single ClientTlsPolicy.
2839    ///
2840    /// # Arguments
2841    ///
2842    /// * `name` - Required. A name of the ClientTlsPolicy to delete. Must be in the format `projects/*/locations/{location}/clientTlsPolicies/*`.
2843    pub fn locations_client_tls_policies_delete(
2844        &self,
2845        name: &str,
2846    ) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C> {
2847        ProjectLocationClientTlsPolicyDeleteCall {
2848            hub: self.hub,
2849            _name: name.to_string(),
2850            _delegate: Default::default(),
2851            _additional_params: Default::default(),
2852            _scopes: Default::default(),
2853        }
2854    }
2855
2856    /// Create a builder to help you perform the following task:
2857    ///
2858    /// Gets details of a single ClientTlsPolicy.
2859    ///
2860    /// # Arguments
2861    ///
2862    /// * `name` - Required. A name of the ClientTlsPolicy to get. Must be in the format `projects/*/locations/{location}/clientTlsPolicies/*`.
2863    pub fn locations_client_tls_policies_get(
2864        &self,
2865        name: &str,
2866    ) -> ProjectLocationClientTlsPolicyGetCall<'a, C> {
2867        ProjectLocationClientTlsPolicyGetCall {
2868            hub: self.hub,
2869            _name: name.to_string(),
2870            _delegate: Default::default(),
2871            _additional_params: Default::default(),
2872            _scopes: Default::default(),
2873        }
2874    }
2875
2876    /// Create a builder to help you perform the following task:
2877    ///
2878    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2879    ///
2880    /// # Arguments
2881    ///
2882    /// * `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.
2883    pub fn locations_client_tls_policies_get_iam_policy(
2884        &self,
2885        resource: &str,
2886    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C> {
2887        ProjectLocationClientTlsPolicyGetIamPolicyCall {
2888            hub: self.hub,
2889            _resource: resource.to_string(),
2890            _options_requested_policy_version: Default::default(),
2891            _delegate: Default::default(),
2892            _additional_params: Default::default(),
2893            _scopes: Default::default(),
2894        }
2895    }
2896
2897    /// Create a builder to help you perform the following task:
2898    ///
2899    /// Lists ClientTlsPolicies in a given project and location.
2900    ///
2901    /// # Arguments
2902    ///
2903    /// * `parent` - Required. The project and location from which the ClientTlsPolicies should be listed, specified in the format `projects/*/locations/{location}`.
2904    pub fn locations_client_tls_policies_list(
2905        &self,
2906        parent: &str,
2907    ) -> ProjectLocationClientTlsPolicyListCall<'a, C> {
2908        ProjectLocationClientTlsPolicyListCall {
2909            hub: self.hub,
2910            _parent: parent.to_string(),
2911            _page_token: Default::default(),
2912            _page_size: Default::default(),
2913            _delegate: Default::default(),
2914            _additional_params: Default::default(),
2915            _scopes: Default::default(),
2916        }
2917    }
2918
2919    /// Create a builder to help you perform the following task:
2920    ///
2921    /// Updates the parameters of a single ClientTlsPolicy.
2922    ///
2923    /// # Arguments
2924    ///
2925    /// * `request` - No description provided.
2926    /// * `name` - Required. Name of the ClientTlsPolicy resource. It matches the pattern `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}`
2927    pub fn locations_client_tls_policies_patch(
2928        &self,
2929        request: ClientTlsPolicy,
2930        name: &str,
2931    ) -> ProjectLocationClientTlsPolicyPatchCall<'a, C> {
2932        ProjectLocationClientTlsPolicyPatchCall {
2933            hub: self.hub,
2934            _request: request,
2935            _name: name.to_string(),
2936            _update_mask: Default::default(),
2937            _delegate: Default::default(),
2938            _additional_params: Default::default(),
2939            _scopes: Default::default(),
2940        }
2941    }
2942
2943    /// Create a builder to help you perform the following task:
2944    ///
2945    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2946    ///
2947    /// # Arguments
2948    ///
2949    /// * `request` - No description provided.
2950    /// * `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.
2951    pub fn locations_client_tls_policies_set_iam_policy(
2952        &self,
2953        request: GoogleIamV1SetIamPolicyRequest,
2954        resource: &str,
2955    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C> {
2956        ProjectLocationClientTlsPolicySetIamPolicyCall {
2957            hub: self.hub,
2958            _request: request,
2959            _resource: resource.to_string(),
2960            _delegate: Default::default(),
2961            _additional_params: Default::default(),
2962            _scopes: Default::default(),
2963        }
2964    }
2965
2966    /// Create a builder to help you perform the following task:
2967    ///
2968    /// 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.
2969    ///
2970    /// # Arguments
2971    ///
2972    /// * `request` - No description provided.
2973    /// * `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.
2974    pub fn locations_client_tls_policies_test_iam_permissions(
2975        &self,
2976        request: GoogleIamV1TestIamPermissionsRequest,
2977        resource: &str,
2978    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C> {
2979        ProjectLocationClientTlsPolicyTestIamPermissionCall {
2980            hub: self.hub,
2981            _request: request,
2982            _resource: resource.to_string(),
2983            _delegate: Default::default(),
2984            _additional_params: Default::default(),
2985            _scopes: Default::default(),
2986        }
2987    }
2988
2989    /// Create a builder to help you perform the following task:
2990    ///
2991    /// Creates a new FirewallEndpointAssociation in a given project and location.
2992    ///
2993    /// # Arguments
2994    ///
2995    /// * `request` - No description provided.
2996    /// * `parent` - Required. Value for parent.
2997    pub fn locations_firewall_endpoint_associations_create(
2998        &self,
2999        request: FirewallEndpointAssociation,
3000        parent: &str,
3001    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
3002        ProjectLocationFirewallEndpointAssociationCreateCall {
3003            hub: self.hub,
3004            _request: request,
3005            _parent: parent.to_string(),
3006            _request_id: Default::default(),
3007            _firewall_endpoint_association_id: Default::default(),
3008            _delegate: Default::default(),
3009            _additional_params: Default::default(),
3010            _scopes: Default::default(),
3011        }
3012    }
3013
3014    /// Create a builder to help you perform the following task:
3015    ///
3016    /// Deletes a single FirewallEndpointAssociation.
3017    ///
3018    /// # Arguments
3019    ///
3020    /// * `name` - Required. Name of the resource
3021    pub fn locations_firewall_endpoint_associations_delete(
3022        &self,
3023        name: &str,
3024    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C> {
3025        ProjectLocationFirewallEndpointAssociationDeleteCall {
3026            hub: self.hub,
3027            _name: name.to_string(),
3028            _request_id: Default::default(),
3029            _delegate: Default::default(),
3030            _additional_params: Default::default(),
3031            _scopes: Default::default(),
3032        }
3033    }
3034
3035    /// Create a builder to help you perform the following task:
3036    ///
3037    /// Gets details of a single FirewallEndpointAssociation.
3038    ///
3039    /// # Arguments
3040    ///
3041    /// * `name` - Required. Name of the resource
3042    pub fn locations_firewall_endpoint_associations_get(
3043        &self,
3044        name: &str,
3045    ) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C> {
3046        ProjectLocationFirewallEndpointAssociationGetCall {
3047            hub: self.hub,
3048            _name: name.to_string(),
3049            _delegate: Default::default(),
3050            _additional_params: Default::default(),
3051            _scopes: Default::default(),
3052        }
3053    }
3054
3055    /// Create a builder to help you perform the following task:
3056    ///
3057    /// Lists Associations in a given project and location.
3058    ///
3059    /// # Arguments
3060    ///
3061    /// * `parent` - Required. Parent value for ListAssociationsRequest
3062    pub fn locations_firewall_endpoint_associations_list(
3063        &self,
3064        parent: &str,
3065    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
3066        ProjectLocationFirewallEndpointAssociationListCall {
3067            hub: self.hub,
3068            _parent: parent.to_string(),
3069            _page_token: Default::default(),
3070            _page_size: Default::default(),
3071            _order_by: Default::default(),
3072            _filter: Default::default(),
3073            _delegate: Default::default(),
3074            _additional_params: Default::default(),
3075            _scopes: Default::default(),
3076        }
3077    }
3078
3079    /// Create a builder to help you perform the following task:
3080    ///
3081    /// Update a single FirewallEndpointAssociation.
3082    ///
3083    /// # Arguments
3084    ///
3085    /// * `request` - No description provided.
3086    /// * `name` - Immutable. Identifier. name of resource
3087    pub fn locations_firewall_endpoint_associations_patch(
3088        &self,
3089        request: FirewallEndpointAssociation,
3090        name: &str,
3091    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
3092        ProjectLocationFirewallEndpointAssociationPatchCall {
3093            hub: self.hub,
3094            _request: request,
3095            _name: name.to_string(),
3096            _update_mask: Default::default(),
3097            _request_id: Default::default(),
3098            _delegate: Default::default(),
3099            _additional_params: Default::default(),
3100            _scopes: Default::default(),
3101        }
3102    }
3103
3104    /// Create a builder to help you perform the following task:
3105    ///
3106    /// Creates a new GatewaySecurityPolicy in a given project and location.
3107    ///
3108    /// # Arguments
3109    ///
3110    /// * `request` - No description provided.
3111    /// * `parent` - Required. The parent where this rule will be created. Format : projects/{project}/location/{location}/gatewaySecurityPolicies/*
3112    pub fn locations_gateway_security_policies_rules_create(
3113        &self,
3114        request: GatewaySecurityPolicyRule,
3115        parent: &str,
3116    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {
3117        ProjectLocationGatewaySecurityPolicyRuleCreateCall {
3118            hub: self.hub,
3119            _request: request,
3120            _parent: parent.to_string(),
3121            _gateway_security_policy_rule_id: Default::default(),
3122            _delegate: Default::default(),
3123            _additional_params: Default::default(),
3124            _scopes: Default::default(),
3125        }
3126    }
3127
3128    /// Create a builder to help you perform the following task:
3129    ///
3130    /// Deletes a single GatewaySecurityPolicyRule.
3131    ///
3132    /// # Arguments
3133    ///
3134    /// * `name` - Required. A name of the GatewaySecurityPolicyRule to delete. Must be in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/{gatewaySecurityPolicy}/rules/*`.
3135    pub fn locations_gateway_security_policies_rules_delete(
3136        &self,
3137        name: &str,
3138    ) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C> {
3139        ProjectLocationGatewaySecurityPolicyRuleDeleteCall {
3140            hub: self.hub,
3141            _name: name.to_string(),
3142            _delegate: Default::default(),
3143            _additional_params: Default::default(),
3144            _scopes: Default::default(),
3145        }
3146    }
3147
3148    /// Create a builder to help you perform the following task:
3149    ///
3150    /// Gets details of a single GatewaySecurityPolicyRule.
3151    ///
3152    /// # Arguments
3153    ///
3154    /// * `name` - Required. The name of the GatewaySecurityPolicyRule to retrieve. Format: projects/{project}/location/{location}/gatewaySecurityPolicies/*/rules/*
3155    pub fn locations_gateway_security_policies_rules_get(
3156        &self,
3157        name: &str,
3158    ) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C> {
3159        ProjectLocationGatewaySecurityPolicyRuleGetCall {
3160            hub: self.hub,
3161            _name: name.to_string(),
3162            _delegate: Default::default(),
3163            _additional_params: Default::default(),
3164            _scopes: Default::default(),
3165        }
3166    }
3167
3168    /// Create a builder to help you perform the following task:
3169    ///
3170    /// Lists GatewaySecurityPolicyRules in a given project and location.
3171    ///
3172    /// # Arguments
3173    ///
3174    /// * `parent` - Required. The project, location and GatewaySecurityPolicy from which the GatewaySecurityPolicyRules should be listed, specified in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/{gatewaySecurityPolicy}`.
3175    pub fn locations_gateway_security_policies_rules_list(
3176        &self,
3177        parent: &str,
3178    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {
3179        ProjectLocationGatewaySecurityPolicyRuleListCall {
3180            hub: self.hub,
3181            _parent: parent.to_string(),
3182            _page_token: Default::default(),
3183            _page_size: Default::default(),
3184            _delegate: Default::default(),
3185            _additional_params: Default::default(),
3186            _scopes: Default::default(),
3187        }
3188    }
3189
3190    /// Create a builder to help you perform the following task:
3191    ///
3192    /// Updates the parameters of a single GatewaySecurityPolicyRule.
3193    ///
3194    /// # Arguments
3195    ///
3196    /// * `request` - No description provided.
3197    /// * `name` - Required. Immutable. Name of the resource. ame is the full resource name so projects/{project}/locations/{location}/gatewaySecurityPolicies/{gateway_security_policy}/rules/{rule} rule should match the pattern: (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
3198    pub fn locations_gateway_security_policies_rules_patch(
3199        &self,
3200        request: GatewaySecurityPolicyRule,
3201        name: &str,
3202    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {
3203        ProjectLocationGatewaySecurityPolicyRulePatchCall {
3204            hub: self.hub,
3205            _request: request,
3206            _name: name.to_string(),
3207            _update_mask: Default::default(),
3208            _delegate: Default::default(),
3209            _additional_params: Default::default(),
3210            _scopes: Default::default(),
3211        }
3212    }
3213
3214    /// Create a builder to help you perform the following task:
3215    ///
3216    /// Creates a new GatewaySecurityPolicy in a given project and location.
3217    ///
3218    /// # Arguments
3219    ///
3220    /// * `request` - No description provided.
3221    /// * `parent` - Required. The parent resource of the GatewaySecurityPolicy. Must be in the format `projects/{project}/locations/{location}`.
3222    pub fn locations_gateway_security_policies_create(
3223        &self,
3224        request: GatewaySecurityPolicy,
3225        parent: &str,
3226    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {
3227        ProjectLocationGatewaySecurityPolicyCreateCall {
3228            hub: self.hub,
3229            _request: request,
3230            _parent: parent.to_string(),
3231            _gateway_security_policy_id: Default::default(),
3232            _delegate: Default::default(),
3233            _additional_params: Default::default(),
3234            _scopes: Default::default(),
3235        }
3236    }
3237
3238    /// Create a builder to help you perform the following task:
3239    ///
3240    /// Deletes a single GatewaySecurityPolicy.
3241    ///
3242    /// # Arguments
3243    ///
3244    /// * `name` - Required. A name of the GatewaySecurityPolicy to delete. Must be in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/*`.
3245    pub fn locations_gateway_security_policies_delete(
3246        &self,
3247        name: &str,
3248    ) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C> {
3249        ProjectLocationGatewaySecurityPolicyDeleteCall {
3250            hub: self.hub,
3251            _name: name.to_string(),
3252            _delegate: Default::default(),
3253            _additional_params: Default::default(),
3254            _scopes: Default::default(),
3255        }
3256    }
3257
3258    /// Create a builder to help you perform the following task:
3259    ///
3260    /// Gets details of a single GatewaySecurityPolicy.
3261    ///
3262    /// # Arguments
3263    ///
3264    /// * `name` - Required. A name of the GatewaySecurityPolicy to get. Must be in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/*`.
3265    pub fn locations_gateway_security_policies_get(
3266        &self,
3267        name: &str,
3268    ) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C> {
3269        ProjectLocationGatewaySecurityPolicyGetCall {
3270            hub: self.hub,
3271            _name: name.to_string(),
3272            _delegate: Default::default(),
3273            _additional_params: Default::default(),
3274            _scopes: Default::default(),
3275        }
3276    }
3277
3278    /// Create a builder to help you perform the following task:
3279    ///
3280    /// Lists GatewaySecurityPolicies in a given project and location.
3281    ///
3282    /// # Arguments
3283    ///
3284    /// * `parent` - Required. The project and location from which the GatewaySecurityPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
3285    pub fn locations_gateway_security_policies_list(
3286        &self,
3287        parent: &str,
3288    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C> {
3289        ProjectLocationGatewaySecurityPolicyListCall {
3290            hub: self.hub,
3291            _parent: parent.to_string(),
3292            _page_token: Default::default(),
3293            _page_size: Default::default(),
3294            _delegate: Default::default(),
3295            _additional_params: Default::default(),
3296            _scopes: Default::default(),
3297        }
3298    }
3299
3300    /// Create a builder to help you perform the following task:
3301    ///
3302    /// Updates the parameters of a single GatewaySecurityPolicy.
3303    ///
3304    /// # Arguments
3305    ///
3306    /// * `request` - No description provided.
3307    /// * `name` - Required. Name of the resource. Name is of the form projects/{project}/locations/{location}/gatewaySecurityPolicies/{gateway_security_policy} gateway_security_policy should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
3308    pub fn locations_gateway_security_policies_patch(
3309        &self,
3310        request: GatewaySecurityPolicy,
3311        name: &str,
3312    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {
3313        ProjectLocationGatewaySecurityPolicyPatchCall {
3314            hub: self.hub,
3315            _request: request,
3316            _name: name.to_string(),
3317            _update_mask: Default::default(),
3318            _delegate: Default::default(),
3319            _additional_params: Default::default(),
3320            _scopes: Default::default(),
3321        }
3322    }
3323
3324    /// Create a builder to help you perform the following task:
3325    ///
3326    /// 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`.
3327    ///
3328    /// # Arguments
3329    ///
3330    /// * `request` - No description provided.
3331    /// * `name` - The name of the operation resource to be cancelled.
3332    pub fn locations_operations_cancel(
3333        &self,
3334        request: CancelOperationRequest,
3335        name: &str,
3336    ) -> ProjectLocationOperationCancelCall<'a, C> {
3337        ProjectLocationOperationCancelCall {
3338            hub: self.hub,
3339            _request: request,
3340            _name: name.to_string(),
3341            _delegate: Default::default(),
3342            _additional_params: Default::default(),
3343            _scopes: Default::default(),
3344        }
3345    }
3346
3347    /// Create a builder to help you perform the following task:
3348    ///
3349    /// 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`.
3350    ///
3351    /// # Arguments
3352    ///
3353    /// * `name` - The name of the operation resource to be deleted.
3354    pub fn locations_operations_delete(
3355        &self,
3356        name: &str,
3357    ) -> ProjectLocationOperationDeleteCall<'a, C> {
3358        ProjectLocationOperationDeleteCall {
3359            hub: self.hub,
3360            _name: name.to_string(),
3361            _delegate: Default::default(),
3362            _additional_params: Default::default(),
3363            _scopes: Default::default(),
3364        }
3365    }
3366
3367    /// Create a builder to help you perform the following task:
3368    ///
3369    /// 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.
3370    ///
3371    /// # Arguments
3372    ///
3373    /// * `name` - The name of the operation resource.
3374    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3375        ProjectLocationOperationGetCall {
3376            hub: self.hub,
3377            _name: name.to_string(),
3378            _delegate: Default::default(),
3379            _additional_params: Default::default(),
3380            _scopes: Default::default(),
3381        }
3382    }
3383
3384    /// Create a builder to help you perform the following task:
3385    ///
3386    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3387    ///
3388    /// # Arguments
3389    ///
3390    /// * `name` - The name of the operation's parent resource.
3391    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3392        ProjectLocationOperationListCall {
3393            hub: self.hub,
3394            _name: name.to_string(),
3395            _page_token: Default::default(),
3396            _page_size: Default::default(),
3397            _filter: Default::default(),
3398            _delegate: Default::default(),
3399            _additional_params: Default::default(),
3400            _scopes: Default::default(),
3401        }
3402    }
3403
3404    /// Create a builder to help you perform the following task:
3405    ///
3406    /// Creates a new ServerTlsPolicy in a given project and location.
3407    ///
3408    /// # Arguments
3409    ///
3410    /// * `request` - No description provided.
3411    /// * `parent` - Required. The parent resource of the ServerTlsPolicy. Must be in the format `projects/*/locations/{location}`.
3412    pub fn locations_server_tls_policies_create(
3413        &self,
3414        request: ServerTlsPolicy,
3415        parent: &str,
3416    ) -> ProjectLocationServerTlsPolicyCreateCall<'a, C> {
3417        ProjectLocationServerTlsPolicyCreateCall {
3418            hub: self.hub,
3419            _request: request,
3420            _parent: parent.to_string(),
3421            _server_tls_policy_id: Default::default(),
3422            _delegate: Default::default(),
3423            _additional_params: Default::default(),
3424            _scopes: Default::default(),
3425        }
3426    }
3427
3428    /// Create a builder to help you perform the following task:
3429    ///
3430    /// Deletes a single ServerTlsPolicy.
3431    ///
3432    /// # Arguments
3433    ///
3434    /// * `name` - Required. A name of the ServerTlsPolicy to delete. Must be in the format `projects/*/locations/{location}/serverTlsPolicies/*`.
3435    pub fn locations_server_tls_policies_delete(
3436        &self,
3437        name: &str,
3438    ) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C> {
3439        ProjectLocationServerTlsPolicyDeleteCall {
3440            hub: self.hub,
3441            _name: name.to_string(),
3442            _delegate: Default::default(),
3443            _additional_params: Default::default(),
3444            _scopes: Default::default(),
3445        }
3446    }
3447
3448    /// Create a builder to help you perform the following task:
3449    ///
3450    /// Gets details of a single ServerTlsPolicy.
3451    ///
3452    /// # Arguments
3453    ///
3454    /// * `name` - Required. A name of the ServerTlsPolicy to get. Must be in the format `projects/*/locations/{location}/serverTlsPolicies/*`.
3455    pub fn locations_server_tls_policies_get(
3456        &self,
3457        name: &str,
3458    ) -> ProjectLocationServerTlsPolicyGetCall<'a, C> {
3459        ProjectLocationServerTlsPolicyGetCall {
3460            hub: self.hub,
3461            _name: name.to_string(),
3462            _delegate: Default::default(),
3463            _additional_params: Default::default(),
3464            _scopes: Default::default(),
3465        }
3466    }
3467
3468    /// Create a builder to help you perform the following task:
3469    ///
3470    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3471    ///
3472    /// # Arguments
3473    ///
3474    /// * `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.
3475    pub fn locations_server_tls_policies_get_iam_policy(
3476        &self,
3477        resource: &str,
3478    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C> {
3479        ProjectLocationServerTlsPolicyGetIamPolicyCall {
3480            hub: self.hub,
3481            _resource: resource.to_string(),
3482            _options_requested_policy_version: Default::default(),
3483            _delegate: Default::default(),
3484            _additional_params: Default::default(),
3485            _scopes: Default::default(),
3486        }
3487    }
3488
3489    /// Create a builder to help you perform the following task:
3490    ///
3491    /// Lists ServerTlsPolicies in a given project and location.
3492    ///
3493    /// # Arguments
3494    ///
3495    /// * `parent` - Required. The project and location from which the ServerTlsPolicies should be listed, specified in the format `projects/*/locations/{location}`.
3496    pub fn locations_server_tls_policies_list(
3497        &self,
3498        parent: &str,
3499    ) -> ProjectLocationServerTlsPolicyListCall<'a, C> {
3500        ProjectLocationServerTlsPolicyListCall {
3501            hub: self.hub,
3502            _parent: parent.to_string(),
3503            _page_token: Default::default(),
3504            _page_size: Default::default(),
3505            _delegate: Default::default(),
3506            _additional_params: Default::default(),
3507            _scopes: Default::default(),
3508        }
3509    }
3510
3511    /// Create a builder to help you perform the following task:
3512    ///
3513    /// Updates the parameters of a single ServerTlsPolicy.
3514    ///
3515    /// # Arguments
3516    ///
3517    /// * `request` - No description provided.
3518    /// * `name` - Required. Name of the ServerTlsPolicy resource. It matches the pattern `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}`
3519    pub fn locations_server_tls_policies_patch(
3520        &self,
3521        request: ServerTlsPolicy,
3522        name: &str,
3523    ) -> ProjectLocationServerTlsPolicyPatchCall<'a, C> {
3524        ProjectLocationServerTlsPolicyPatchCall {
3525            hub: self.hub,
3526            _request: request,
3527            _name: name.to_string(),
3528            _update_mask: Default::default(),
3529            _delegate: Default::default(),
3530            _additional_params: Default::default(),
3531            _scopes: Default::default(),
3532        }
3533    }
3534
3535    /// Create a builder to help you perform the following task:
3536    ///
3537    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3538    ///
3539    /// # Arguments
3540    ///
3541    /// * `request` - No description provided.
3542    /// * `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.
3543    pub fn locations_server_tls_policies_set_iam_policy(
3544        &self,
3545        request: GoogleIamV1SetIamPolicyRequest,
3546        resource: &str,
3547    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C> {
3548        ProjectLocationServerTlsPolicySetIamPolicyCall {
3549            hub: self.hub,
3550            _request: request,
3551            _resource: resource.to_string(),
3552            _delegate: Default::default(),
3553            _additional_params: Default::default(),
3554            _scopes: Default::default(),
3555        }
3556    }
3557
3558    /// Create a builder to help you perform the following task:
3559    ///
3560    /// 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.
3561    ///
3562    /// # Arguments
3563    ///
3564    /// * `request` - No description provided.
3565    /// * `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.
3566    pub fn locations_server_tls_policies_test_iam_permissions(
3567        &self,
3568        request: GoogleIamV1TestIamPermissionsRequest,
3569        resource: &str,
3570    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C> {
3571        ProjectLocationServerTlsPolicyTestIamPermissionCall {
3572            hub: self.hub,
3573            _request: request,
3574            _resource: resource.to_string(),
3575            _delegate: Default::default(),
3576            _additional_params: Default::default(),
3577            _scopes: Default::default(),
3578        }
3579    }
3580
3581    /// Create a builder to help you perform the following task:
3582    ///
3583    /// Creates a new TlsInspectionPolicy in a given project and location.
3584    ///
3585    /// # Arguments
3586    ///
3587    /// * `request` - No description provided.
3588    /// * `parent` - Required. The parent resource of the TlsInspectionPolicy. Must be in the format `projects/{project}/locations/{location}`.
3589    pub fn locations_tls_inspection_policies_create(
3590        &self,
3591        request: TlsInspectionPolicy,
3592        parent: &str,
3593    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {
3594        ProjectLocationTlsInspectionPolicyCreateCall {
3595            hub: self.hub,
3596            _request: request,
3597            _parent: parent.to_string(),
3598            _tls_inspection_policy_id: Default::default(),
3599            _delegate: Default::default(),
3600            _additional_params: Default::default(),
3601            _scopes: Default::default(),
3602        }
3603    }
3604
3605    /// Create a builder to help you perform the following task:
3606    ///
3607    /// Deletes a single TlsInspectionPolicy.
3608    ///
3609    /// # Arguments
3610    ///
3611    /// * `name` - Required. A name of the TlsInspectionPolicy to delete. Must be in the format `projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy}`.
3612    pub fn locations_tls_inspection_policies_delete(
3613        &self,
3614        name: &str,
3615    ) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C> {
3616        ProjectLocationTlsInspectionPolicyDeleteCall {
3617            hub: self.hub,
3618            _name: name.to_string(),
3619            _force: Default::default(),
3620            _delegate: Default::default(),
3621            _additional_params: Default::default(),
3622            _scopes: Default::default(),
3623        }
3624    }
3625
3626    /// Create a builder to help you perform the following task:
3627    ///
3628    /// Gets details of a single TlsInspectionPolicy.
3629    ///
3630    /// # Arguments
3631    ///
3632    /// * `name` - Required. A name of the TlsInspectionPolicy to get. Must be in the format `projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy}`.
3633    pub fn locations_tls_inspection_policies_get(
3634        &self,
3635        name: &str,
3636    ) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C> {
3637        ProjectLocationTlsInspectionPolicyGetCall {
3638            hub: self.hub,
3639            _name: name.to_string(),
3640            _delegate: Default::default(),
3641            _additional_params: Default::default(),
3642            _scopes: Default::default(),
3643        }
3644    }
3645
3646    /// Create a builder to help you perform the following task:
3647    ///
3648    /// Lists TlsInspectionPolicies in a given project and location.
3649    ///
3650    /// # Arguments
3651    ///
3652    /// * `parent` - Required. The project and location from which the TlsInspectionPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
3653    pub fn locations_tls_inspection_policies_list(
3654        &self,
3655        parent: &str,
3656    ) -> ProjectLocationTlsInspectionPolicyListCall<'a, C> {
3657        ProjectLocationTlsInspectionPolicyListCall {
3658            hub: self.hub,
3659            _parent: parent.to_string(),
3660            _page_token: Default::default(),
3661            _page_size: Default::default(),
3662            _delegate: Default::default(),
3663            _additional_params: Default::default(),
3664            _scopes: Default::default(),
3665        }
3666    }
3667
3668    /// Create a builder to help you perform the following task:
3669    ///
3670    /// Updates the parameters of a single TlsInspectionPolicy.
3671    ///
3672    /// # Arguments
3673    ///
3674    /// * `request` - No description provided.
3675    /// * `name` - Required. Name of the resource. Name is of the form projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy} tls_inspection_policy should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
3676    pub fn locations_tls_inspection_policies_patch(
3677        &self,
3678        request: TlsInspectionPolicy,
3679        name: &str,
3680    ) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {
3681        ProjectLocationTlsInspectionPolicyPatchCall {
3682            hub: self.hub,
3683            _request: request,
3684            _name: name.to_string(),
3685            _update_mask: Default::default(),
3686            _delegate: Default::default(),
3687            _additional_params: Default::default(),
3688            _scopes: Default::default(),
3689        }
3690    }
3691
3692    /// Create a builder to help you perform the following task:
3693    ///
3694    /// Creates a new UrlList in a given project and location.
3695    ///
3696    /// # Arguments
3697    ///
3698    /// * `request` - No description provided.
3699    /// * `parent` - Required. The parent resource of the UrlList. Must be in the format `projects/*/locations/{location}`.
3700    pub fn locations_url_lists_create(
3701        &self,
3702        request: UrlList,
3703        parent: &str,
3704    ) -> ProjectLocationUrlListCreateCall<'a, C> {
3705        ProjectLocationUrlListCreateCall {
3706            hub: self.hub,
3707            _request: request,
3708            _parent: parent.to_string(),
3709            _url_list_id: Default::default(),
3710            _delegate: Default::default(),
3711            _additional_params: Default::default(),
3712            _scopes: Default::default(),
3713        }
3714    }
3715
3716    /// Create a builder to help you perform the following task:
3717    ///
3718    /// Deletes a single UrlList.
3719    ///
3720    /// # Arguments
3721    ///
3722    /// * `name` - Required. A name of the UrlList to delete. Must be in the format `projects/*/locations/{location}/urlLists/*`.
3723    pub fn locations_url_lists_delete(
3724        &self,
3725        name: &str,
3726    ) -> ProjectLocationUrlListDeleteCall<'a, C> {
3727        ProjectLocationUrlListDeleteCall {
3728            hub: self.hub,
3729            _name: name.to_string(),
3730            _delegate: Default::default(),
3731            _additional_params: Default::default(),
3732            _scopes: Default::default(),
3733        }
3734    }
3735
3736    /// Create a builder to help you perform the following task:
3737    ///
3738    /// Gets details of a single UrlList.
3739    ///
3740    /// # Arguments
3741    ///
3742    /// * `name` - Required. A name of the UrlList to get. Must be in the format `projects/*/locations/{location}/urlLists/*`.
3743    pub fn locations_url_lists_get(&self, name: &str) -> ProjectLocationUrlListGetCall<'a, C> {
3744        ProjectLocationUrlListGetCall {
3745            hub: self.hub,
3746            _name: name.to_string(),
3747            _delegate: Default::default(),
3748            _additional_params: Default::default(),
3749            _scopes: Default::default(),
3750        }
3751    }
3752
3753    /// Create a builder to help you perform the following task:
3754    ///
3755    /// Lists UrlLists in a given project and location.
3756    ///
3757    /// # Arguments
3758    ///
3759    /// * `parent` - Required. The project and location from which the UrlLists should be listed, specified in the format `projects/{project}/locations/{location}`.
3760    pub fn locations_url_lists_list(&self, parent: &str) -> ProjectLocationUrlListListCall<'a, C> {
3761        ProjectLocationUrlListListCall {
3762            hub: self.hub,
3763            _parent: parent.to_string(),
3764            _page_token: Default::default(),
3765            _page_size: Default::default(),
3766            _delegate: Default::default(),
3767            _additional_params: Default::default(),
3768            _scopes: Default::default(),
3769        }
3770    }
3771
3772    /// Create a builder to help you perform the following task:
3773    ///
3774    /// Updates the parameters of a single UrlList.
3775    ///
3776    /// # Arguments
3777    ///
3778    /// * `request` - No description provided.
3779    /// * `name` - Required. Name of the resource provided by the user. Name is of the form projects/{project}/locations/{location}/urlLists/{url_list} url_list should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
3780    pub fn locations_url_lists_patch(
3781        &self,
3782        request: UrlList,
3783        name: &str,
3784    ) -> ProjectLocationUrlListPatchCall<'a, C> {
3785        ProjectLocationUrlListPatchCall {
3786            hub: self.hub,
3787            _request: request,
3788            _name: name.to_string(),
3789            _update_mask: Default::default(),
3790            _delegate: Default::default(),
3791            _additional_params: Default::default(),
3792            _scopes: Default::default(),
3793        }
3794    }
3795
3796    /// Create a builder to help you perform the following task:
3797    ///
3798    /// Gets information about a location.
3799    ///
3800    /// # Arguments
3801    ///
3802    /// * `name` - Resource name for the location.
3803    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3804        ProjectLocationGetCall {
3805            hub: self.hub,
3806            _name: name.to_string(),
3807            _delegate: Default::default(),
3808            _additional_params: Default::default(),
3809            _scopes: Default::default(),
3810        }
3811    }
3812
3813    /// Create a builder to help you perform the following task:
3814    ///
3815    /// Lists information about the supported locations for this service.
3816    ///
3817    /// # Arguments
3818    ///
3819    /// * `name` - The resource that owns the locations collection, if applicable.
3820    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3821        ProjectLocationListCall {
3822            hub: self.hub,
3823            _name: name.to_string(),
3824            _page_token: Default::default(),
3825            _page_size: Default::default(),
3826            _filter: Default::default(),
3827            _delegate: Default::default(),
3828            _additional_params: Default::default(),
3829            _scopes: Default::default(),
3830        }
3831    }
3832}
3833
3834// ###################
3835// CallBuilders   ###
3836// #################
3837
3838/// Adds items to an address group.
3839///
3840/// A builder for the *locations.addressGroups.addItems* method supported by a *organization* resource.
3841/// It is not used directly, but through a [`OrganizationMethods`] instance.
3842///
3843/// # Example
3844///
3845/// Instantiate a resource method builder
3846///
3847/// ```test_harness,no_run
3848/// # extern crate hyper;
3849/// # extern crate hyper_rustls;
3850/// # extern crate google_networksecurity1 as networksecurity1;
3851/// use networksecurity1::api::AddAddressGroupItemsRequest;
3852/// # async fn dox() {
3853/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3854///
3855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3857/// #     secret,
3858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3859/// # ).build().await.unwrap();
3860///
3861/// # let client = hyper_util::client::legacy::Client::builder(
3862/// #     hyper_util::rt::TokioExecutor::new()
3863/// # )
3864/// # .build(
3865/// #     hyper_rustls::HttpsConnectorBuilder::new()
3866/// #         .with_native_roots()
3867/// #         .unwrap()
3868/// #         .https_or_http()
3869/// #         .enable_http1()
3870/// #         .build()
3871/// # );
3872/// # let mut hub = NetworkSecurity::new(client, auth);
3873/// // As the method needs a request, you would usually fill it with the desired information
3874/// // into the respective structure. Some of the parts shown here might not be applicable !
3875/// // Values shown here are possibly random and not representative !
3876/// let mut req = AddAddressGroupItemsRequest::default();
3877///
3878/// // You can configure optional parameters by calling the respective setters at will, and
3879/// // execute the final call using `doit()`.
3880/// // Values shown here are possibly random and not representative !
3881/// let result = hub.organizations().locations_address_groups_add_items(req, "addressGroup")
3882///              .doit().await;
3883/// # }
3884/// ```
3885pub struct OrganizationLocationAddressGroupAddItemCall<'a, C>
3886where
3887    C: 'a,
3888{
3889    hub: &'a NetworkSecurity<C>,
3890    _request: AddAddressGroupItemsRequest,
3891    _address_group: String,
3892    _delegate: Option<&'a mut dyn common::Delegate>,
3893    _additional_params: HashMap<String, String>,
3894    _scopes: BTreeSet<String>,
3895}
3896
3897impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupAddItemCall<'a, C> {}
3898
3899impl<'a, C> OrganizationLocationAddressGroupAddItemCall<'a, C>
3900where
3901    C: common::Connector,
3902{
3903    /// Perform the operation you have build so far.
3904    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3905        use std::borrow::Cow;
3906        use std::io::{Read, Seek};
3907
3908        use common::{url::Params, ToParts};
3909        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3910
3911        let mut dd = common::DefaultDelegate;
3912        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3913        dlg.begin(common::MethodInfo {
3914            id: "networksecurity.organizations.locations.addressGroups.addItems",
3915            http_method: hyper::Method::POST,
3916        });
3917
3918        for &field in ["alt", "addressGroup"].iter() {
3919            if self._additional_params.contains_key(field) {
3920                dlg.finished(false);
3921                return Err(common::Error::FieldClash(field));
3922            }
3923        }
3924
3925        let mut params = Params::with_capacity(4 + self._additional_params.len());
3926        params.push("addressGroup", self._address_group);
3927
3928        params.extend(self._additional_params.iter());
3929
3930        params.push("alt", "json");
3931        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:addItems";
3932        if self._scopes.is_empty() {
3933            self._scopes
3934                .insert(Scope::CloudPlatform.as_ref().to_string());
3935        }
3936
3937        #[allow(clippy::single_element_loop)]
3938        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
3939            url = params.uri_replacement(url, param_name, find_this, true);
3940        }
3941        {
3942            let to_remove = ["addressGroup"];
3943            params.remove_params(&to_remove);
3944        }
3945
3946        let url = params.parse_with_url(&url);
3947
3948        let mut json_mime_type = mime::APPLICATION_JSON;
3949        let mut request_value_reader = {
3950            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3951            common::remove_json_null_values(&mut value);
3952            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3953            serde_json::to_writer(&mut dst, &value).unwrap();
3954            dst
3955        };
3956        let request_size = request_value_reader
3957            .seek(std::io::SeekFrom::End(0))
3958            .unwrap();
3959        request_value_reader
3960            .seek(std::io::SeekFrom::Start(0))
3961            .unwrap();
3962
3963        loop {
3964            let token = match self
3965                .hub
3966                .auth
3967                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3968                .await
3969            {
3970                Ok(token) => token,
3971                Err(e) => match dlg.token(e) {
3972                    Ok(token) => token,
3973                    Err(e) => {
3974                        dlg.finished(false);
3975                        return Err(common::Error::MissingToken(e));
3976                    }
3977                },
3978            };
3979            request_value_reader
3980                .seek(std::io::SeekFrom::Start(0))
3981                .unwrap();
3982            let mut req_result = {
3983                let client = &self.hub.client;
3984                dlg.pre_request();
3985                let mut req_builder = hyper::Request::builder()
3986                    .method(hyper::Method::POST)
3987                    .uri(url.as_str())
3988                    .header(USER_AGENT, self.hub._user_agent.clone());
3989
3990                if let Some(token) = token.as_ref() {
3991                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3992                }
3993
3994                let request = req_builder
3995                    .header(CONTENT_TYPE, json_mime_type.to_string())
3996                    .header(CONTENT_LENGTH, request_size as u64)
3997                    .body(common::to_body(
3998                        request_value_reader.get_ref().clone().into(),
3999                    ));
4000
4001                client.request(request.unwrap()).await
4002            };
4003
4004            match req_result {
4005                Err(err) => {
4006                    if let common::Retry::After(d) = dlg.http_error(&err) {
4007                        sleep(d).await;
4008                        continue;
4009                    }
4010                    dlg.finished(false);
4011                    return Err(common::Error::HttpError(err));
4012                }
4013                Ok(res) => {
4014                    let (mut parts, body) = res.into_parts();
4015                    let mut body = common::Body::new(body);
4016                    if !parts.status.is_success() {
4017                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4018                        let error = serde_json::from_str(&common::to_string(&bytes));
4019                        let response = common::to_response(parts, bytes.into());
4020
4021                        if let common::Retry::After(d) =
4022                            dlg.http_failure(&response, error.as_ref().ok())
4023                        {
4024                            sleep(d).await;
4025                            continue;
4026                        }
4027
4028                        dlg.finished(false);
4029
4030                        return Err(match error {
4031                            Ok(value) => common::Error::BadRequest(value),
4032                            _ => common::Error::Failure(response),
4033                        });
4034                    }
4035                    let response = {
4036                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4037                        let encoded = common::to_string(&bytes);
4038                        match serde_json::from_str(&encoded) {
4039                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4040                            Err(error) => {
4041                                dlg.response_json_decode_error(&encoded, &error);
4042                                return Err(common::Error::JsonDecodeError(
4043                                    encoded.to_string(),
4044                                    error,
4045                                ));
4046                            }
4047                        }
4048                    };
4049
4050                    dlg.finished(true);
4051                    return Ok(response);
4052                }
4053            }
4054        }
4055    }
4056
4057    ///
4058    /// Sets the *request* property to the given value.
4059    ///
4060    /// Even though the property as already been set when instantiating this call,
4061    /// we provide this method for API completeness.
4062    pub fn request(
4063        mut self,
4064        new_value: AddAddressGroupItemsRequest,
4065    ) -> OrganizationLocationAddressGroupAddItemCall<'a, C> {
4066        self._request = new_value;
4067        self
4068    }
4069    /// Required. A name of the AddressGroup to add items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
4070    ///
4071    /// Sets the *address group* path property to the given value.
4072    ///
4073    /// Even though the property as already been set when instantiating this call,
4074    /// we provide this method for API completeness.
4075    pub fn address_group(
4076        mut self,
4077        new_value: &str,
4078    ) -> OrganizationLocationAddressGroupAddItemCall<'a, C> {
4079        self._address_group = new_value.to_string();
4080        self
4081    }
4082    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4083    /// while executing the actual API request.
4084    ///
4085    /// ````text
4086    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4087    /// ````
4088    ///
4089    /// Sets the *delegate* property to the given value.
4090    pub fn delegate(
4091        mut self,
4092        new_value: &'a mut dyn common::Delegate,
4093    ) -> OrganizationLocationAddressGroupAddItemCall<'a, C> {
4094        self._delegate = Some(new_value);
4095        self
4096    }
4097
4098    /// Set any additional parameter of the query string used in the request.
4099    /// It should be used to set parameters which are not yet available through their own
4100    /// setters.
4101    ///
4102    /// Please note that this method must not be used to set any of the known parameters
4103    /// which have their own setter method. If done anyway, the request will fail.
4104    ///
4105    /// # Additional Parameters
4106    ///
4107    /// * *$.xgafv* (query-string) - V1 error format.
4108    /// * *access_token* (query-string) - OAuth access token.
4109    /// * *alt* (query-string) - Data format for response.
4110    /// * *callback* (query-string) - JSONP
4111    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4112    /// * *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.
4113    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4114    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4115    /// * *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.
4116    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4117    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4118    pub fn param<T>(
4119        mut self,
4120        name: T,
4121        value: T,
4122    ) -> OrganizationLocationAddressGroupAddItemCall<'a, C>
4123    where
4124        T: AsRef<str>,
4125    {
4126        self._additional_params
4127            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4128        self
4129    }
4130
4131    /// Identifies the authorization scope for the method you are building.
4132    ///
4133    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4134    /// [`Scope::CloudPlatform`].
4135    ///
4136    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4137    /// tokens for more than one scope.
4138    ///
4139    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4140    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4141    /// sufficient, a read-write scope will do as well.
4142    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationAddressGroupAddItemCall<'a, C>
4143    where
4144        St: AsRef<str>,
4145    {
4146        self._scopes.insert(String::from(scope.as_ref()));
4147        self
4148    }
4149    /// Identifies the authorization scope(s) for the method you are building.
4150    ///
4151    /// See [`Self::add_scope()`] for details.
4152    pub fn add_scopes<I, St>(
4153        mut self,
4154        scopes: I,
4155    ) -> OrganizationLocationAddressGroupAddItemCall<'a, C>
4156    where
4157        I: IntoIterator<Item = St>,
4158        St: AsRef<str>,
4159    {
4160        self._scopes
4161            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4162        self
4163    }
4164
4165    /// Removes all scopes, and no default scope will be used either.
4166    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4167    /// for details).
4168    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupAddItemCall<'a, C> {
4169        self._scopes.clear();
4170        self
4171    }
4172}
4173
4174/// Clones items from one address group to another.
4175///
4176/// A builder for the *locations.addressGroups.cloneItems* method supported by a *organization* resource.
4177/// It is not used directly, but through a [`OrganizationMethods`] instance.
4178///
4179/// # Example
4180///
4181/// Instantiate a resource method builder
4182///
4183/// ```test_harness,no_run
4184/// # extern crate hyper;
4185/// # extern crate hyper_rustls;
4186/// # extern crate google_networksecurity1 as networksecurity1;
4187/// use networksecurity1::api::CloneAddressGroupItemsRequest;
4188/// # async fn dox() {
4189/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4190///
4191/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4193/// #     secret,
4194/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4195/// # ).build().await.unwrap();
4196///
4197/// # let client = hyper_util::client::legacy::Client::builder(
4198/// #     hyper_util::rt::TokioExecutor::new()
4199/// # )
4200/// # .build(
4201/// #     hyper_rustls::HttpsConnectorBuilder::new()
4202/// #         .with_native_roots()
4203/// #         .unwrap()
4204/// #         .https_or_http()
4205/// #         .enable_http1()
4206/// #         .build()
4207/// # );
4208/// # let mut hub = NetworkSecurity::new(client, auth);
4209/// // As the method needs a request, you would usually fill it with the desired information
4210/// // into the respective structure. Some of the parts shown here might not be applicable !
4211/// // Values shown here are possibly random and not representative !
4212/// let mut req = CloneAddressGroupItemsRequest::default();
4213///
4214/// // You can configure optional parameters by calling the respective setters at will, and
4215/// // execute the final call using `doit()`.
4216/// // Values shown here are possibly random and not representative !
4217/// let result = hub.organizations().locations_address_groups_clone_items(req, "addressGroup")
4218///              .doit().await;
4219/// # }
4220/// ```
4221pub struct OrganizationLocationAddressGroupCloneItemCall<'a, C>
4222where
4223    C: 'a,
4224{
4225    hub: &'a NetworkSecurity<C>,
4226    _request: CloneAddressGroupItemsRequest,
4227    _address_group: String,
4228    _delegate: Option<&'a mut dyn common::Delegate>,
4229    _additional_params: HashMap<String, String>,
4230    _scopes: BTreeSet<String>,
4231}
4232
4233impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupCloneItemCall<'a, C> {}
4234
4235impl<'a, C> OrganizationLocationAddressGroupCloneItemCall<'a, C>
4236where
4237    C: common::Connector,
4238{
4239    /// Perform the operation you have build so far.
4240    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4241        use std::borrow::Cow;
4242        use std::io::{Read, Seek};
4243
4244        use common::{url::Params, ToParts};
4245        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4246
4247        let mut dd = common::DefaultDelegate;
4248        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4249        dlg.begin(common::MethodInfo {
4250            id: "networksecurity.organizations.locations.addressGroups.cloneItems",
4251            http_method: hyper::Method::POST,
4252        });
4253
4254        for &field in ["alt", "addressGroup"].iter() {
4255            if self._additional_params.contains_key(field) {
4256                dlg.finished(false);
4257                return Err(common::Error::FieldClash(field));
4258            }
4259        }
4260
4261        let mut params = Params::with_capacity(4 + self._additional_params.len());
4262        params.push("addressGroup", self._address_group);
4263
4264        params.extend(self._additional_params.iter());
4265
4266        params.push("alt", "json");
4267        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:cloneItems";
4268        if self._scopes.is_empty() {
4269            self._scopes
4270                .insert(Scope::CloudPlatform.as_ref().to_string());
4271        }
4272
4273        #[allow(clippy::single_element_loop)]
4274        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
4275            url = params.uri_replacement(url, param_name, find_this, true);
4276        }
4277        {
4278            let to_remove = ["addressGroup"];
4279            params.remove_params(&to_remove);
4280        }
4281
4282        let url = params.parse_with_url(&url);
4283
4284        let mut json_mime_type = mime::APPLICATION_JSON;
4285        let mut request_value_reader = {
4286            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4287            common::remove_json_null_values(&mut value);
4288            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4289            serde_json::to_writer(&mut dst, &value).unwrap();
4290            dst
4291        };
4292        let request_size = request_value_reader
4293            .seek(std::io::SeekFrom::End(0))
4294            .unwrap();
4295        request_value_reader
4296            .seek(std::io::SeekFrom::Start(0))
4297            .unwrap();
4298
4299        loop {
4300            let token = match self
4301                .hub
4302                .auth
4303                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4304                .await
4305            {
4306                Ok(token) => token,
4307                Err(e) => match dlg.token(e) {
4308                    Ok(token) => token,
4309                    Err(e) => {
4310                        dlg.finished(false);
4311                        return Err(common::Error::MissingToken(e));
4312                    }
4313                },
4314            };
4315            request_value_reader
4316                .seek(std::io::SeekFrom::Start(0))
4317                .unwrap();
4318            let mut req_result = {
4319                let client = &self.hub.client;
4320                dlg.pre_request();
4321                let mut req_builder = hyper::Request::builder()
4322                    .method(hyper::Method::POST)
4323                    .uri(url.as_str())
4324                    .header(USER_AGENT, self.hub._user_agent.clone());
4325
4326                if let Some(token) = token.as_ref() {
4327                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4328                }
4329
4330                let request = req_builder
4331                    .header(CONTENT_TYPE, json_mime_type.to_string())
4332                    .header(CONTENT_LENGTH, request_size as u64)
4333                    .body(common::to_body(
4334                        request_value_reader.get_ref().clone().into(),
4335                    ));
4336
4337                client.request(request.unwrap()).await
4338            };
4339
4340            match req_result {
4341                Err(err) => {
4342                    if let common::Retry::After(d) = dlg.http_error(&err) {
4343                        sleep(d).await;
4344                        continue;
4345                    }
4346                    dlg.finished(false);
4347                    return Err(common::Error::HttpError(err));
4348                }
4349                Ok(res) => {
4350                    let (mut parts, body) = res.into_parts();
4351                    let mut body = common::Body::new(body);
4352                    if !parts.status.is_success() {
4353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4354                        let error = serde_json::from_str(&common::to_string(&bytes));
4355                        let response = common::to_response(parts, bytes.into());
4356
4357                        if let common::Retry::After(d) =
4358                            dlg.http_failure(&response, error.as_ref().ok())
4359                        {
4360                            sleep(d).await;
4361                            continue;
4362                        }
4363
4364                        dlg.finished(false);
4365
4366                        return Err(match error {
4367                            Ok(value) => common::Error::BadRequest(value),
4368                            _ => common::Error::Failure(response),
4369                        });
4370                    }
4371                    let response = {
4372                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4373                        let encoded = common::to_string(&bytes);
4374                        match serde_json::from_str(&encoded) {
4375                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4376                            Err(error) => {
4377                                dlg.response_json_decode_error(&encoded, &error);
4378                                return Err(common::Error::JsonDecodeError(
4379                                    encoded.to_string(),
4380                                    error,
4381                                ));
4382                            }
4383                        }
4384                    };
4385
4386                    dlg.finished(true);
4387                    return Ok(response);
4388                }
4389            }
4390        }
4391    }
4392
4393    ///
4394    /// Sets the *request* property to the given value.
4395    ///
4396    /// Even though the property as already been set when instantiating this call,
4397    /// we provide this method for API completeness.
4398    pub fn request(
4399        mut self,
4400        new_value: CloneAddressGroupItemsRequest,
4401    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C> {
4402        self._request = new_value;
4403        self
4404    }
4405    /// Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
4406    ///
4407    /// Sets the *address group* path property to the given value.
4408    ///
4409    /// Even though the property as already been set when instantiating this call,
4410    /// we provide this method for API completeness.
4411    pub fn address_group(
4412        mut self,
4413        new_value: &str,
4414    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C> {
4415        self._address_group = new_value.to_string();
4416        self
4417    }
4418    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4419    /// while executing the actual API request.
4420    ///
4421    /// ````text
4422    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4423    /// ````
4424    ///
4425    /// Sets the *delegate* property to the given value.
4426    pub fn delegate(
4427        mut self,
4428        new_value: &'a mut dyn common::Delegate,
4429    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C> {
4430        self._delegate = Some(new_value);
4431        self
4432    }
4433
4434    /// Set any additional parameter of the query string used in the request.
4435    /// It should be used to set parameters which are not yet available through their own
4436    /// setters.
4437    ///
4438    /// Please note that this method must not be used to set any of the known parameters
4439    /// which have their own setter method. If done anyway, the request will fail.
4440    ///
4441    /// # Additional Parameters
4442    ///
4443    /// * *$.xgafv* (query-string) - V1 error format.
4444    /// * *access_token* (query-string) - OAuth access token.
4445    /// * *alt* (query-string) - Data format for response.
4446    /// * *callback* (query-string) - JSONP
4447    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4448    /// * *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.
4449    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4450    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4451    /// * *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.
4452    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4453    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4454    pub fn param<T>(
4455        mut self,
4456        name: T,
4457        value: T,
4458    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C>
4459    where
4460        T: AsRef<str>,
4461    {
4462        self._additional_params
4463            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4464        self
4465    }
4466
4467    /// Identifies the authorization scope for the method you are building.
4468    ///
4469    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4470    /// [`Scope::CloudPlatform`].
4471    ///
4472    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4473    /// tokens for more than one scope.
4474    ///
4475    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4476    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4477    /// sufficient, a read-write scope will do as well.
4478    pub fn add_scope<St>(
4479        mut self,
4480        scope: St,
4481    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C>
4482    where
4483        St: AsRef<str>,
4484    {
4485        self._scopes.insert(String::from(scope.as_ref()));
4486        self
4487    }
4488    /// Identifies the authorization scope(s) for the method you are building.
4489    ///
4490    /// See [`Self::add_scope()`] for details.
4491    pub fn add_scopes<I, St>(
4492        mut self,
4493        scopes: I,
4494    ) -> OrganizationLocationAddressGroupCloneItemCall<'a, C>
4495    where
4496        I: IntoIterator<Item = St>,
4497        St: AsRef<str>,
4498    {
4499        self._scopes
4500            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4501        self
4502    }
4503
4504    /// Removes all scopes, and no default scope will be used either.
4505    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4506    /// for details).
4507    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupCloneItemCall<'a, C> {
4508        self._scopes.clear();
4509        self
4510    }
4511}
4512
4513/// Creates a new address group in a given project and location.
4514///
4515/// A builder for the *locations.addressGroups.create* method supported by a *organization* resource.
4516/// It is not used directly, but through a [`OrganizationMethods`] instance.
4517///
4518/// # Example
4519///
4520/// Instantiate a resource method builder
4521///
4522/// ```test_harness,no_run
4523/// # extern crate hyper;
4524/// # extern crate hyper_rustls;
4525/// # extern crate google_networksecurity1 as networksecurity1;
4526/// use networksecurity1::api::AddressGroup;
4527/// # async fn dox() {
4528/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4529///
4530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4531/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4532/// #     secret,
4533/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4534/// # ).build().await.unwrap();
4535///
4536/// # let client = hyper_util::client::legacy::Client::builder(
4537/// #     hyper_util::rt::TokioExecutor::new()
4538/// # )
4539/// # .build(
4540/// #     hyper_rustls::HttpsConnectorBuilder::new()
4541/// #         .with_native_roots()
4542/// #         .unwrap()
4543/// #         .https_or_http()
4544/// #         .enable_http1()
4545/// #         .build()
4546/// # );
4547/// # let mut hub = NetworkSecurity::new(client, auth);
4548/// // As the method needs a request, you would usually fill it with the desired information
4549/// // into the respective structure. Some of the parts shown here might not be applicable !
4550/// // Values shown here are possibly random and not representative !
4551/// let mut req = AddressGroup::default();
4552///
4553/// // You can configure optional parameters by calling the respective setters at will, and
4554/// // execute the final call using `doit()`.
4555/// // Values shown here are possibly random and not representative !
4556/// let result = hub.organizations().locations_address_groups_create(req, "parent")
4557///              .request_id("ipsum")
4558///              .address_group_id("gubergren")
4559///              .doit().await;
4560/// # }
4561/// ```
4562pub struct OrganizationLocationAddressGroupCreateCall<'a, C>
4563where
4564    C: 'a,
4565{
4566    hub: &'a NetworkSecurity<C>,
4567    _request: AddressGroup,
4568    _parent: String,
4569    _request_id: Option<String>,
4570    _address_group_id: Option<String>,
4571    _delegate: Option<&'a mut dyn common::Delegate>,
4572    _additional_params: HashMap<String, String>,
4573    _scopes: BTreeSet<String>,
4574}
4575
4576impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupCreateCall<'a, C> {}
4577
4578impl<'a, C> OrganizationLocationAddressGroupCreateCall<'a, C>
4579where
4580    C: common::Connector,
4581{
4582    /// Perform the operation you have build so far.
4583    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4584        use std::borrow::Cow;
4585        use std::io::{Read, Seek};
4586
4587        use common::{url::Params, ToParts};
4588        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4589
4590        let mut dd = common::DefaultDelegate;
4591        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4592        dlg.begin(common::MethodInfo {
4593            id: "networksecurity.organizations.locations.addressGroups.create",
4594            http_method: hyper::Method::POST,
4595        });
4596
4597        for &field in ["alt", "parent", "requestId", "addressGroupId"].iter() {
4598            if self._additional_params.contains_key(field) {
4599                dlg.finished(false);
4600                return Err(common::Error::FieldClash(field));
4601            }
4602        }
4603
4604        let mut params = Params::with_capacity(6 + self._additional_params.len());
4605        params.push("parent", self._parent);
4606        if let Some(value) = self._request_id.as_ref() {
4607            params.push("requestId", value);
4608        }
4609        if let Some(value) = self._address_group_id.as_ref() {
4610            params.push("addressGroupId", value);
4611        }
4612
4613        params.extend(self._additional_params.iter());
4614
4615        params.push("alt", "json");
4616        let mut url = self.hub._base_url.clone() + "v1/{+parent}/addressGroups";
4617        if self._scopes.is_empty() {
4618            self._scopes
4619                .insert(Scope::CloudPlatform.as_ref().to_string());
4620        }
4621
4622        #[allow(clippy::single_element_loop)]
4623        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4624            url = params.uri_replacement(url, param_name, find_this, true);
4625        }
4626        {
4627            let to_remove = ["parent"];
4628            params.remove_params(&to_remove);
4629        }
4630
4631        let url = params.parse_with_url(&url);
4632
4633        let mut json_mime_type = mime::APPLICATION_JSON;
4634        let mut request_value_reader = {
4635            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4636            common::remove_json_null_values(&mut value);
4637            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4638            serde_json::to_writer(&mut dst, &value).unwrap();
4639            dst
4640        };
4641        let request_size = request_value_reader
4642            .seek(std::io::SeekFrom::End(0))
4643            .unwrap();
4644        request_value_reader
4645            .seek(std::io::SeekFrom::Start(0))
4646            .unwrap();
4647
4648        loop {
4649            let token = match self
4650                .hub
4651                .auth
4652                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4653                .await
4654            {
4655                Ok(token) => token,
4656                Err(e) => match dlg.token(e) {
4657                    Ok(token) => token,
4658                    Err(e) => {
4659                        dlg.finished(false);
4660                        return Err(common::Error::MissingToken(e));
4661                    }
4662                },
4663            };
4664            request_value_reader
4665                .seek(std::io::SeekFrom::Start(0))
4666                .unwrap();
4667            let mut req_result = {
4668                let client = &self.hub.client;
4669                dlg.pre_request();
4670                let mut req_builder = hyper::Request::builder()
4671                    .method(hyper::Method::POST)
4672                    .uri(url.as_str())
4673                    .header(USER_AGENT, self.hub._user_agent.clone());
4674
4675                if let Some(token) = token.as_ref() {
4676                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4677                }
4678
4679                let request = req_builder
4680                    .header(CONTENT_TYPE, json_mime_type.to_string())
4681                    .header(CONTENT_LENGTH, request_size as u64)
4682                    .body(common::to_body(
4683                        request_value_reader.get_ref().clone().into(),
4684                    ));
4685
4686                client.request(request.unwrap()).await
4687            };
4688
4689            match req_result {
4690                Err(err) => {
4691                    if let common::Retry::After(d) = dlg.http_error(&err) {
4692                        sleep(d).await;
4693                        continue;
4694                    }
4695                    dlg.finished(false);
4696                    return Err(common::Error::HttpError(err));
4697                }
4698                Ok(res) => {
4699                    let (mut parts, body) = res.into_parts();
4700                    let mut body = common::Body::new(body);
4701                    if !parts.status.is_success() {
4702                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4703                        let error = serde_json::from_str(&common::to_string(&bytes));
4704                        let response = common::to_response(parts, bytes.into());
4705
4706                        if let common::Retry::After(d) =
4707                            dlg.http_failure(&response, error.as_ref().ok())
4708                        {
4709                            sleep(d).await;
4710                            continue;
4711                        }
4712
4713                        dlg.finished(false);
4714
4715                        return Err(match error {
4716                            Ok(value) => common::Error::BadRequest(value),
4717                            _ => common::Error::Failure(response),
4718                        });
4719                    }
4720                    let response = {
4721                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4722                        let encoded = common::to_string(&bytes);
4723                        match serde_json::from_str(&encoded) {
4724                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4725                            Err(error) => {
4726                                dlg.response_json_decode_error(&encoded, &error);
4727                                return Err(common::Error::JsonDecodeError(
4728                                    encoded.to_string(),
4729                                    error,
4730                                ));
4731                            }
4732                        }
4733                    };
4734
4735                    dlg.finished(true);
4736                    return Ok(response);
4737                }
4738            }
4739        }
4740    }
4741
4742    ///
4743    /// Sets the *request* property to the given value.
4744    ///
4745    /// Even though the property as already been set when instantiating this call,
4746    /// we provide this method for API completeness.
4747    pub fn request(
4748        mut self,
4749        new_value: AddressGroup,
4750    ) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
4751        self._request = new_value;
4752        self
4753    }
4754    /// Required. The parent resource of the AddressGroup. Must be in the format `projects/*/locations/{location}`.
4755    ///
4756    /// Sets the *parent* path property to the given value.
4757    ///
4758    /// Even though the property as already been set when instantiating this call,
4759    /// we provide this method for API completeness.
4760    pub fn parent(mut self, new_value: &str) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
4761        self._parent = new_value.to_string();
4762        self
4763    }
4764    /// Optional. 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).
4765    ///
4766    /// Sets the *request id* query property to the given value.
4767    pub fn request_id(
4768        mut self,
4769        new_value: &str,
4770    ) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
4771        self._request_id = Some(new_value.to_string());
4772        self
4773    }
4774    /// Required. Short name of the AddressGroup resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "authz_policy".
4775    ///
4776    /// Sets the *address group id* query property to the given value.
4777    pub fn address_group_id(
4778        mut self,
4779        new_value: &str,
4780    ) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
4781        self._address_group_id = Some(new_value.to_string());
4782        self
4783    }
4784    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4785    /// while executing the actual API request.
4786    ///
4787    /// ````text
4788    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4789    /// ````
4790    ///
4791    /// Sets the *delegate* property to the given value.
4792    pub fn delegate(
4793        mut self,
4794        new_value: &'a mut dyn common::Delegate,
4795    ) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
4796        self._delegate = Some(new_value);
4797        self
4798    }
4799
4800    /// Set any additional parameter of the query string used in the request.
4801    /// It should be used to set parameters which are not yet available through their own
4802    /// setters.
4803    ///
4804    /// Please note that this method must not be used to set any of the known parameters
4805    /// which have their own setter method. If done anyway, the request will fail.
4806    ///
4807    /// # Additional Parameters
4808    ///
4809    /// * *$.xgafv* (query-string) - V1 error format.
4810    /// * *access_token* (query-string) - OAuth access token.
4811    /// * *alt* (query-string) - Data format for response.
4812    /// * *callback* (query-string) - JSONP
4813    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4814    /// * *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.
4815    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4816    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4817    /// * *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.
4818    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4819    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4820    pub fn param<T>(
4821        mut self,
4822        name: T,
4823        value: T,
4824    ) -> OrganizationLocationAddressGroupCreateCall<'a, C>
4825    where
4826        T: AsRef<str>,
4827    {
4828        self._additional_params
4829            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4830        self
4831    }
4832
4833    /// Identifies the authorization scope for the method you are building.
4834    ///
4835    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4836    /// [`Scope::CloudPlatform`].
4837    ///
4838    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4839    /// tokens for more than one scope.
4840    ///
4841    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4842    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4843    /// sufficient, a read-write scope will do as well.
4844    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationAddressGroupCreateCall<'a, C>
4845    where
4846        St: AsRef<str>,
4847    {
4848        self._scopes.insert(String::from(scope.as_ref()));
4849        self
4850    }
4851    /// Identifies the authorization scope(s) for the method you are building.
4852    ///
4853    /// See [`Self::add_scope()`] for details.
4854    pub fn add_scopes<I, St>(
4855        mut self,
4856        scopes: I,
4857    ) -> OrganizationLocationAddressGroupCreateCall<'a, C>
4858    where
4859        I: IntoIterator<Item = St>,
4860        St: AsRef<str>,
4861    {
4862        self._scopes
4863            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4864        self
4865    }
4866
4867    /// Removes all scopes, and no default scope will be used either.
4868    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4869    /// for details).
4870    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupCreateCall<'a, C> {
4871        self._scopes.clear();
4872        self
4873    }
4874}
4875
4876/// Deletes an address group.
4877///
4878/// A builder for the *locations.addressGroups.delete* method supported by a *organization* resource.
4879/// It is not used directly, but through a [`OrganizationMethods`] instance.
4880///
4881/// # Example
4882///
4883/// Instantiate a resource method builder
4884///
4885/// ```test_harness,no_run
4886/// # extern crate hyper;
4887/// # extern crate hyper_rustls;
4888/// # extern crate google_networksecurity1 as networksecurity1;
4889/// # async fn dox() {
4890/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4891///
4892/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4893/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4894/// #     secret,
4895/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4896/// # ).build().await.unwrap();
4897///
4898/// # let client = hyper_util::client::legacy::Client::builder(
4899/// #     hyper_util::rt::TokioExecutor::new()
4900/// # )
4901/// # .build(
4902/// #     hyper_rustls::HttpsConnectorBuilder::new()
4903/// #         .with_native_roots()
4904/// #         .unwrap()
4905/// #         .https_or_http()
4906/// #         .enable_http1()
4907/// #         .build()
4908/// # );
4909/// # let mut hub = NetworkSecurity::new(client, auth);
4910/// // You can configure optional parameters by calling the respective setters at will, and
4911/// // execute the final call using `doit()`.
4912/// // Values shown here are possibly random and not representative !
4913/// let result = hub.organizations().locations_address_groups_delete("name")
4914///              .request_id("gubergren")
4915///              .doit().await;
4916/// # }
4917/// ```
4918pub struct OrganizationLocationAddressGroupDeleteCall<'a, C>
4919where
4920    C: 'a,
4921{
4922    hub: &'a NetworkSecurity<C>,
4923    _name: String,
4924    _request_id: Option<String>,
4925    _delegate: Option<&'a mut dyn common::Delegate>,
4926    _additional_params: HashMap<String, String>,
4927    _scopes: BTreeSet<String>,
4928}
4929
4930impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupDeleteCall<'a, C> {}
4931
4932impl<'a, C> OrganizationLocationAddressGroupDeleteCall<'a, C>
4933where
4934    C: common::Connector,
4935{
4936    /// Perform the operation you have build so far.
4937    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4938        use std::borrow::Cow;
4939        use std::io::{Read, Seek};
4940
4941        use common::{url::Params, ToParts};
4942        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4943
4944        let mut dd = common::DefaultDelegate;
4945        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4946        dlg.begin(common::MethodInfo {
4947            id: "networksecurity.organizations.locations.addressGroups.delete",
4948            http_method: hyper::Method::DELETE,
4949        });
4950
4951        for &field in ["alt", "name", "requestId"].iter() {
4952            if self._additional_params.contains_key(field) {
4953                dlg.finished(false);
4954                return Err(common::Error::FieldClash(field));
4955            }
4956        }
4957
4958        let mut params = Params::with_capacity(4 + self._additional_params.len());
4959        params.push("name", self._name);
4960        if let Some(value) = self._request_id.as_ref() {
4961            params.push("requestId", value);
4962        }
4963
4964        params.extend(self._additional_params.iter());
4965
4966        params.push("alt", "json");
4967        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4968        if self._scopes.is_empty() {
4969            self._scopes
4970                .insert(Scope::CloudPlatform.as_ref().to_string());
4971        }
4972
4973        #[allow(clippy::single_element_loop)]
4974        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4975            url = params.uri_replacement(url, param_name, find_this, true);
4976        }
4977        {
4978            let to_remove = ["name"];
4979            params.remove_params(&to_remove);
4980        }
4981
4982        let url = params.parse_with_url(&url);
4983
4984        loop {
4985            let token = match self
4986                .hub
4987                .auth
4988                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4989                .await
4990            {
4991                Ok(token) => token,
4992                Err(e) => match dlg.token(e) {
4993                    Ok(token) => token,
4994                    Err(e) => {
4995                        dlg.finished(false);
4996                        return Err(common::Error::MissingToken(e));
4997                    }
4998                },
4999            };
5000            let mut req_result = {
5001                let client = &self.hub.client;
5002                dlg.pre_request();
5003                let mut req_builder = hyper::Request::builder()
5004                    .method(hyper::Method::DELETE)
5005                    .uri(url.as_str())
5006                    .header(USER_AGENT, self.hub._user_agent.clone());
5007
5008                if let Some(token) = token.as_ref() {
5009                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5010                }
5011
5012                let request = req_builder
5013                    .header(CONTENT_LENGTH, 0_u64)
5014                    .body(common::to_body::<String>(None));
5015
5016                client.request(request.unwrap()).await
5017            };
5018
5019            match req_result {
5020                Err(err) => {
5021                    if let common::Retry::After(d) = dlg.http_error(&err) {
5022                        sleep(d).await;
5023                        continue;
5024                    }
5025                    dlg.finished(false);
5026                    return Err(common::Error::HttpError(err));
5027                }
5028                Ok(res) => {
5029                    let (mut parts, body) = res.into_parts();
5030                    let mut body = common::Body::new(body);
5031                    if !parts.status.is_success() {
5032                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5033                        let error = serde_json::from_str(&common::to_string(&bytes));
5034                        let response = common::to_response(parts, bytes.into());
5035
5036                        if let common::Retry::After(d) =
5037                            dlg.http_failure(&response, error.as_ref().ok())
5038                        {
5039                            sleep(d).await;
5040                            continue;
5041                        }
5042
5043                        dlg.finished(false);
5044
5045                        return Err(match error {
5046                            Ok(value) => common::Error::BadRequest(value),
5047                            _ => common::Error::Failure(response),
5048                        });
5049                    }
5050                    let response = {
5051                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5052                        let encoded = common::to_string(&bytes);
5053                        match serde_json::from_str(&encoded) {
5054                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5055                            Err(error) => {
5056                                dlg.response_json_decode_error(&encoded, &error);
5057                                return Err(common::Error::JsonDecodeError(
5058                                    encoded.to_string(),
5059                                    error,
5060                                ));
5061                            }
5062                        }
5063                    };
5064
5065                    dlg.finished(true);
5066                    return Ok(response);
5067                }
5068            }
5069        }
5070    }
5071
5072    /// Required. A name of the AddressGroup to delete. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
5073    ///
5074    /// Sets the *name* path property to the given value.
5075    ///
5076    /// Even though the property as already been set when instantiating this call,
5077    /// we provide this method for API completeness.
5078    pub fn name(mut self, new_value: &str) -> OrganizationLocationAddressGroupDeleteCall<'a, C> {
5079        self._name = new_value.to_string();
5080        self
5081    }
5082    /// Optional. 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).
5083    ///
5084    /// Sets the *request id* query property to the given value.
5085    pub fn request_id(
5086        mut self,
5087        new_value: &str,
5088    ) -> OrganizationLocationAddressGroupDeleteCall<'a, C> {
5089        self._request_id = Some(new_value.to_string());
5090        self
5091    }
5092    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5093    /// while executing the actual API request.
5094    ///
5095    /// ````text
5096    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5097    /// ````
5098    ///
5099    /// Sets the *delegate* property to the given value.
5100    pub fn delegate(
5101        mut self,
5102        new_value: &'a mut dyn common::Delegate,
5103    ) -> OrganizationLocationAddressGroupDeleteCall<'a, C> {
5104        self._delegate = Some(new_value);
5105        self
5106    }
5107
5108    /// Set any additional parameter of the query string used in the request.
5109    /// It should be used to set parameters which are not yet available through their own
5110    /// setters.
5111    ///
5112    /// Please note that this method must not be used to set any of the known parameters
5113    /// which have their own setter method. If done anyway, the request will fail.
5114    ///
5115    /// # Additional Parameters
5116    ///
5117    /// * *$.xgafv* (query-string) - V1 error format.
5118    /// * *access_token* (query-string) - OAuth access token.
5119    /// * *alt* (query-string) - Data format for response.
5120    /// * *callback* (query-string) - JSONP
5121    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5122    /// * *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.
5123    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5124    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5125    /// * *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.
5126    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5127    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5128    pub fn param<T>(
5129        mut self,
5130        name: T,
5131        value: T,
5132    ) -> OrganizationLocationAddressGroupDeleteCall<'a, C>
5133    where
5134        T: AsRef<str>,
5135    {
5136        self._additional_params
5137            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5138        self
5139    }
5140
5141    /// Identifies the authorization scope for the method you are building.
5142    ///
5143    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5144    /// [`Scope::CloudPlatform`].
5145    ///
5146    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5147    /// tokens for more than one scope.
5148    ///
5149    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5150    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5151    /// sufficient, a read-write scope will do as well.
5152    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationAddressGroupDeleteCall<'a, C>
5153    where
5154        St: AsRef<str>,
5155    {
5156        self._scopes.insert(String::from(scope.as_ref()));
5157        self
5158    }
5159    /// Identifies the authorization scope(s) for the method you are building.
5160    ///
5161    /// See [`Self::add_scope()`] for details.
5162    pub fn add_scopes<I, St>(
5163        mut self,
5164        scopes: I,
5165    ) -> OrganizationLocationAddressGroupDeleteCall<'a, C>
5166    where
5167        I: IntoIterator<Item = St>,
5168        St: AsRef<str>,
5169    {
5170        self._scopes
5171            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5172        self
5173    }
5174
5175    /// Removes all scopes, and no default scope will be used either.
5176    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5177    /// for details).
5178    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupDeleteCall<'a, C> {
5179        self._scopes.clear();
5180        self
5181    }
5182}
5183
5184/// Gets details of a single address group.
5185///
5186/// A builder for the *locations.addressGroups.get* method supported by a *organization* resource.
5187/// It is not used directly, but through a [`OrganizationMethods`] instance.
5188///
5189/// # Example
5190///
5191/// Instantiate a resource method builder
5192///
5193/// ```test_harness,no_run
5194/// # extern crate hyper;
5195/// # extern crate hyper_rustls;
5196/// # extern crate google_networksecurity1 as networksecurity1;
5197/// # async fn dox() {
5198/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5199///
5200/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5201/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5202/// #     secret,
5203/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5204/// # ).build().await.unwrap();
5205///
5206/// # let client = hyper_util::client::legacy::Client::builder(
5207/// #     hyper_util::rt::TokioExecutor::new()
5208/// # )
5209/// # .build(
5210/// #     hyper_rustls::HttpsConnectorBuilder::new()
5211/// #         .with_native_roots()
5212/// #         .unwrap()
5213/// #         .https_or_http()
5214/// #         .enable_http1()
5215/// #         .build()
5216/// # );
5217/// # let mut hub = NetworkSecurity::new(client, auth);
5218/// // You can configure optional parameters by calling the respective setters at will, and
5219/// // execute the final call using `doit()`.
5220/// // Values shown here are possibly random and not representative !
5221/// let result = hub.organizations().locations_address_groups_get("name")
5222///              .doit().await;
5223/// # }
5224/// ```
5225pub struct OrganizationLocationAddressGroupGetCall<'a, C>
5226where
5227    C: 'a,
5228{
5229    hub: &'a NetworkSecurity<C>,
5230    _name: String,
5231    _delegate: Option<&'a mut dyn common::Delegate>,
5232    _additional_params: HashMap<String, String>,
5233    _scopes: BTreeSet<String>,
5234}
5235
5236impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupGetCall<'a, C> {}
5237
5238impl<'a, C> OrganizationLocationAddressGroupGetCall<'a, C>
5239where
5240    C: common::Connector,
5241{
5242    /// Perform the operation you have build so far.
5243    pub async fn doit(mut self) -> common::Result<(common::Response, AddressGroup)> {
5244        use std::borrow::Cow;
5245        use std::io::{Read, Seek};
5246
5247        use common::{url::Params, ToParts};
5248        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5249
5250        let mut dd = common::DefaultDelegate;
5251        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5252        dlg.begin(common::MethodInfo {
5253            id: "networksecurity.organizations.locations.addressGroups.get",
5254            http_method: hyper::Method::GET,
5255        });
5256
5257        for &field in ["alt", "name"].iter() {
5258            if self._additional_params.contains_key(field) {
5259                dlg.finished(false);
5260                return Err(common::Error::FieldClash(field));
5261            }
5262        }
5263
5264        let mut params = Params::with_capacity(3 + self._additional_params.len());
5265        params.push("name", self._name);
5266
5267        params.extend(self._additional_params.iter());
5268
5269        params.push("alt", "json");
5270        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5271        if self._scopes.is_empty() {
5272            self._scopes
5273                .insert(Scope::CloudPlatform.as_ref().to_string());
5274        }
5275
5276        #[allow(clippy::single_element_loop)]
5277        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5278            url = params.uri_replacement(url, param_name, find_this, true);
5279        }
5280        {
5281            let to_remove = ["name"];
5282            params.remove_params(&to_remove);
5283        }
5284
5285        let url = params.parse_with_url(&url);
5286
5287        loop {
5288            let token = match self
5289                .hub
5290                .auth
5291                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5292                .await
5293            {
5294                Ok(token) => token,
5295                Err(e) => match dlg.token(e) {
5296                    Ok(token) => token,
5297                    Err(e) => {
5298                        dlg.finished(false);
5299                        return Err(common::Error::MissingToken(e));
5300                    }
5301                },
5302            };
5303            let mut req_result = {
5304                let client = &self.hub.client;
5305                dlg.pre_request();
5306                let mut req_builder = hyper::Request::builder()
5307                    .method(hyper::Method::GET)
5308                    .uri(url.as_str())
5309                    .header(USER_AGENT, self.hub._user_agent.clone());
5310
5311                if let Some(token) = token.as_ref() {
5312                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5313                }
5314
5315                let request = req_builder
5316                    .header(CONTENT_LENGTH, 0_u64)
5317                    .body(common::to_body::<String>(None));
5318
5319                client.request(request.unwrap()).await
5320            };
5321
5322            match req_result {
5323                Err(err) => {
5324                    if let common::Retry::After(d) = dlg.http_error(&err) {
5325                        sleep(d).await;
5326                        continue;
5327                    }
5328                    dlg.finished(false);
5329                    return Err(common::Error::HttpError(err));
5330                }
5331                Ok(res) => {
5332                    let (mut parts, body) = res.into_parts();
5333                    let mut body = common::Body::new(body);
5334                    if !parts.status.is_success() {
5335                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5336                        let error = serde_json::from_str(&common::to_string(&bytes));
5337                        let response = common::to_response(parts, bytes.into());
5338
5339                        if let common::Retry::After(d) =
5340                            dlg.http_failure(&response, error.as_ref().ok())
5341                        {
5342                            sleep(d).await;
5343                            continue;
5344                        }
5345
5346                        dlg.finished(false);
5347
5348                        return Err(match error {
5349                            Ok(value) => common::Error::BadRequest(value),
5350                            _ => common::Error::Failure(response),
5351                        });
5352                    }
5353                    let response = {
5354                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5355                        let encoded = common::to_string(&bytes);
5356                        match serde_json::from_str(&encoded) {
5357                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5358                            Err(error) => {
5359                                dlg.response_json_decode_error(&encoded, &error);
5360                                return Err(common::Error::JsonDecodeError(
5361                                    encoded.to_string(),
5362                                    error,
5363                                ));
5364                            }
5365                        }
5366                    };
5367
5368                    dlg.finished(true);
5369                    return Ok(response);
5370                }
5371            }
5372        }
5373    }
5374
5375    /// Required. A name of the AddressGroup to get. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
5376    ///
5377    /// Sets the *name* path property to the given value.
5378    ///
5379    /// Even though the property as already been set when instantiating this call,
5380    /// we provide this method for API completeness.
5381    pub fn name(mut self, new_value: &str) -> OrganizationLocationAddressGroupGetCall<'a, C> {
5382        self._name = new_value.to_string();
5383        self
5384    }
5385    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5386    /// while executing the actual API request.
5387    ///
5388    /// ````text
5389    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5390    /// ````
5391    ///
5392    /// Sets the *delegate* property to the given value.
5393    pub fn delegate(
5394        mut self,
5395        new_value: &'a mut dyn common::Delegate,
5396    ) -> OrganizationLocationAddressGroupGetCall<'a, C> {
5397        self._delegate = Some(new_value);
5398        self
5399    }
5400
5401    /// Set any additional parameter of the query string used in the request.
5402    /// It should be used to set parameters which are not yet available through their own
5403    /// setters.
5404    ///
5405    /// Please note that this method must not be used to set any of the known parameters
5406    /// which have their own setter method. If done anyway, the request will fail.
5407    ///
5408    /// # Additional Parameters
5409    ///
5410    /// * *$.xgafv* (query-string) - V1 error format.
5411    /// * *access_token* (query-string) - OAuth access token.
5412    /// * *alt* (query-string) - Data format for response.
5413    /// * *callback* (query-string) - JSONP
5414    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5415    /// * *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.
5416    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5417    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5418    /// * *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.
5419    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5420    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5421    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationAddressGroupGetCall<'a, C>
5422    where
5423        T: AsRef<str>,
5424    {
5425        self._additional_params
5426            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5427        self
5428    }
5429
5430    /// Identifies the authorization scope for the method you are building.
5431    ///
5432    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5433    /// [`Scope::CloudPlatform`].
5434    ///
5435    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5436    /// tokens for more than one scope.
5437    ///
5438    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5439    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5440    /// sufficient, a read-write scope will do as well.
5441    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationAddressGroupGetCall<'a, C>
5442    where
5443        St: AsRef<str>,
5444    {
5445        self._scopes.insert(String::from(scope.as_ref()));
5446        self
5447    }
5448    /// Identifies the authorization scope(s) for the method you are building.
5449    ///
5450    /// See [`Self::add_scope()`] for details.
5451    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationAddressGroupGetCall<'a, C>
5452    where
5453        I: IntoIterator<Item = St>,
5454        St: AsRef<str>,
5455    {
5456        self._scopes
5457            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5458        self
5459    }
5460
5461    /// Removes all scopes, and no default scope will be used either.
5462    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5463    /// for details).
5464    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupGetCall<'a, C> {
5465        self._scopes.clear();
5466        self
5467    }
5468}
5469
5470/// Lists address groups in a given project and location.
5471///
5472/// A builder for the *locations.addressGroups.list* method supported by a *organization* resource.
5473/// It is not used directly, but through a [`OrganizationMethods`] instance.
5474///
5475/// # Example
5476///
5477/// Instantiate a resource method builder
5478///
5479/// ```test_harness,no_run
5480/// # extern crate hyper;
5481/// # extern crate hyper_rustls;
5482/// # extern crate google_networksecurity1 as networksecurity1;
5483/// # async fn dox() {
5484/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5485///
5486/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5487/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5488/// #     secret,
5489/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5490/// # ).build().await.unwrap();
5491///
5492/// # let client = hyper_util::client::legacy::Client::builder(
5493/// #     hyper_util::rt::TokioExecutor::new()
5494/// # )
5495/// # .build(
5496/// #     hyper_rustls::HttpsConnectorBuilder::new()
5497/// #         .with_native_roots()
5498/// #         .unwrap()
5499/// #         .https_or_http()
5500/// #         .enable_http1()
5501/// #         .build()
5502/// # );
5503/// # let mut hub = NetworkSecurity::new(client, auth);
5504/// // You can configure optional parameters by calling the respective setters at will, and
5505/// // execute the final call using `doit()`.
5506/// // Values shown here are possibly random and not representative !
5507/// let result = hub.organizations().locations_address_groups_list("parent")
5508///              .page_token("ea")
5509///              .page_size(-55)
5510///              .doit().await;
5511/// # }
5512/// ```
5513pub struct OrganizationLocationAddressGroupListCall<'a, C>
5514where
5515    C: 'a,
5516{
5517    hub: &'a NetworkSecurity<C>,
5518    _parent: String,
5519    _page_token: Option<String>,
5520    _page_size: Option<i32>,
5521    _delegate: Option<&'a mut dyn common::Delegate>,
5522    _additional_params: HashMap<String, String>,
5523    _scopes: BTreeSet<String>,
5524}
5525
5526impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupListCall<'a, C> {}
5527
5528impl<'a, C> OrganizationLocationAddressGroupListCall<'a, C>
5529where
5530    C: common::Connector,
5531{
5532    /// Perform the operation you have build so far.
5533    pub async fn doit(mut self) -> common::Result<(common::Response, ListAddressGroupsResponse)> {
5534        use std::borrow::Cow;
5535        use std::io::{Read, Seek};
5536
5537        use common::{url::Params, ToParts};
5538        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5539
5540        let mut dd = common::DefaultDelegate;
5541        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5542        dlg.begin(common::MethodInfo {
5543            id: "networksecurity.organizations.locations.addressGroups.list",
5544            http_method: hyper::Method::GET,
5545        });
5546
5547        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5548            if self._additional_params.contains_key(field) {
5549                dlg.finished(false);
5550                return Err(common::Error::FieldClash(field));
5551            }
5552        }
5553
5554        let mut params = Params::with_capacity(5 + self._additional_params.len());
5555        params.push("parent", self._parent);
5556        if let Some(value) = self._page_token.as_ref() {
5557            params.push("pageToken", value);
5558        }
5559        if let Some(value) = self._page_size.as_ref() {
5560            params.push("pageSize", value.to_string());
5561        }
5562
5563        params.extend(self._additional_params.iter());
5564
5565        params.push("alt", "json");
5566        let mut url = self.hub._base_url.clone() + "v1/{+parent}/addressGroups";
5567        if self._scopes.is_empty() {
5568            self._scopes
5569                .insert(Scope::CloudPlatform.as_ref().to_string());
5570        }
5571
5572        #[allow(clippy::single_element_loop)]
5573        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5574            url = params.uri_replacement(url, param_name, find_this, true);
5575        }
5576        {
5577            let to_remove = ["parent"];
5578            params.remove_params(&to_remove);
5579        }
5580
5581        let url = params.parse_with_url(&url);
5582
5583        loop {
5584            let token = match self
5585                .hub
5586                .auth
5587                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5588                .await
5589            {
5590                Ok(token) => token,
5591                Err(e) => match dlg.token(e) {
5592                    Ok(token) => token,
5593                    Err(e) => {
5594                        dlg.finished(false);
5595                        return Err(common::Error::MissingToken(e));
5596                    }
5597                },
5598            };
5599            let mut req_result = {
5600                let client = &self.hub.client;
5601                dlg.pre_request();
5602                let mut req_builder = hyper::Request::builder()
5603                    .method(hyper::Method::GET)
5604                    .uri(url.as_str())
5605                    .header(USER_AGENT, self.hub._user_agent.clone());
5606
5607                if let Some(token) = token.as_ref() {
5608                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5609                }
5610
5611                let request = req_builder
5612                    .header(CONTENT_LENGTH, 0_u64)
5613                    .body(common::to_body::<String>(None));
5614
5615                client.request(request.unwrap()).await
5616            };
5617
5618            match req_result {
5619                Err(err) => {
5620                    if let common::Retry::After(d) = dlg.http_error(&err) {
5621                        sleep(d).await;
5622                        continue;
5623                    }
5624                    dlg.finished(false);
5625                    return Err(common::Error::HttpError(err));
5626                }
5627                Ok(res) => {
5628                    let (mut parts, body) = res.into_parts();
5629                    let mut body = common::Body::new(body);
5630                    if !parts.status.is_success() {
5631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5632                        let error = serde_json::from_str(&common::to_string(&bytes));
5633                        let response = common::to_response(parts, bytes.into());
5634
5635                        if let common::Retry::After(d) =
5636                            dlg.http_failure(&response, error.as_ref().ok())
5637                        {
5638                            sleep(d).await;
5639                            continue;
5640                        }
5641
5642                        dlg.finished(false);
5643
5644                        return Err(match error {
5645                            Ok(value) => common::Error::BadRequest(value),
5646                            _ => common::Error::Failure(response),
5647                        });
5648                    }
5649                    let response = {
5650                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5651                        let encoded = common::to_string(&bytes);
5652                        match serde_json::from_str(&encoded) {
5653                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5654                            Err(error) => {
5655                                dlg.response_json_decode_error(&encoded, &error);
5656                                return Err(common::Error::JsonDecodeError(
5657                                    encoded.to_string(),
5658                                    error,
5659                                ));
5660                            }
5661                        }
5662                    };
5663
5664                    dlg.finished(true);
5665                    return Ok(response);
5666                }
5667            }
5668        }
5669    }
5670
5671    /// Required. The project and location from which the AddressGroups should be listed, specified in the format `projects/*/locations/{location}`.
5672    ///
5673    /// Sets the *parent* path property to the given value.
5674    ///
5675    /// Even though the property as already been set when instantiating this call,
5676    /// we provide this method for API completeness.
5677    pub fn parent(mut self, new_value: &str) -> OrganizationLocationAddressGroupListCall<'a, C> {
5678        self._parent = new_value.to_string();
5679        self
5680    }
5681    /// The value returned by the last `ListAddressGroupsResponse` Indicates that this is a continuation of a prior `ListAddressGroups` call, and that the system should return the next page of data.
5682    ///
5683    /// Sets the *page token* query property to the given value.
5684    pub fn page_token(
5685        mut self,
5686        new_value: &str,
5687    ) -> OrganizationLocationAddressGroupListCall<'a, C> {
5688        self._page_token = Some(new_value.to_string());
5689        self
5690    }
5691    /// Maximum number of AddressGroups to return per call.
5692    ///
5693    /// Sets the *page size* query property to the given value.
5694    pub fn page_size(mut self, new_value: i32) -> OrganizationLocationAddressGroupListCall<'a, C> {
5695        self._page_size = Some(new_value);
5696        self
5697    }
5698    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5699    /// while executing the actual API request.
5700    ///
5701    /// ````text
5702    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5703    /// ````
5704    ///
5705    /// Sets the *delegate* property to the given value.
5706    pub fn delegate(
5707        mut self,
5708        new_value: &'a mut dyn common::Delegate,
5709    ) -> OrganizationLocationAddressGroupListCall<'a, C> {
5710        self._delegate = Some(new_value);
5711        self
5712    }
5713
5714    /// Set any additional parameter of the query string used in the request.
5715    /// It should be used to set parameters which are not yet available through their own
5716    /// setters.
5717    ///
5718    /// Please note that this method must not be used to set any of the known parameters
5719    /// which have their own setter method. If done anyway, the request will fail.
5720    ///
5721    /// # Additional Parameters
5722    ///
5723    /// * *$.xgafv* (query-string) - V1 error format.
5724    /// * *access_token* (query-string) - OAuth access token.
5725    /// * *alt* (query-string) - Data format for response.
5726    /// * *callback* (query-string) - JSONP
5727    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5728    /// * *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.
5729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5730    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5731    /// * *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.
5732    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5733    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5734    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationAddressGroupListCall<'a, C>
5735    where
5736        T: AsRef<str>,
5737    {
5738        self._additional_params
5739            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5740        self
5741    }
5742
5743    /// Identifies the authorization scope for the method you are building.
5744    ///
5745    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5746    /// [`Scope::CloudPlatform`].
5747    ///
5748    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5749    /// tokens for more than one scope.
5750    ///
5751    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5752    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5753    /// sufficient, a read-write scope will do as well.
5754    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationAddressGroupListCall<'a, C>
5755    where
5756        St: AsRef<str>,
5757    {
5758        self._scopes.insert(String::from(scope.as_ref()));
5759        self
5760    }
5761    /// Identifies the authorization scope(s) for the method you are building.
5762    ///
5763    /// See [`Self::add_scope()`] for details.
5764    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationAddressGroupListCall<'a, C>
5765    where
5766        I: IntoIterator<Item = St>,
5767        St: AsRef<str>,
5768    {
5769        self._scopes
5770            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5771        self
5772    }
5773
5774    /// Removes all scopes, and no default scope will be used either.
5775    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5776    /// for details).
5777    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupListCall<'a, C> {
5778        self._scopes.clear();
5779        self
5780    }
5781}
5782
5783/// Lists references of an address group.
5784///
5785/// A builder for the *locations.addressGroups.listReferences* method supported by a *organization* resource.
5786/// It is not used directly, but through a [`OrganizationMethods`] instance.
5787///
5788/// # Example
5789///
5790/// Instantiate a resource method builder
5791///
5792/// ```test_harness,no_run
5793/// # extern crate hyper;
5794/// # extern crate hyper_rustls;
5795/// # extern crate google_networksecurity1 as networksecurity1;
5796/// # async fn dox() {
5797/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5798///
5799/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5801/// #     secret,
5802/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5803/// # ).build().await.unwrap();
5804///
5805/// # let client = hyper_util::client::legacy::Client::builder(
5806/// #     hyper_util::rt::TokioExecutor::new()
5807/// # )
5808/// # .build(
5809/// #     hyper_rustls::HttpsConnectorBuilder::new()
5810/// #         .with_native_roots()
5811/// #         .unwrap()
5812/// #         .https_or_http()
5813/// #         .enable_http1()
5814/// #         .build()
5815/// # );
5816/// # let mut hub = NetworkSecurity::new(client, auth);
5817/// // You can configure optional parameters by calling the respective setters at will, and
5818/// // execute the final call using `doit()`.
5819/// // Values shown here are possibly random and not representative !
5820/// let result = hub.organizations().locations_address_groups_list_references("addressGroup")
5821///              .page_token("amet")
5822///              .page_size(-20)
5823///              .doit().await;
5824/// # }
5825/// ```
5826pub struct OrganizationLocationAddressGroupListReferenceCall<'a, C>
5827where
5828    C: 'a,
5829{
5830    hub: &'a NetworkSecurity<C>,
5831    _address_group: String,
5832    _page_token: Option<String>,
5833    _page_size: Option<i32>,
5834    _delegate: Option<&'a mut dyn common::Delegate>,
5835    _additional_params: HashMap<String, String>,
5836    _scopes: BTreeSet<String>,
5837}
5838
5839impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupListReferenceCall<'a, C> {}
5840
5841impl<'a, C> OrganizationLocationAddressGroupListReferenceCall<'a, C>
5842where
5843    C: common::Connector,
5844{
5845    /// Perform the operation you have build so far.
5846    pub async fn doit(
5847        mut self,
5848    ) -> common::Result<(common::Response, ListAddressGroupReferencesResponse)> {
5849        use std::borrow::Cow;
5850        use std::io::{Read, Seek};
5851
5852        use common::{url::Params, ToParts};
5853        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5854
5855        let mut dd = common::DefaultDelegate;
5856        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5857        dlg.begin(common::MethodInfo {
5858            id: "networksecurity.organizations.locations.addressGroups.listReferences",
5859            http_method: hyper::Method::GET,
5860        });
5861
5862        for &field in ["alt", "addressGroup", "pageToken", "pageSize"].iter() {
5863            if self._additional_params.contains_key(field) {
5864                dlg.finished(false);
5865                return Err(common::Error::FieldClash(field));
5866            }
5867        }
5868
5869        let mut params = Params::with_capacity(5 + self._additional_params.len());
5870        params.push("addressGroup", self._address_group);
5871        if let Some(value) = self._page_token.as_ref() {
5872            params.push("pageToken", value);
5873        }
5874        if let Some(value) = self._page_size.as_ref() {
5875            params.push("pageSize", value.to_string());
5876        }
5877
5878        params.extend(self._additional_params.iter());
5879
5880        params.push("alt", "json");
5881        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:listReferences";
5882        if self._scopes.is_empty() {
5883            self._scopes
5884                .insert(Scope::CloudPlatform.as_ref().to_string());
5885        }
5886
5887        #[allow(clippy::single_element_loop)]
5888        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
5889            url = params.uri_replacement(url, param_name, find_this, true);
5890        }
5891        {
5892            let to_remove = ["addressGroup"];
5893            params.remove_params(&to_remove);
5894        }
5895
5896        let url = params.parse_with_url(&url);
5897
5898        loop {
5899            let token = match self
5900                .hub
5901                .auth
5902                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5903                .await
5904            {
5905                Ok(token) => token,
5906                Err(e) => match dlg.token(e) {
5907                    Ok(token) => token,
5908                    Err(e) => {
5909                        dlg.finished(false);
5910                        return Err(common::Error::MissingToken(e));
5911                    }
5912                },
5913            };
5914            let mut req_result = {
5915                let client = &self.hub.client;
5916                dlg.pre_request();
5917                let mut req_builder = hyper::Request::builder()
5918                    .method(hyper::Method::GET)
5919                    .uri(url.as_str())
5920                    .header(USER_AGENT, self.hub._user_agent.clone());
5921
5922                if let Some(token) = token.as_ref() {
5923                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5924                }
5925
5926                let request = req_builder
5927                    .header(CONTENT_LENGTH, 0_u64)
5928                    .body(common::to_body::<String>(None));
5929
5930                client.request(request.unwrap()).await
5931            };
5932
5933            match req_result {
5934                Err(err) => {
5935                    if let common::Retry::After(d) = dlg.http_error(&err) {
5936                        sleep(d).await;
5937                        continue;
5938                    }
5939                    dlg.finished(false);
5940                    return Err(common::Error::HttpError(err));
5941                }
5942                Ok(res) => {
5943                    let (mut parts, body) = res.into_parts();
5944                    let mut body = common::Body::new(body);
5945                    if !parts.status.is_success() {
5946                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5947                        let error = serde_json::from_str(&common::to_string(&bytes));
5948                        let response = common::to_response(parts, bytes.into());
5949
5950                        if let common::Retry::After(d) =
5951                            dlg.http_failure(&response, error.as_ref().ok())
5952                        {
5953                            sleep(d).await;
5954                            continue;
5955                        }
5956
5957                        dlg.finished(false);
5958
5959                        return Err(match error {
5960                            Ok(value) => common::Error::BadRequest(value),
5961                            _ => common::Error::Failure(response),
5962                        });
5963                    }
5964                    let response = {
5965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5966                        let encoded = common::to_string(&bytes);
5967                        match serde_json::from_str(&encoded) {
5968                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5969                            Err(error) => {
5970                                dlg.response_json_decode_error(&encoded, &error);
5971                                return Err(common::Error::JsonDecodeError(
5972                                    encoded.to_string(),
5973                                    error,
5974                                ));
5975                            }
5976                        }
5977                    };
5978
5979                    dlg.finished(true);
5980                    return Ok(response);
5981                }
5982            }
5983        }
5984    }
5985
5986    /// Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
5987    ///
5988    /// Sets the *address group* path property to the given value.
5989    ///
5990    /// Even though the property as already been set when instantiating this call,
5991    /// we provide this method for API completeness.
5992    pub fn address_group(
5993        mut self,
5994        new_value: &str,
5995    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C> {
5996        self._address_group = new_value.to_string();
5997        self
5998    }
5999    /// The next_page_token value returned from a previous List request, if any.
6000    ///
6001    /// Sets the *page token* query property to the given value.
6002    pub fn page_token(
6003        mut self,
6004        new_value: &str,
6005    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C> {
6006        self._page_token = Some(new_value.to_string());
6007        self
6008    }
6009    /// The maximum number of references to return. If unspecified, server will pick an appropriate default. Server may return fewer items than requested. A caller should only rely on response's next_page_token to determine if there are more AddressGroupUsers left to be queried.
6010    ///
6011    /// Sets the *page size* query property to the given value.
6012    pub fn page_size(
6013        mut self,
6014        new_value: i32,
6015    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C> {
6016        self._page_size = Some(new_value);
6017        self
6018    }
6019    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6020    /// while executing the actual API request.
6021    ///
6022    /// ````text
6023    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6024    /// ````
6025    ///
6026    /// Sets the *delegate* property to the given value.
6027    pub fn delegate(
6028        mut self,
6029        new_value: &'a mut dyn common::Delegate,
6030    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C> {
6031        self._delegate = Some(new_value);
6032        self
6033    }
6034
6035    /// Set any additional parameter of the query string used in the request.
6036    /// It should be used to set parameters which are not yet available through their own
6037    /// setters.
6038    ///
6039    /// Please note that this method must not be used to set any of the known parameters
6040    /// which have their own setter method. If done anyway, the request will fail.
6041    ///
6042    /// # Additional Parameters
6043    ///
6044    /// * *$.xgafv* (query-string) - V1 error format.
6045    /// * *access_token* (query-string) - OAuth access token.
6046    /// * *alt* (query-string) - Data format for response.
6047    /// * *callback* (query-string) - JSONP
6048    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6049    /// * *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.
6050    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6051    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6052    /// * *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.
6053    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6054    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6055    pub fn param<T>(
6056        mut self,
6057        name: T,
6058        value: T,
6059    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C>
6060    where
6061        T: AsRef<str>,
6062    {
6063        self._additional_params
6064            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6065        self
6066    }
6067
6068    /// Identifies the authorization scope for the method you are building.
6069    ///
6070    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6071    /// [`Scope::CloudPlatform`].
6072    ///
6073    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6074    /// tokens for more than one scope.
6075    ///
6076    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6077    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6078    /// sufficient, a read-write scope will do as well.
6079    pub fn add_scope<St>(
6080        mut self,
6081        scope: St,
6082    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C>
6083    where
6084        St: AsRef<str>,
6085    {
6086        self._scopes.insert(String::from(scope.as_ref()));
6087        self
6088    }
6089    /// Identifies the authorization scope(s) for the method you are building.
6090    ///
6091    /// See [`Self::add_scope()`] for details.
6092    pub fn add_scopes<I, St>(
6093        mut self,
6094        scopes: I,
6095    ) -> OrganizationLocationAddressGroupListReferenceCall<'a, C>
6096    where
6097        I: IntoIterator<Item = St>,
6098        St: AsRef<str>,
6099    {
6100        self._scopes
6101            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6102        self
6103    }
6104
6105    /// Removes all scopes, and no default scope will be used either.
6106    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6107    /// for details).
6108    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupListReferenceCall<'a, C> {
6109        self._scopes.clear();
6110        self
6111    }
6112}
6113
6114/// Updates parameters of an address group.
6115///
6116/// A builder for the *locations.addressGroups.patch* method supported by a *organization* resource.
6117/// It is not used directly, but through a [`OrganizationMethods`] instance.
6118///
6119/// # Example
6120///
6121/// Instantiate a resource method builder
6122///
6123/// ```test_harness,no_run
6124/// # extern crate hyper;
6125/// # extern crate hyper_rustls;
6126/// # extern crate google_networksecurity1 as networksecurity1;
6127/// use networksecurity1::api::AddressGroup;
6128/// # async fn dox() {
6129/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6130///
6131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6132/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6133/// #     secret,
6134/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6135/// # ).build().await.unwrap();
6136///
6137/// # let client = hyper_util::client::legacy::Client::builder(
6138/// #     hyper_util::rt::TokioExecutor::new()
6139/// # )
6140/// # .build(
6141/// #     hyper_rustls::HttpsConnectorBuilder::new()
6142/// #         .with_native_roots()
6143/// #         .unwrap()
6144/// #         .https_or_http()
6145/// #         .enable_http1()
6146/// #         .build()
6147/// # );
6148/// # let mut hub = NetworkSecurity::new(client, auth);
6149/// // As the method needs a request, you would usually fill it with the desired information
6150/// // into the respective structure. Some of the parts shown here might not be applicable !
6151/// // Values shown here are possibly random and not representative !
6152/// let mut req = AddressGroup::default();
6153///
6154/// // You can configure optional parameters by calling the respective setters at will, and
6155/// // execute the final call using `doit()`.
6156/// // Values shown here are possibly random and not representative !
6157/// let result = hub.organizations().locations_address_groups_patch(req, "name")
6158///              .update_mask(FieldMask::new::<&str>(&[]))
6159///              .request_id("sed")
6160///              .doit().await;
6161/// # }
6162/// ```
6163pub struct OrganizationLocationAddressGroupPatchCall<'a, C>
6164where
6165    C: 'a,
6166{
6167    hub: &'a NetworkSecurity<C>,
6168    _request: AddressGroup,
6169    _name: String,
6170    _update_mask: Option<common::FieldMask>,
6171    _request_id: Option<String>,
6172    _delegate: Option<&'a mut dyn common::Delegate>,
6173    _additional_params: HashMap<String, String>,
6174    _scopes: BTreeSet<String>,
6175}
6176
6177impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupPatchCall<'a, C> {}
6178
6179impl<'a, C> OrganizationLocationAddressGroupPatchCall<'a, C>
6180where
6181    C: common::Connector,
6182{
6183    /// Perform the operation you have build so far.
6184    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6185        use std::borrow::Cow;
6186        use std::io::{Read, Seek};
6187
6188        use common::{url::Params, ToParts};
6189        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6190
6191        let mut dd = common::DefaultDelegate;
6192        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6193        dlg.begin(common::MethodInfo {
6194            id: "networksecurity.organizations.locations.addressGroups.patch",
6195            http_method: hyper::Method::PATCH,
6196        });
6197
6198        for &field in ["alt", "name", "updateMask", "requestId"].iter() {
6199            if self._additional_params.contains_key(field) {
6200                dlg.finished(false);
6201                return Err(common::Error::FieldClash(field));
6202            }
6203        }
6204
6205        let mut params = Params::with_capacity(6 + self._additional_params.len());
6206        params.push("name", self._name);
6207        if let Some(value) = self._update_mask.as_ref() {
6208            params.push("updateMask", value.to_string());
6209        }
6210        if let Some(value) = self._request_id.as_ref() {
6211            params.push("requestId", value);
6212        }
6213
6214        params.extend(self._additional_params.iter());
6215
6216        params.push("alt", "json");
6217        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6218        if self._scopes.is_empty() {
6219            self._scopes
6220                .insert(Scope::CloudPlatform.as_ref().to_string());
6221        }
6222
6223        #[allow(clippy::single_element_loop)]
6224        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6225            url = params.uri_replacement(url, param_name, find_this, true);
6226        }
6227        {
6228            let to_remove = ["name"];
6229            params.remove_params(&to_remove);
6230        }
6231
6232        let url = params.parse_with_url(&url);
6233
6234        let mut json_mime_type = mime::APPLICATION_JSON;
6235        let mut request_value_reader = {
6236            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6237            common::remove_json_null_values(&mut value);
6238            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6239            serde_json::to_writer(&mut dst, &value).unwrap();
6240            dst
6241        };
6242        let request_size = request_value_reader
6243            .seek(std::io::SeekFrom::End(0))
6244            .unwrap();
6245        request_value_reader
6246            .seek(std::io::SeekFrom::Start(0))
6247            .unwrap();
6248
6249        loop {
6250            let token = match self
6251                .hub
6252                .auth
6253                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6254                .await
6255            {
6256                Ok(token) => token,
6257                Err(e) => match dlg.token(e) {
6258                    Ok(token) => token,
6259                    Err(e) => {
6260                        dlg.finished(false);
6261                        return Err(common::Error::MissingToken(e));
6262                    }
6263                },
6264            };
6265            request_value_reader
6266                .seek(std::io::SeekFrom::Start(0))
6267                .unwrap();
6268            let mut req_result = {
6269                let client = &self.hub.client;
6270                dlg.pre_request();
6271                let mut req_builder = hyper::Request::builder()
6272                    .method(hyper::Method::PATCH)
6273                    .uri(url.as_str())
6274                    .header(USER_AGENT, self.hub._user_agent.clone());
6275
6276                if let Some(token) = token.as_ref() {
6277                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6278                }
6279
6280                let request = req_builder
6281                    .header(CONTENT_TYPE, json_mime_type.to_string())
6282                    .header(CONTENT_LENGTH, request_size as u64)
6283                    .body(common::to_body(
6284                        request_value_reader.get_ref().clone().into(),
6285                    ));
6286
6287                client.request(request.unwrap()).await
6288            };
6289
6290            match req_result {
6291                Err(err) => {
6292                    if let common::Retry::After(d) = dlg.http_error(&err) {
6293                        sleep(d).await;
6294                        continue;
6295                    }
6296                    dlg.finished(false);
6297                    return Err(common::Error::HttpError(err));
6298                }
6299                Ok(res) => {
6300                    let (mut parts, body) = res.into_parts();
6301                    let mut body = common::Body::new(body);
6302                    if !parts.status.is_success() {
6303                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6304                        let error = serde_json::from_str(&common::to_string(&bytes));
6305                        let response = common::to_response(parts, bytes.into());
6306
6307                        if let common::Retry::After(d) =
6308                            dlg.http_failure(&response, error.as_ref().ok())
6309                        {
6310                            sleep(d).await;
6311                            continue;
6312                        }
6313
6314                        dlg.finished(false);
6315
6316                        return Err(match error {
6317                            Ok(value) => common::Error::BadRequest(value),
6318                            _ => common::Error::Failure(response),
6319                        });
6320                    }
6321                    let response = {
6322                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6323                        let encoded = common::to_string(&bytes);
6324                        match serde_json::from_str(&encoded) {
6325                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6326                            Err(error) => {
6327                                dlg.response_json_decode_error(&encoded, &error);
6328                                return Err(common::Error::JsonDecodeError(
6329                                    encoded.to_string(),
6330                                    error,
6331                                ));
6332                            }
6333                        }
6334                    };
6335
6336                    dlg.finished(true);
6337                    return Ok(response);
6338                }
6339            }
6340        }
6341    }
6342
6343    ///
6344    /// Sets the *request* property to the given value.
6345    ///
6346    /// Even though the property as already been set when instantiating this call,
6347    /// we provide this method for API completeness.
6348    pub fn request(
6349        mut self,
6350        new_value: AddressGroup,
6351    ) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
6352        self._request = new_value;
6353        self
6354    }
6355    /// Required. Name of the AddressGroup resource. It matches pattern `projects/*/locations/{location}/addressGroups/`.
6356    ///
6357    /// Sets the *name* path property to the given value.
6358    ///
6359    /// Even though the property as already been set when instantiating this call,
6360    /// we provide this method for API completeness.
6361    pub fn name(mut self, new_value: &str) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
6362        self._name = new_value.to_string();
6363        self
6364    }
6365    /// Optional. Field mask is used to specify the fields to be overwritten in the AddressGroup 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.
6366    ///
6367    /// Sets the *update mask* query property to the given value.
6368    pub fn update_mask(
6369        mut self,
6370        new_value: common::FieldMask,
6371    ) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
6372        self._update_mask = Some(new_value);
6373        self
6374    }
6375    /// Optional. 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).
6376    ///
6377    /// Sets the *request id* query property to the given value.
6378    pub fn request_id(
6379        mut self,
6380        new_value: &str,
6381    ) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
6382        self._request_id = Some(new_value.to_string());
6383        self
6384    }
6385    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6386    /// while executing the actual API request.
6387    ///
6388    /// ````text
6389    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6390    /// ````
6391    ///
6392    /// Sets the *delegate* property to the given value.
6393    pub fn delegate(
6394        mut self,
6395        new_value: &'a mut dyn common::Delegate,
6396    ) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
6397        self._delegate = Some(new_value);
6398        self
6399    }
6400
6401    /// Set any additional parameter of the query string used in the request.
6402    /// It should be used to set parameters which are not yet available through their own
6403    /// setters.
6404    ///
6405    /// Please note that this method must not be used to set any of the known parameters
6406    /// which have their own setter method. If done anyway, the request will fail.
6407    ///
6408    /// # Additional Parameters
6409    ///
6410    /// * *$.xgafv* (query-string) - V1 error format.
6411    /// * *access_token* (query-string) - OAuth access token.
6412    /// * *alt* (query-string) - Data format for response.
6413    /// * *callback* (query-string) - JSONP
6414    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6415    /// * *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.
6416    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6417    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6418    /// * *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.
6419    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6420    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6421    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationAddressGroupPatchCall<'a, C>
6422    where
6423        T: AsRef<str>,
6424    {
6425        self._additional_params
6426            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6427        self
6428    }
6429
6430    /// Identifies the authorization scope for the method you are building.
6431    ///
6432    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6433    /// [`Scope::CloudPlatform`].
6434    ///
6435    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6436    /// tokens for more than one scope.
6437    ///
6438    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6439    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6440    /// sufficient, a read-write scope will do as well.
6441    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationAddressGroupPatchCall<'a, C>
6442    where
6443        St: AsRef<str>,
6444    {
6445        self._scopes.insert(String::from(scope.as_ref()));
6446        self
6447    }
6448    /// Identifies the authorization scope(s) for the method you are building.
6449    ///
6450    /// See [`Self::add_scope()`] for details.
6451    pub fn add_scopes<I, St>(
6452        mut self,
6453        scopes: I,
6454    ) -> OrganizationLocationAddressGroupPatchCall<'a, C>
6455    where
6456        I: IntoIterator<Item = St>,
6457        St: AsRef<str>,
6458    {
6459        self._scopes
6460            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6461        self
6462    }
6463
6464    /// Removes all scopes, and no default scope will be used either.
6465    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6466    /// for details).
6467    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupPatchCall<'a, C> {
6468        self._scopes.clear();
6469        self
6470    }
6471}
6472
6473/// Removes items from an address group.
6474///
6475/// A builder for the *locations.addressGroups.removeItems* method supported by a *organization* resource.
6476/// It is not used directly, but through a [`OrganizationMethods`] instance.
6477///
6478/// # Example
6479///
6480/// Instantiate a resource method builder
6481///
6482/// ```test_harness,no_run
6483/// # extern crate hyper;
6484/// # extern crate hyper_rustls;
6485/// # extern crate google_networksecurity1 as networksecurity1;
6486/// use networksecurity1::api::RemoveAddressGroupItemsRequest;
6487/// # async fn dox() {
6488/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6489///
6490/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6491/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6492/// #     secret,
6493/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6494/// # ).build().await.unwrap();
6495///
6496/// # let client = hyper_util::client::legacy::Client::builder(
6497/// #     hyper_util::rt::TokioExecutor::new()
6498/// # )
6499/// # .build(
6500/// #     hyper_rustls::HttpsConnectorBuilder::new()
6501/// #         .with_native_roots()
6502/// #         .unwrap()
6503/// #         .https_or_http()
6504/// #         .enable_http1()
6505/// #         .build()
6506/// # );
6507/// # let mut hub = NetworkSecurity::new(client, auth);
6508/// // As the method needs a request, you would usually fill it with the desired information
6509/// // into the respective structure. Some of the parts shown here might not be applicable !
6510/// // Values shown here are possibly random and not representative !
6511/// let mut req = RemoveAddressGroupItemsRequest::default();
6512///
6513/// // You can configure optional parameters by calling the respective setters at will, and
6514/// // execute the final call using `doit()`.
6515/// // Values shown here are possibly random and not representative !
6516/// let result = hub.organizations().locations_address_groups_remove_items(req, "addressGroup")
6517///              .doit().await;
6518/// # }
6519/// ```
6520pub struct OrganizationLocationAddressGroupRemoveItemCall<'a, C>
6521where
6522    C: 'a,
6523{
6524    hub: &'a NetworkSecurity<C>,
6525    _request: RemoveAddressGroupItemsRequest,
6526    _address_group: String,
6527    _delegate: Option<&'a mut dyn common::Delegate>,
6528    _additional_params: HashMap<String, String>,
6529    _scopes: BTreeSet<String>,
6530}
6531
6532impl<'a, C> common::CallBuilder for OrganizationLocationAddressGroupRemoveItemCall<'a, C> {}
6533
6534impl<'a, C> OrganizationLocationAddressGroupRemoveItemCall<'a, C>
6535where
6536    C: common::Connector,
6537{
6538    /// Perform the operation you have build so far.
6539    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6540        use std::borrow::Cow;
6541        use std::io::{Read, Seek};
6542
6543        use common::{url::Params, ToParts};
6544        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6545
6546        let mut dd = common::DefaultDelegate;
6547        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6548        dlg.begin(common::MethodInfo {
6549            id: "networksecurity.organizations.locations.addressGroups.removeItems",
6550            http_method: hyper::Method::POST,
6551        });
6552
6553        for &field in ["alt", "addressGroup"].iter() {
6554            if self._additional_params.contains_key(field) {
6555                dlg.finished(false);
6556                return Err(common::Error::FieldClash(field));
6557            }
6558        }
6559
6560        let mut params = Params::with_capacity(4 + self._additional_params.len());
6561        params.push("addressGroup", self._address_group);
6562
6563        params.extend(self._additional_params.iter());
6564
6565        params.push("alt", "json");
6566        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:removeItems";
6567        if self._scopes.is_empty() {
6568            self._scopes
6569                .insert(Scope::CloudPlatform.as_ref().to_string());
6570        }
6571
6572        #[allow(clippy::single_element_loop)]
6573        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
6574            url = params.uri_replacement(url, param_name, find_this, true);
6575        }
6576        {
6577            let to_remove = ["addressGroup"];
6578            params.remove_params(&to_remove);
6579        }
6580
6581        let url = params.parse_with_url(&url);
6582
6583        let mut json_mime_type = mime::APPLICATION_JSON;
6584        let mut request_value_reader = {
6585            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6586            common::remove_json_null_values(&mut value);
6587            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6588            serde_json::to_writer(&mut dst, &value).unwrap();
6589            dst
6590        };
6591        let request_size = request_value_reader
6592            .seek(std::io::SeekFrom::End(0))
6593            .unwrap();
6594        request_value_reader
6595            .seek(std::io::SeekFrom::Start(0))
6596            .unwrap();
6597
6598        loop {
6599            let token = match self
6600                .hub
6601                .auth
6602                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6603                .await
6604            {
6605                Ok(token) => token,
6606                Err(e) => match dlg.token(e) {
6607                    Ok(token) => token,
6608                    Err(e) => {
6609                        dlg.finished(false);
6610                        return Err(common::Error::MissingToken(e));
6611                    }
6612                },
6613            };
6614            request_value_reader
6615                .seek(std::io::SeekFrom::Start(0))
6616                .unwrap();
6617            let mut req_result = {
6618                let client = &self.hub.client;
6619                dlg.pre_request();
6620                let mut req_builder = hyper::Request::builder()
6621                    .method(hyper::Method::POST)
6622                    .uri(url.as_str())
6623                    .header(USER_AGENT, self.hub._user_agent.clone());
6624
6625                if let Some(token) = token.as_ref() {
6626                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6627                }
6628
6629                let request = req_builder
6630                    .header(CONTENT_TYPE, json_mime_type.to_string())
6631                    .header(CONTENT_LENGTH, request_size as u64)
6632                    .body(common::to_body(
6633                        request_value_reader.get_ref().clone().into(),
6634                    ));
6635
6636                client.request(request.unwrap()).await
6637            };
6638
6639            match req_result {
6640                Err(err) => {
6641                    if let common::Retry::After(d) = dlg.http_error(&err) {
6642                        sleep(d).await;
6643                        continue;
6644                    }
6645                    dlg.finished(false);
6646                    return Err(common::Error::HttpError(err));
6647                }
6648                Ok(res) => {
6649                    let (mut parts, body) = res.into_parts();
6650                    let mut body = common::Body::new(body);
6651                    if !parts.status.is_success() {
6652                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6653                        let error = serde_json::from_str(&common::to_string(&bytes));
6654                        let response = common::to_response(parts, bytes.into());
6655
6656                        if let common::Retry::After(d) =
6657                            dlg.http_failure(&response, error.as_ref().ok())
6658                        {
6659                            sleep(d).await;
6660                            continue;
6661                        }
6662
6663                        dlg.finished(false);
6664
6665                        return Err(match error {
6666                            Ok(value) => common::Error::BadRequest(value),
6667                            _ => common::Error::Failure(response),
6668                        });
6669                    }
6670                    let response = {
6671                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6672                        let encoded = common::to_string(&bytes);
6673                        match serde_json::from_str(&encoded) {
6674                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6675                            Err(error) => {
6676                                dlg.response_json_decode_error(&encoded, &error);
6677                                return Err(common::Error::JsonDecodeError(
6678                                    encoded.to_string(),
6679                                    error,
6680                                ));
6681                            }
6682                        }
6683                    };
6684
6685                    dlg.finished(true);
6686                    return Ok(response);
6687                }
6688            }
6689        }
6690    }
6691
6692    ///
6693    /// Sets the *request* property to the given value.
6694    ///
6695    /// Even though the property as already been set when instantiating this call,
6696    /// we provide this method for API completeness.
6697    pub fn request(
6698        mut self,
6699        new_value: RemoveAddressGroupItemsRequest,
6700    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C> {
6701        self._request = new_value;
6702        self
6703    }
6704    /// Required. A name of the AddressGroup to remove items from. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
6705    ///
6706    /// Sets the *address group* path property to the given value.
6707    ///
6708    /// Even though the property as already been set when instantiating this call,
6709    /// we provide this method for API completeness.
6710    pub fn address_group(
6711        mut self,
6712        new_value: &str,
6713    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C> {
6714        self._address_group = new_value.to_string();
6715        self
6716    }
6717    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6718    /// while executing the actual API request.
6719    ///
6720    /// ````text
6721    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6722    /// ````
6723    ///
6724    /// Sets the *delegate* property to the given value.
6725    pub fn delegate(
6726        mut self,
6727        new_value: &'a mut dyn common::Delegate,
6728    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C> {
6729        self._delegate = Some(new_value);
6730        self
6731    }
6732
6733    /// Set any additional parameter of the query string used in the request.
6734    /// It should be used to set parameters which are not yet available through their own
6735    /// setters.
6736    ///
6737    /// Please note that this method must not be used to set any of the known parameters
6738    /// which have their own setter method. If done anyway, the request will fail.
6739    ///
6740    /// # Additional Parameters
6741    ///
6742    /// * *$.xgafv* (query-string) - V1 error format.
6743    /// * *access_token* (query-string) - OAuth access token.
6744    /// * *alt* (query-string) - Data format for response.
6745    /// * *callback* (query-string) - JSONP
6746    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6747    /// * *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.
6748    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6749    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6750    /// * *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.
6751    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6752    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6753    pub fn param<T>(
6754        mut self,
6755        name: T,
6756        value: T,
6757    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C>
6758    where
6759        T: AsRef<str>,
6760    {
6761        self._additional_params
6762            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6763        self
6764    }
6765
6766    /// Identifies the authorization scope for the method you are building.
6767    ///
6768    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6769    /// [`Scope::CloudPlatform`].
6770    ///
6771    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6772    /// tokens for more than one scope.
6773    ///
6774    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6775    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6776    /// sufficient, a read-write scope will do as well.
6777    pub fn add_scope<St>(
6778        mut self,
6779        scope: St,
6780    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C>
6781    where
6782        St: AsRef<str>,
6783    {
6784        self._scopes.insert(String::from(scope.as_ref()));
6785        self
6786    }
6787    /// Identifies the authorization scope(s) for the method you are building.
6788    ///
6789    /// See [`Self::add_scope()`] for details.
6790    pub fn add_scopes<I, St>(
6791        mut self,
6792        scopes: I,
6793    ) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C>
6794    where
6795        I: IntoIterator<Item = St>,
6796        St: AsRef<str>,
6797    {
6798        self._scopes
6799            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6800        self
6801    }
6802
6803    /// Removes all scopes, and no default scope will be used either.
6804    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6805    /// for details).
6806    pub fn clear_scopes(mut self) -> OrganizationLocationAddressGroupRemoveItemCall<'a, C> {
6807        self._scopes.clear();
6808        self
6809    }
6810}
6811
6812/// Creates a new FirewallEndpoint in a given project and location.
6813///
6814/// A builder for the *locations.firewallEndpoints.create* method supported by a *organization* resource.
6815/// It is not used directly, but through a [`OrganizationMethods`] instance.
6816///
6817/// # Example
6818///
6819/// Instantiate a resource method builder
6820///
6821/// ```test_harness,no_run
6822/// # extern crate hyper;
6823/// # extern crate hyper_rustls;
6824/// # extern crate google_networksecurity1 as networksecurity1;
6825/// use networksecurity1::api::FirewallEndpoint;
6826/// # async fn dox() {
6827/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6828///
6829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6831/// #     secret,
6832/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6833/// # ).build().await.unwrap();
6834///
6835/// # let client = hyper_util::client::legacy::Client::builder(
6836/// #     hyper_util::rt::TokioExecutor::new()
6837/// # )
6838/// # .build(
6839/// #     hyper_rustls::HttpsConnectorBuilder::new()
6840/// #         .with_native_roots()
6841/// #         .unwrap()
6842/// #         .https_or_http()
6843/// #         .enable_http1()
6844/// #         .build()
6845/// # );
6846/// # let mut hub = NetworkSecurity::new(client, auth);
6847/// // As the method needs a request, you would usually fill it with the desired information
6848/// // into the respective structure. Some of the parts shown here might not be applicable !
6849/// // Values shown here are possibly random and not representative !
6850/// let mut req = FirewallEndpoint::default();
6851///
6852/// // You can configure optional parameters by calling the respective setters at will, and
6853/// // execute the final call using `doit()`.
6854/// // Values shown here are possibly random and not representative !
6855/// let result = hub.organizations().locations_firewall_endpoints_create(req, "parent")
6856///              .request_id("rebum.")
6857///              .firewall_endpoint_id("est")
6858///              .doit().await;
6859/// # }
6860/// ```
6861pub struct OrganizationLocationFirewallEndpointCreateCall<'a, C>
6862where
6863    C: 'a,
6864{
6865    hub: &'a NetworkSecurity<C>,
6866    _request: FirewallEndpoint,
6867    _parent: String,
6868    _request_id: Option<String>,
6869    _firewall_endpoint_id: Option<String>,
6870    _delegate: Option<&'a mut dyn common::Delegate>,
6871    _additional_params: HashMap<String, String>,
6872    _scopes: BTreeSet<String>,
6873}
6874
6875impl<'a, C> common::CallBuilder for OrganizationLocationFirewallEndpointCreateCall<'a, C> {}
6876
6877impl<'a, C> OrganizationLocationFirewallEndpointCreateCall<'a, C>
6878where
6879    C: common::Connector,
6880{
6881    /// Perform the operation you have build so far.
6882    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6883        use std::borrow::Cow;
6884        use std::io::{Read, Seek};
6885
6886        use common::{url::Params, ToParts};
6887        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6888
6889        let mut dd = common::DefaultDelegate;
6890        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6891        dlg.begin(common::MethodInfo {
6892            id: "networksecurity.organizations.locations.firewallEndpoints.create",
6893            http_method: hyper::Method::POST,
6894        });
6895
6896        for &field in ["alt", "parent", "requestId", "firewallEndpointId"].iter() {
6897            if self._additional_params.contains_key(field) {
6898                dlg.finished(false);
6899                return Err(common::Error::FieldClash(field));
6900            }
6901        }
6902
6903        let mut params = Params::with_capacity(6 + self._additional_params.len());
6904        params.push("parent", self._parent);
6905        if let Some(value) = self._request_id.as_ref() {
6906            params.push("requestId", value);
6907        }
6908        if let Some(value) = self._firewall_endpoint_id.as_ref() {
6909            params.push("firewallEndpointId", value);
6910        }
6911
6912        params.extend(self._additional_params.iter());
6913
6914        params.push("alt", "json");
6915        let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallEndpoints";
6916        if self._scopes.is_empty() {
6917            self._scopes
6918                .insert(Scope::CloudPlatform.as_ref().to_string());
6919        }
6920
6921        #[allow(clippy::single_element_loop)]
6922        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6923            url = params.uri_replacement(url, param_name, find_this, true);
6924        }
6925        {
6926            let to_remove = ["parent"];
6927            params.remove_params(&to_remove);
6928        }
6929
6930        let url = params.parse_with_url(&url);
6931
6932        let mut json_mime_type = mime::APPLICATION_JSON;
6933        let mut request_value_reader = {
6934            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6935            common::remove_json_null_values(&mut value);
6936            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6937            serde_json::to_writer(&mut dst, &value).unwrap();
6938            dst
6939        };
6940        let request_size = request_value_reader
6941            .seek(std::io::SeekFrom::End(0))
6942            .unwrap();
6943        request_value_reader
6944            .seek(std::io::SeekFrom::Start(0))
6945            .unwrap();
6946
6947        loop {
6948            let token = match self
6949                .hub
6950                .auth
6951                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6952                .await
6953            {
6954                Ok(token) => token,
6955                Err(e) => match dlg.token(e) {
6956                    Ok(token) => token,
6957                    Err(e) => {
6958                        dlg.finished(false);
6959                        return Err(common::Error::MissingToken(e));
6960                    }
6961                },
6962            };
6963            request_value_reader
6964                .seek(std::io::SeekFrom::Start(0))
6965                .unwrap();
6966            let mut req_result = {
6967                let client = &self.hub.client;
6968                dlg.pre_request();
6969                let mut req_builder = hyper::Request::builder()
6970                    .method(hyper::Method::POST)
6971                    .uri(url.as_str())
6972                    .header(USER_AGENT, self.hub._user_agent.clone());
6973
6974                if let Some(token) = token.as_ref() {
6975                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6976                }
6977
6978                let request = req_builder
6979                    .header(CONTENT_TYPE, json_mime_type.to_string())
6980                    .header(CONTENT_LENGTH, request_size as u64)
6981                    .body(common::to_body(
6982                        request_value_reader.get_ref().clone().into(),
6983                    ));
6984
6985                client.request(request.unwrap()).await
6986            };
6987
6988            match req_result {
6989                Err(err) => {
6990                    if let common::Retry::After(d) = dlg.http_error(&err) {
6991                        sleep(d).await;
6992                        continue;
6993                    }
6994                    dlg.finished(false);
6995                    return Err(common::Error::HttpError(err));
6996                }
6997                Ok(res) => {
6998                    let (mut parts, body) = res.into_parts();
6999                    let mut body = common::Body::new(body);
7000                    if !parts.status.is_success() {
7001                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7002                        let error = serde_json::from_str(&common::to_string(&bytes));
7003                        let response = common::to_response(parts, bytes.into());
7004
7005                        if let common::Retry::After(d) =
7006                            dlg.http_failure(&response, error.as_ref().ok())
7007                        {
7008                            sleep(d).await;
7009                            continue;
7010                        }
7011
7012                        dlg.finished(false);
7013
7014                        return Err(match error {
7015                            Ok(value) => common::Error::BadRequest(value),
7016                            _ => common::Error::Failure(response),
7017                        });
7018                    }
7019                    let response = {
7020                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7021                        let encoded = common::to_string(&bytes);
7022                        match serde_json::from_str(&encoded) {
7023                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7024                            Err(error) => {
7025                                dlg.response_json_decode_error(&encoded, &error);
7026                                return Err(common::Error::JsonDecodeError(
7027                                    encoded.to_string(),
7028                                    error,
7029                                ));
7030                            }
7031                        }
7032                    };
7033
7034                    dlg.finished(true);
7035                    return Ok(response);
7036                }
7037            }
7038        }
7039    }
7040
7041    ///
7042    /// Sets the *request* property to the given value.
7043    ///
7044    /// Even though the property as already been set when instantiating this call,
7045    /// we provide this method for API completeness.
7046    pub fn request(
7047        mut self,
7048        new_value: FirewallEndpoint,
7049    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
7050        self._request = new_value;
7051        self
7052    }
7053    /// Required. Value for parent.
7054    ///
7055    /// Sets the *parent* path property to the given value.
7056    ///
7057    /// Even though the property as already been set when instantiating this call,
7058    /// we provide this method for API completeness.
7059    pub fn parent(
7060        mut self,
7061        new_value: &str,
7062    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
7063        self._parent = new_value.to_string();
7064        self
7065    }
7066    /// Optional. 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).
7067    ///
7068    /// Sets the *request id* query property to the given value.
7069    pub fn request_id(
7070        mut self,
7071        new_value: &str,
7072    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
7073        self._request_id = Some(new_value.to_string());
7074        self
7075    }
7076    /// Required. Id of the requesting object. If auto-generating Id server-side, remove this field and firewall_endpoint_id from the method_signature of Create RPC.
7077    ///
7078    /// Sets the *firewall endpoint id* query property to the given value.
7079    pub fn firewall_endpoint_id(
7080        mut self,
7081        new_value: &str,
7082    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
7083        self._firewall_endpoint_id = Some(new_value.to_string());
7084        self
7085    }
7086    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7087    /// while executing the actual API request.
7088    ///
7089    /// ````text
7090    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7091    /// ````
7092    ///
7093    /// Sets the *delegate* property to the given value.
7094    pub fn delegate(
7095        mut self,
7096        new_value: &'a mut dyn common::Delegate,
7097    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
7098        self._delegate = Some(new_value);
7099        self
7100    }
7101
7102    /// Set any additional parameter of the query string used in the request.
7103    /// It should be used to set parameters which are not yet available through their own
7104    /// setters.
7105    ///
7106    /// Please note that this method must not be used to set any of the known parameters
7107    /// which have their own setter method. If done anyway, the request will fail.
7108    ///
7109    /// # Additional Parameters
7110    ///
7111    /// * *$.xgafv* (query-string) - V1 error format.
7112    /// * *access_token* (query-string) - OAuth access token.
7113    /// * *alt* (query-string) - Data format for response.
7114    /// * *callback* (query-string) - JSONP
7115    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7116    /// * *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.
7117    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7118    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7119    /// * *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.
7120    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7121    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7122    pub fn param<T>(
7123        mut self,
7124        name: T,
7125        value: T,
7126    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C>
7127    where
7128        T: AsRef<str>,
7129    {
7130        self._additional_params
7131            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7132        self
7133    }
7134
7135    /// Identifies the authorization scope for the method you are building.
7136    ///
7137    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7138    /// [`Scope::CloudPlatform`].
7139    ///
7140    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7141    /// tokens for more than one scope.
7142    ///
7143    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7144    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7145    /// sufficient, a read-write scope will do as well.
7146    pub fn add_scope<St>(
7147        mut self,
7148        scope: St,
7149    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C>
7150    where
7151        St: AsRef<str>,
7152    {
7153        self._scopes.insert(String::from(scope.as_ref()));
7154        self
7155    }
7156    /// Identifies the authorization scope(s) for the method you are building.
7157    ///
7158    /// See [`Self::add_scope()`] for details.
7159    pub fn add_scopes<I, St>(
7160        mut self,
7161        scopes: I,
7162    ) -> OrganizationLocationFirewallEndpointCreateCall<'a, C>
7163    where
7164        I: IntoIterator<Item = St>,
7165        St: AsRef<str>,
7166    {
7167        self._scopes
7168            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7169        self
7170    }
7171
7172    /// Removes all scopes, and no default scope will be used either.
7173    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7174    /// for details).
7175    pub fn clear_scopes(mut self) -> OrganizationLocationFirewallEndpointCreateCall<'a, C> {
7176        self._scopes.clear();
7177        self
7178    }
7179}
7180
7181/// Deletes a single Endpoint.
7182///
7183/// A builder for the *locations.firewallEndpoints.delete* method supported by a *organization* resource.
7184/// It is not used directly, but through a [`OrganizationMethods`] instance.
7185///
7186/// # Example
7187///
7188/// Instantiate a resource method builder
7189///
7190/// ```test_harness,no_run
7191/// # extern crate hyper;
7192/// # extern crate hyper_rustls;
7193/// # extern crate google_networksecurity1 as networksecurity1;
7194/// # async fn dox() {
7195/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7196///
7197/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7199/// #     secret,
7200/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7201/// # ).build().await.unwrap();
7202///
7203/// # let client = hyper_util::client::legacy::Client::builder(
7204/// #     hyper_util::rt::TokioExecutor::new()
7205/// # )
7206/// # .build(
7207/// #     hyper_rustls::HttpsConnectorBuilder::new()
7208/// #         .with_native_roots()
7209/// #         .unwrap()
7210/// #         .https_or_http()
7211/// #         .enable_http1()
7212/// #         .build()
7213/// # );
7214/// # let mut hub = NetworkSecurity::new(client, auth);
7215/// // You can configure optional parameters by calling the respective setters at will, and
7216/// // execute the final call using `doit()`.
7217/// // Values shown here are possibly random and not representative !
7218/// let result = hub.organizations().locations_firewall_endpoints_delete("name")
7219///              .request_id("ipsum")
7220///              .doit().await;
7221/// # }
7222/// ```
7223pub struct OrganizationLocationFirewallEndpointDeleteCall<'a, C>
7224where
7225    C: 'a,
7226{
7227    hub: &'a NetworkSecurity<C>,
7228    _name: String,
7229    _request_id: Option<String>,
7230    _delegate: Option<&'a mut dyn common::Delegate>,
7231    _additional_params: HashMap<String, String>,
7232    _scopes: BTreeSet<String>,
7233}
7234
7235impl<'a, C> common::CallBuilder for OrganizationLocationFirewallEndpointDeleteCall<'a, C> {}
7236
7237impl<'a, C> OrganizationLocationFirewallEndpointDeleteCall<'a, C>
7238where
7239    C: common::Connector,
7240{
7241    /// Perform the operation you have build so far.
7242    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7243        use std::borrow::Cow;
7244        use std::io::{Read, Seek};
7245
7246        use common::{url::Params, ToParts};
7247        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7248
7249        let mut dd = common::DefaultDelegate;
7250        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7251        dlg.begin(common::MethodInfo {
7252            id: "networksecurity.organizations.locations.firewallEndpoints.delete",
7253            http_method: hyper::Method::DELETE,
7254        });
7255
7256        for &field in ["alt", "name", "requestId"].iter() {
7257            if self._additional_params.contains_key(field) {
7258                dlg.finished(false);
7259                return Err(common::Error::FieldClash(field));
7260            }
7261        }
7262
7263        let mut params = Params::with_capacity(4 + self._additional_params.len());
7264        params.push("name", self._name);
7265        if let Some(value) = self._request_id.as_ref() {
7266            params.push("requestId", value);
7267        }
7268
7269        params.extend(self._additional_params.iter());
7270
7271        params.push("alt", "json");
7272        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7273        if self._scopes.is_empty() {
7274            self._scopes
7275                .insert(Scope::CloudPlatform.as_ref().to_string());
7276        }
7277
7278        #[allow(clippy::single_element_loop)]
7279        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7280            url = params.uri_replacement(url, param_name, find_this, true);
7281        }
7282        {
7283            let to_remove = ["name"];
7284            params.remove_params(&to_remove);
7285        }
7286
7287        let url = params.parse_with_url(&url);
7288
7289        loop {
7290            let token = match self
7291                .hub
7292                .auth
7293                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7294                .await
7295            {
7296                Ok(token) => token,
7297                Err(e) => match dlg.token(e) {
7298                    Ok(token) => token,
7299                    Err(e) => {
7300                        dlg.finished(false);
7301                        return Err(common::Error::MissingToken(e));
7302                    }
7303                },
7304            };
7305            let mut req_result = {
7306                let client = &self.hub.client;
7307                dlg.pre_request();
7308                let mut req_builder = hyper::Request::builder()
7309                    .method(hyper::Method::DELETE)
7310                    .uri(url.as_str())
7311                    .header(USER_AGENT, self.hub._user_agent.clone());
7312
7313                if let Some(token) = token.as_ref() {
7314                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7315                }
7316
7317                let request = req_builder
7318                    .header(CONTENT_LENGTH, 0_u64)
7319                    .body(common::to_body::<String>(None));
7320
7321                client.request(request.unwrap()).await
7322            };
7323
7324            match req_result {
7325                Err(err) => {
7326                    if let common::Retry::After(d) = dlg.http_error(&err) {
7327                        sleep(d).await;
7328                        continue;
7329                    }
7330                    dlg.finished(false);
7331                    return Err(common::Error::HttpError(err));
7332                }
7333                Ok(res) => {
7334                    let (mut parts, body) = res.into_parts();
7335                    let mut body = common::Body::new(body);
7336                    if !parts.status.is_success() {
7337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7338                        let error = serde_json::from_str(&common::to_string(&bytes));
7339                        let response = common::to_response(parts, bytes.into());
7340
7341                        if let common::Retry::After(d) =
7342                            dlg.http_failure(&response, error.as_ref().ok())
7343                        {
7344                            sleep(d).await;
7345                            continue;
7346                        }
7347
7348                        dlg.finished(false);
7349
7350                        return Err(match error {
7351                            Ok(value) => common::Error::BadRequest(value),
7352                            _ => common::Error::Failure(response),
7353                        });
7354                    }
7355                    let response = {
7356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7357                        let encoded = common::to_string(&bytes);
7358                        match serde_json::from_str(&encoded) {
7359                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7360                            Err(error) => {
7361                                dlg.response_json_decode_error(&encoded, &error);
7362                                return Err(common::Error::JsonDecodeError(
7363                                    encoded.to_string(),
7364                                    error,
7365                                ));
7366                            }
7367                        }
7368                    };
7369
7370                    dlg.finished(true);
7371                    return Ok(response);
7372                }
7373            }
7374        }
7375    }
7376
7377    /// Required. Name of the resource
7378    ///
7379    /// Sets the *name* path property to the given value.
7380    ///
7381    /// Even though the property as already been set when instantiating this call,
7382    /// we provide this method for API completeness.
7383    pub fn name(
7384        mut self,
7385        new_value: &str,
7386    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C> {
7387        self._name = new_value.to_string();
7388        self
7389    }
7390    /// Optional. 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).
7391    ///
7392    /// Sets the *request id* query property to the given value.
7393    pub fn request_id(
7394        mut self,
7395        new_value: &str,
7396    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C> {
7397        self._request_id = Some(new_value.to_string());
7398        self
7399    }
7400    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7401    /// while executing the actual API request.
7402    ///
7403    /// ````text
7404    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7405    /// ````
7406    ///
7407    /// Sets the *delegate* property to the given value.
7408    pub fn delegate(
7409        mut self,
7410        new_value: &'a mut dyn common::Delegate,
7411    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C> {
7412        self._delegate = Some(new_value);
7413        self
7414    }
7415
7416    /// Set any additional parameter of the query string used in the request.
7417    /// It should be used to set parameters which are not yet available through their own
7418    /// setters.
7419    ///
7420    /// Please note that this method must not be used to set any of the known parameters
7421    /// which have their own setter method. If done anyway, the request will fail.
7422    ///
7423    /// # Additional Parameters
7424    ///
7425    /// * *$.xgafv* (query-string) - V1 error format.
7426    /// * *access_token* (query-string) - OAuth access token.
7427    /// * *alt* (query-string) - Data format for response.
7428    /// * *callback* (query-string) - JSONP
7429    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7430    /// * *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.
7431    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7432    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7433    /// * *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.
7434    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7435    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7436    pub fn param<T>(
7437        mut self,
7438        name: T,
7439        value: T,
7440    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C>
7441    where
7442        T: AsRef<str>,
7443    {
7444        self._additional_params
7445            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7446        self
7447    }
7448
7449    /// Identifies the authorization scope for the method you are building.
7450    ///
7451    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7452    /// [`Scope::CloudPlatform`].
7453    ///
7454    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7455    /// tokens for more than one scope.
7456    ///
7457    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7458    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7459    /// sufficient, a read-write scope will do as well.
7460    pub fn add_scope<St>(
7461        mut self,
7462        scope: St,
7463    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C>
7464    where
7465        St: AsRef<str>,
7466    {
7467        self._scopes.insert(String::from(scope.as_ref()));
7468        self
7469    }
7470    /// Identifies the authorization scope(s) for the method you are building.
7471    ///
7472    /// See [`Self::add_scope()`] for details.
7473    pub fn add_scopes<I, St>(
7474        mut self,
7475        scopes: I,
7476    ) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C>
7477    where
7478        I: IntoIterator<Item = St>,
7479        St: AsRef<str>,
7480    {
7481        self._scopes
7482            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7483        self
7484    }
7485
7486    /// Removes all scopes, and no default scope will be used either.
7487    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7488    /// for details).
7489    pub fn clear_scopes(mut self) -> OrganizationLocationFirewallEndpointDeleteCall<'a, C> {
7490        self._scopes.clear();
7491        self
7492    }
7493}
7494
7495/// Gets details of a single Endpoint.
7496///
7497/// A builder for the *locations.firewallEndpoints.get* method supported by a *organization* resource.
7498/// It is not used directly, but through a [`OrganizationMethods`] instance.
7499///
7500/// # Example
7501///
7502/// Instantiate a resource method builder
7503///
7504/// ```test_harness,no_run
7505/// # extern crate hyper;
7506/// # extern crate hyper_rustls;
7507/// # extern crate google_networksecurity1 as networksecurity1;
7508/// # async fn dox() {
7509/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7510///
7511/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7512/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7513/// #     secret,
7514/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7515/// # ).build().await.unwrap();
7516///
7517/// # let client = hyper_util::client::legacy::Client::builder(
7518/// #     hyper_util::rt::TokioExecutor::new()
7519/// # )
7520/// # .build(
7521/// #     hyper_rustls::HttpsConnectorBuilder::new()
7522/// #         .with_native_roots()
7523/// #         .unwrap()
7524/// #         .https_or_http()
7525/// #         .enable_http1()
7526/// #         .build()
7527/// # );
7528/// # let mut hub = NetworkSecurity::new(client, auth);
7529/// // You can configure optional parameters by calling the respective setters at will, and
7530/// // execute the final call using `doit()`.
7531/// // Values shown here are possibly random and not representative !
7532/// let result = hub.organizations().locations_firewall_endpoints_get("name")
7533///              .doit().await;
7534/// # }
7535/// ```
7536pub struct OrganizationLocationFirewallEndpointGetCall<'a, C>
7537where
7538    C: 'a,
7539{
7540    hub: &'a NetworkSecurity<C>,
7541    _name: String,
7542    _delegate: Option<&'a mut dyn common::Delegate>,
7543    _additional_params: HashMap<String, String>,
7544    _scopes: BTreeSet<String>,
7545}
7546
7547impl<'a, C> common::CallBuilder for OrganizationLocationFirewallEndpointGetCall<'a, C> {}
7548
7549impl<'a, C> OrganizationLocationFirewallEndpointGetCall<'a, C>
7550where
7551    C: common::Connector,
7552{
7553    /// Perform the operation you have build so far.
7554    pub async fn doit(mut self) -> common::Result<(common::Response, FirewallEndpoint)> {
7555        use std::borrow::Cow;
7556        use std::io::{Read, Seek};
7557
7558        use common::{url::Params, ToParts};
7559        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7560
7561        let mut dd = common::DefaultDelegate;
7562        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7563        dlg.begin(common::MethodInfo {
7564            id: "networksecurity.organizations.locations.firewallEndpoints.get",
7565            http_method: hyper::Method::GET,
7566        });
7567
7568        for &field in ["alt", "name"].iter() {
7569            if self._additional_params.contains_key(field) {
7570                dlg.finished(false);
7571                return Err(common::Error::FieldClash(field));
7572            }
7573        }
7574
7575        let mut params = Params::with_capacity(3 + self._additional_params.len());
7576        params.push("name", self._name);
7577
7578        params.extend(self._additional_params.iter());
7579
7580        params.push("alt", "json");
7581        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7582        if self._scopes.is_empty() {
7583            self._scopes
7584                .insert(Scope::CloudPlatform.as_ref().to_string());
7585        }
7586
7587        #[allow(clippy::single_element_loop)]
7588        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7589            url = params.uri_replacement(url, param_name, find_this, true);
7590        }
7591        {
7592            let to_remove = ["name"];
7593            params.remove_params(&to_remove);
7594        }
7595
7596        let url = params.parse_with_url(&url);
7597
7598        loop {
7599            let token = match self
7600                .hub
7601                .auth
7602                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7603                .await
7604            {
7605                Ok(token) => token,
7606                Err(e) => match dlg.token(e) {
7607                    Ok(token) => token,
7608                    Err(e) => {
7609                        dlg.finished(false);
7610                        return Err(common::Error::MissingToken(e));
7611                    }
7612                },
7613            };
7614            let mut req_result = {
7615                let client = &self.hub.client;
7616                dlg.pre_request();
7617                let mut req_builder = hyper::Request::builder()
7618                    .method(hyper::Method::GET)
7619                    .uri(url.as_str())
7620                    .header(USER_AGENT, self.hub._user_agent.clone());
7621
7622                if let Some(token) = token.as_ref() {
7623                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7624                }
7625
7626                let request = req_builder
7627                    .header(CONTENT_LENGTH, 0_u64)
7628                    .body(common::to_body::<String>(None));
7629
7630                client.request(request.unwrap()).await
7631            };
7632
7633            match req_result {
7634                Err(err) => {
7635                    if let common::Retry::After(d) = dlg.http_error(&err) {
7636                        sleep(d).await;
7637                        continue;
7638                    }
7639                    dlg.finished(false);
7640                    return Err(common::Error::HttpError(err));
7641                }
7642                Ok(res) => {
7643                    let (mut parts, body) = res.into_parts();
7644                    let mut body = common::Body::new(body);
7645                    if !parts.status.is_success() {
7646                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7647                        let error = serde_json::from_str(&common::to_string(&bytes));
7648                        let response = common::to_response(parts, bytes.into());
7649
7650                        if let common::Retry::After(d) =
7651                            dlg.http_failure(&response, error.as_ref().ok())
7652                        {
7653                            sleep(d).await;
7654                            continue;
7655                        }
7656
7657                        dlg.finished(false);
7658
7659                        return Err(match error {
7660                            Ok(value) => common::Error::BadRequest(value),
7661                            _ => common::Error::Failure(response),
7662                        });
7663                    }
7664                    let response = {
7665                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7666                        let encoded = common::to_string(&bytes);
7667                        match serde_json::from_str(&encoded) {
7668                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7669                            Err(error) => {
7670                                dlg.response_json_decode_error(&encoded, &error);
7671                                return Err(common::Error::JsonDecodeError(
7672                                    encoded.to_string(),
7673                                    error,
7674                                ));
7675                            }
7676                        }
7677                    };
7678
7679                    dlg.finished(true);
7680                    return Ok(response);
7681                }
7682            }
7683        }
7684    }
7685
7686    /// Required. Name of the resource
7687    ///
7688    /// Sets the *name* path property to the given value.
7689    ///
7690    /// Even though the property as already been set when instantiating this call,
7691    /// we provide this method for API completeness.
7692    pub fn name(mut self, new_value: &str) -> OrganizationLocationFirewallEndpointGetCall<'a, C> {
7693        self._name = new_value.to_string();
7694        self
7695    }
7696    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7697    /// while executing the actual API request.
7698    ///
7699    /// ````text
7700    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7701    /// ````
7702    ///
7703    /// Sets the *delegate* property to the given value.
7704    pub fn delegate(
7705        mut self,
7706        new_value: &'a mut dyn common::Delegate,
7707    ) -> OrganizationLocationFirewallEndpointGetCall<'a, C> {
7708        self._delegate = Some(new_value);
7709        self
7710    }
7711
7712    /// Set any additional parameter of the query string used in the request.
7713    /// It should be used to set parameters which are not yet available through their own
7714    /// setters.
7715    ///
7716    /// Please note that this method must not be used to set any of the known parameters
7717    /// which have their own setter method. If done anyway, the request will fail.
7718    ///
7719    /// # Additional Parameters
7720    ///
7721    /// * *$.xgafv* (query-string) - V1 error format.
7722    /// * *access_token* (query-string) - OAuth access token.
7723    /// * *alt* (query-string) - Data format for response.
7724    /// * *callback* (query-string) - JSONP
7725    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7726    /// * *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.
7727    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7728    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7729    /// * *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.
7730    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7731    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7732    pub fn param<T>(
7733        mut self,
7734        name: T,
7735        value: T,
7736    ) -> OrganizationLocationFirewallEndpointGetCall<'a, C>
7737    where
7738        T: AsRef<str>,
7739    {
7740        self._additional_params
7741            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7742        self
7743    }
7744
7745    /// Identifies the authorization scope for the method you are building.
7746    ///
7747    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7748    /// [`Scope::CloudPlatform`].
7749    ///
7750    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7751    /// tokens for more than one scope.
7752    ///
7753    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7754    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7755    /// sufficient, a read-write scope will do as well.
7756    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationFirewallEndpointGetCall<'a, C>
7757    where
7758        St: AsRef<str>,
7759    {
7760        self._scopes.insert(String::from(scope.as_ref()));
7761        self
7762    }
7763    /// Identifies the authorization scope(s) for the method you are building.
7764    ///
7765    /// See [`Self::add_scope()`] for details.
7766    pub fn add_scopes<I, St>(
7767        mut self,
7768        scopes: I,
7769    ) -> OrganizationLocationFirewallEndpointGetCall<'a, C>
7770    where
7771        I: IntoIterator<Item = St>,
7772        St: AsRef<str>,
7773    {
7774        self._scopes
7775            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7776        self
7777    }
7778
7779    /// Removes all scopes, and no default scope will be used either.
7780    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7781    /// for details).
7782    pub fn clear_scopes(mut self) -> OrganizationLocationFirewallEndpointGetCall<'a, C> {
7783        self._scopes.clear();
7784        self
7785    }
7786}
7787
7788/// Lists FirewallEndpoints in a given project and location.
7789///
7790/// A builder for the *locations.firewallEndpoints.list* method supported by a *organization* resource.
7791/// It is not used directly, but through a [`OrganizationMethods`] instance.
7792///
7793/// # Example
7794///
7795/// Instantiate a resource method builder
7796///
7797/// ```test_harness,no_run
7798/// # extern crate hyper;
7799/// # extern crate hyper_rustls;
7800/// # extern crate google_networksecurity1 as networksecurity1;
7801/// # async fn dox() {
7802/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7803///
7804/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7806/// #     secret,
7807/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7808/// # ).build().await.unwrap();
7809///
7810/// # let client = hyper_util::client::legacy::Client::builder(
7811/// #     hyper_util::rt::TokioExecutor::new()
7812/// # )
7813/// # .build(
7814/// #     hyper_rustls::HttpsConnectorBuilder::new()
7815/// #         .with_native_roots()
7816/// #         .unwrap()
7817/// #         .https_or_http()
7818/// #         .enable_http1()
7819/// #         .build()
7820/// # );
7821/// # let mut hub = NetworkSecurity::new(client, auth);
7822/// // You can configure optional parameters by calling the respective setters at will, and
7823/// // execute the final call using `doit()`.
7824/// // Values shown here are possibly random and not representative !
7825/// let result = hub.organizations().locations_firewall_endpoints_list("parent")
7826///              .page_token("ea")
7827///              .page_size(-99)
7828///              .order_by("Lorem")
7829///              .filter("eos")
7830///              .doit().await;
7831/// # }
7832/// ```
7833pub struct OrganizationLocationFirewallEndpointListCall<'a, C>
7834where
7835    C: 'a,
7836{
7837    hub: &'a NetworkSecurity<C>,
7838    _parent: String,
7839    _page_token: Option<String>,
7840    _page_size: Option<i32>,
7841    _order_by: Option<String>,
7842    _filter: Option<String>,
7843    _delegate: Option<&'a mut dyn common::Delegate>,
7844    _additional_params: HashMap<String, String>,
7845    _scopes: BTreeSet<String>,
7846}
7847
7848impl<'a, C> common::CallBuilder for OrganizationLocationFirewallEndpointListCall<'a, C> {}
7849
7850impl<'a, C> OrganizationLocationFirewallEndpointListCall<'a, C>
7851where
7852    C: common::Connector,
7853{
7854    /// Perform the operation you have build so far.
7855    pub async fn doit(
7856        mut self,
7857    ) -> common::Result<(common::Response, ListFirewallEndpointsResponse)> {
7858        use std::borrow::Cow;
7859        use std::io::{Read, Seek};
7860
7861        use common::{url::Params, ToParts};
7862        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7863
7864        let mut dd = common::DefaultDelegate;
7865        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7866        dlg.begin(common::MethodInfo {
7867            id: "networksecurity.organizations.locations.firewallEndpoints.list",
7868            http_method: hyper::Method::GET,
7869        });
7870
7871        for &field in [
7872            "alt",
7873            "parent",
7874            "pageToken",
7875            "pageSize",
7876            "orderBy",
7877            "filter",
7878        ]
7879        .iter()
7880        {
7881            if self._additional_params.contains_key(field) {
7882                dlg.finished(false);
7883                return Err(common::Error::FieldClash(field));
7884            }
7885        }
7886
7887        let mut params = Params::with_capacity(7 + self._additional_params.len());
7888        params.push("parent", self._parent);
7889        if let Some(value) = self._page_token.as_ref() {
7890            params.push("pageToken", value);
7891        }
7892        if let Some(value) = self._page_size.as_ref() {
7893            params.push("pageSize", value.to_string());
7894        }
7895        if let Some(value) = self._order_by.as_ref() {
7896            params.push("orderBy", value);
7897        }
7898        if let Some(value) = self._filter.as_ref() {
7899            params.push("filter", value);
7900        }
7901
7902        params.extend(self._additional_params.iter());
7903
7904        params.push("alt", "json");
7905        let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallEndpoints";
7906        if self._scopes.is_empty() {
7907            self._scopes
7908                .insert(Scope::CloudPlatform.as_ref().to_string());
7909        }
7910
7911        #[allow(clippy::single_element_loop)]
7912        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7913            url = params.uri_replacement(url, param_name, find_this, true);
7914        }
7915        {
7916            let to_remove = ["parent"];
7917            params.remove_params(&to_remove);
7918        }
7919
7920        let url = params.parse_with_url(&url);
7921
7922        loop {
7923            let token = match self
7924                .hub
7925                .auth
7926                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7927                .await
7928            {
7929                Ok(token) => token,
7930                Err(e) => match dlg.token(e) {
7931                    Ok(token) => token,
7932                    Err(e) => {
7933                        dlg.finished(false);
7934                        return Err(common::Error::MissingToken(e));
7935                    }
7936                },
7937            };
7938            let mut req_result = {
7939                let client = &self.hub.client;
7940                dlg.pre_request();
7941                let mut req_builder = hyper::Request::builder()
7942                    .method(hyper::Method::GET)
7943                    .uri(url.as_str())
7944                    .header(USER_AGENT, self.hub._user_agent.clone());
7945
7946                if let Some(token) = token.as_ref() {
7947                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7948                }
7949
7950                let request = req_builder
7951                    .header(CONTENT_LENGTH, 0_u64)
7952                    .body(common::to_body::<String>(None));
7953
7954                client.request(request.unwrap()).await
7955            };
7956
7957            match req_result {
7958                Err(err) => {
7959                    if let common::Retry::After(d) = dlg.http_error(&err) {
7960                        sleep(d).await;
7961                        continue;
7962                    }
7963                    dlg.finished(false);
7964                    return Err(common::Error::HttpError(err));
7965                }
7966                Ok(res) => {
7967                    let (mut parts, body) = res.into_parts();
7968                    let mut body = common::Body::new(body);
7969                    if !parts.status.is_success() {
7970                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7971                        let error = serde_json::from_str(&common::to_string(&bytes));
7972                        let response = common::to_response(parts, bytes.into());
7973
7974                        if let common::Retry::After(d) =
7975                            dlg.http_failure(&response, error.as_ref().ok())
7976                        {
7977                            sleep(d).await;
7978                            continue;
7979                        }
7980
7981                        dlg.finished(false);
7982
7983                        return Err(match error {
7984                            Ok(value) => common::Error::BadRequest(value),
7985                            _ => common::Error::Failure(response),
7986                        });
7987                    }
7988                    let response = {
7989                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7990                        let encoded = common::to_string(&bytes);
7991                        match serde_json::from_str(&encoded) {
7992                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7993                            Err(error) => {
7994                                dlg.response_json_decode_error(&encoded, &error);
7995                                return Err(common::Error::JsonDecodeError(
7996                                    encoded.to_string(),
7997                                    error,
7998                                ));
7999                            }
8000                        }
8001                    };
8002
8003                    dlg.finished(true);
8004                    return Ok(response);
8005                }
8006            }
8007        }
8008    }
8009
8010    /// Required. Parent value for ListEndpointsRequest
8011    ///
8012    /// Sets the *parent* path property to the given value.
8013    ///
8014    /// Even though the property as already been set when instantiating this call,
8015    /// we provide this method for API completeness.
8016    pub fn parent(
8017        mut self,
8018        new_value: &str,
8019    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8020        self._parent = new_value.to_string();
8021        self
8022    }
8023    /// A token identifying a page of results the server should return.
8024    ///
8025    /// Sets the *page token* query property to the given value.
8026    pub fn page_token(
8027        mut self,
8028        new_value: &str,
8029    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8030        self._page_token = Some(new_value.to_string());
8031        self
8032    }
8033    /// Optional. Requested page size. Server may return fewer items than requested. If unspecified, server will pick an appropriate default.
8034    ///
8035    /// Sets the *page size* query property to the given value.
8036    pub fn page_size(
8037        mut self,
8038        new_value: i32,
8039    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8040        self._page_size = Some(new_value);
8041        self
8042    }
8043    /// Hint for how to order the results
8044    ///
8045    /// Sets the *order by* query property to the given value.
8046    pub fn order_by(
8047        mut self,
8048        new_value: &str,
8049    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8050        self._order_by = Some(new_value.to_string());
8051        self
8052    }
8053    /// Optional. Filtering results
8054    ///
8055    /// Sets the *filter* query property to the given value.
8056    pub fn filter(
8057        mut self,
8058        new_value: &str,
8059    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8060        self._filter = Some(new_value.to_string());
8061        self
8062    }
8063    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8064    /// while executing the actual API request.
8065    ///
8066    /// ````text
8067    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8068    /// ````
8069    ///
8070    /// Sets the *delegate* property to the given value.
8071    pub fn delegate(
8072        mut self,
8073        new_value: &'a mut dyn common::Delegate,
8074    ) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8075        self._delegate = Some(new_value);
8076        self
8077    }
8078
8079    /// Set any additional parameter of the query string used in the request.
8080    /// It should be used to set parameters which are not yet available through their own
8081    /// setters.
8082    ///
8083    /// Please note that this method must not be used to set any of the known parameters
8084    /// which have their own setter method. If done anyway, the request will fail.
8085    ///
8086    /// # Additional Parameters
8087    ///
8088    /// * *$.xgafv* (query-string) - V1 error format.
8089    /// * *access_token* (query-string) - OAuth access token.
8090    /// * *alt* (query-string) - Data format for response.
8091    /// * *callback* (query-string) - JSONP
8092    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8093    /// * *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.
8094    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8095    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8096    /// * *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.
8097    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8098    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8099    pub fn param<T>(
8100        mut self,
8101        name: T,
8102        value: T,
8103    ) -> OrganizationLocationFirewallEndpointListCall<'a, C>
8104    where
8105        T: AsRef<str>,
8106    {
8107        self._additional_params
8108            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8109        self
8110    }
8111
8112    /// Identifies the authorization scope for the method you are building.
8113    ///
8114    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8115    /// [`Scope::CloudPlatform`].
8116    ///
8117    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8118    /// tokens for more than one scope.
8119    ///
8120    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8121    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8122    /// sufficient, a read-write scope will do as well.
8123    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationFirewallEndpointListCall<'a, C>
8124    where
8125        St: AsRef<str>,
8126    {
8127        self._scopes.insert(String::from(scope.as_ref()));
8128        self
8129    }
8130    /// Identifies the authorization scope(s) for the method you are building.
8131    ///
8132    /// See [`Self::add_scope()`] for details.
8133    pub fn add_scopes<I, St>(
8134        mut self,
8135        scopes: I,
8136    ) -> OrganizationLocationFirewallEndpointListCall<'a, C>
8137    where
8138        I: IntoIterator<Item = St>,
8139        St: AsRef<str>,
8140    {
8141        self._scopes
8142            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8143        self
8144    }
8145
8146    /// Removes all scopes, and no default scope will be used either.
8147    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8148    /// for details).
8149    pub fn clear_scopes(mut self) -> OrganizationLocationFirewallEndpointListCall<'a, C> {
8150        self._scopes.clear();
8151        self
8152    }
8153}
8154
8155/// Update a single Endpoint.
8156///
8157/// A builder for the *locations.firewallEndpoints.patch* method supported by a *organization* resource.
8158/// It is not used directly, but through a [`OrganizationMethods`] instance.
8159///
8160/// # Example
8161///
8162/// Instantiate a resource method builder
8163///
8164/// ```test_harness,no_run
8165/// # extern crate hyper;
8166/// # extern crate hyper_rustls;
8167/// # extern crate google_networksecurity1 as networksecurity1;
8168/// use networksecurity1::api::FirewallEndpoint;
8169/// # async fn dox() {
8170/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8171///
8172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8173/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8174/// #     secret,
8175/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8176/// # ).build().await.unwrap();
8177///
8178/// # let client = hyper_util::client::legacy::Client::builder(
8179/// #     hyper_util::rt::TokioExecutor::new()
8180/// # )
8181/// # .build(
8182/// #     hyper_rustls::HttpsConnectorBuilder::new()
8183/// #         .with_native_roots()
8184/// #         .unwrap()
8185/// #         .https_or_http()
8186/// #         .enable_http1()
8187/// #         .build()
8188/// # );
8189/// # let mut hub = NetworkSecurity::new(client, auth);
8190/// // As the method needs a request, you would usually fill it with the desired information
8191/// // into the respective structure. Some of the parts shown here might not be applicable !
8192/// // Values shown here are possibly random and not representative !
8193/// let mut req = FirewallEndpoint::default();
8194///
8195/// // You can configure optional parameters by calling the respective setters at will, and
8196/// // execute the final call using `doit()`.
8197/// // Values shown here are possibly random and not representative !
8198/// let result = hub.organizations().locations_firewall_endpoints_patch(req, "name")
8199///              .update_mask(FieldMask::new::<&str>(&[]))
8200///              .request_id("sed")
8201///              .doit().await;
8202/// # }
8203/// ```
8204pub struct OrganizationLocationFirewallEndpointPatchCall<'a, C>
8205where
8206    C: 'a,
8207{
8208    hub: &'a NetworkSecurity<C>,
8209    _request: FirewallEndpoint,
8210    _name: String,
8211    _update_mask: Option<common::FieldMask>,
8212    _request_id: Option<String>,
8213    _delegate: Option<&'a mut dyn common::Delegate>,
8214    _additional_params: HashMap<String, String>,
8215    _scopes: BTreeSet<String>,
8216}
8217
8218impl<'a, C> common::CallBuilder for OrganizationLocationFirewallEndpointPatchCall<'a, C> {}
8219
8220impl<'a, C> OrganizationLocationFirewallEndpointPatchCall<'a, C>
8221where
8222    C: common::Connector,
8223{
8224    /// Perform the operation you have build so far.
8225    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8226        use std::borrow::Cow;
8227        use std::io::{Read, Seek};
8228
8229        use common::{url::Params, ToParts};
8230        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8231
8232        let mut dd = common::DefaultDelegate;
8233        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8234        dlg.begin(common::MethodInfo {
8235            id: "networksecurity.organizations.locations.firewallEndpoints.patch",
8236            http_method: hyper::Method::PATCH,
8237        });
8238
8239        for &field in ["alt", "name", "updateMask", "requestId"].iter() {
8240            if self._additional_params.contains_key(field) {
8241                dlg.finished(false);
8242                return Err(common::Error::FieldClash(field));
8243            }
8244        }
8245
8246        let mut params = Params::with_capacity(6 + self._additional_params.len());
8247        params.push("name", self._name);
8248        if let Some(value) = self._update_mask.as_ref() {
8249            params.push("updateMask", value.to_string());
8250        }
8251        if let Some(value) = self._request_id.as_ref() {
8252            params.push("requestId", value);
8253        }
8254
8255        params.extend(self._additional_params.iter());
8256
8257        params.push("alt", "json");
8258        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8259        if self._scopes.is_empty() {
8260            self._scopes
8261                .insert(Scope::CloudPlatform.as_ref().to_string());
8262        }
8263
8264        #[allow(clippy::single_element_loop)]
8265        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8266            url = params.uri_replacement(url, param_name, find_this, true);
8267        }
8268        {
8269            let to_remove = ["name"];
8270            params.remove_params(&to_remove);
8271        }
8272
8273        let url = params.parse_with_url(&url);
8274
8275        let mut json_mime_type = mime::APPLICATION_JSON;
8276        let mut request_value_reader = {
8277            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8278            common::remove_json_null_values(&mut value);
8279            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8280            serde_json::to_writer(&mut dst, &value).unwrap();
8281            dst
8282        };
8283        let request_size = request_value_reader
8284            .seek(std::io::SeekFrom::End(0))
8285            .unwrap();
8286        request_value_reader
8287            .seek(std::io::SeekFrom::Start(0))
8288            .unwrap();
8289
8290        loop {
8291            let token = match self
8292                .hub
8293                .auth
8294                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8295                .await
8296            {
8297                Ok(token) => token,
8298                Err(e) => match dlg.token(e) {
8299                    Ok(token) => token,
8300                    Err(e) => {
8301                        dlg.finished(false);
8302                        return Err(common::Error::MissingToken(e));
8303                    }
8304                },
8305            };
8306            request_value_reader
8307                .seek(std::io::SeekFrom::Start(0))
8308                .unwrap();
8309            let mut req_result = {
8310                let client = &self.hub.client;
8311                dlg.pre_request();
8312                let mut req_builder = hyper::Request::builder()
8313                    .method(hyper::Method::PATCH)
8314                    .uri(url.as_str())
8315                    .header(USER_AGENT, self.hub._user_agent.clone());
8316
8317                if let Some(token) = token.as_ref() {
8318                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8319                }
8320
8321                let request = req_builder
8322                    .header(CONTENT_TYPE, json_mime_type.to_string())
8323                    .header(CONTENT_LENGTH, request_size as u64)
8324                    .body(common::to_body(
8325                        request_value_reader.get_ref().clone().into(),
8326                    ));
8327
8328                client.request(request.unwrap()).await
8329            };
8330
8331            match req_result {
8332                Err(err) => {
8333                    if let common::Retry::After(d) = dlg.http_error(&err) {
8334                        sleep(d).await;
8335                        continue;
8336                    }
8337                    dlg.finished(false);
8338                    return Err(common::Error::HttpError(err));
8339                }
8340                Ok(res) => {
8341                    let (mut parts, body) = res.into_parts();
8342                    let mut body = common::Body::new(body);
8343                    if !parts.status.is_success() {
8344                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8345                        let error = serde_json::from_str(&common::to_string(&bytes));
8346                        let response = common::to_response(parts, bytes.into());
8347
8348                        if let common::Retry::After(d) =
8349                            dlg.http_failure(&response, error.as_ref().ok())
8350                        {
8351                            sleep(d).await;
8352                            continue;
8353                        }
8354
8355                        dlg.finished(false);
8356
8357                        return Err(match error {
8358                            Ok(value) => common::Error::BadRequest(value),
8359                            _ => common::Error::Failure(response),
8360                        });
8361                    }
8362                    let response = {
8363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8364                        let encoded = common::to_string(&bytes);
8365                        match serde_json::from_str(&encoded) {
8366                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8367                            Err(error) => {
8368                                dlg.response_json_decode_error(&encoded, &error);
8369                                return Err(common::Error::JsonDecodeError(
8370                                    encoded.to_string(),
8371                                    error,
8372                                ));
8373                            }
8374                        }
8375                    };
8376
8377                    dlg.finished(true);
8378                    return Ok(response);
8379                }
8380            }
8381        }
8382    }
8383
8384    ///
8385    /// Sets the *request* property to the given value.
8386    ///
8387    /// Even though the property as already been set when instantiating this call,
8388    /// we provide this method for API completeness.
8389    pub fn request(
8390        mut self,
8391        new_value: FirewallEndpoint,
8392    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
8393        self._request = new_value;
8394        self
8395    }
8396    /// Immutable. Identifier. name of resource
8397    ///
8398    /// Sets the *name* path property to the given value.
8399    ///
8400    /// Even though the property as already been set when instantiating this call,
8401    /// we provide this method for API completeness.
8402    pub fn name(mut self, new_value: &str) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
8403        self._name = new_value.to_string();
8404        self
8405    }
8406    /// Required. 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.
8407    ///
8408    /// Sets the *update mask* query property to the given value.
8409    pub fn update_mask(
8410        mut self,
8411        new_value: common::FieldMask,
8412    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
8413        self._update_mask = Some(new_value);
8414        self
8415    }
8416    /// Optional. 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).
8417    ///
8418    /// Sets the *request id* query property to the given value.
8419    pub fn request_id(
8420        mut self,
8421        new_value: &str,
8422    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
8423        self._request_id = Some(new_value.to_string());
8424        self
8425    }
8426    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8427    /// while executing the actual API request.
8428    ///
8429    /// ````text
8430    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8431    /// ````
8432    ///
8433    /// Sets the *delegate* property to the given value.
8434    pub fn delegate(
8435        mut self,
8436        new_value: &'a mut dyn common::Delegate,
8437    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
8438        self._delegate = Some(new_value);
8439        self
8440    }
8441
8442    /// Set any additional parameter of the query string used in the request.
8443    /// It should be used to set parameters which are not yet available through their own
8444    /// setters.
8445    ///
8446    /// Please note that this method must not be used to set any of the known parameters
8447    /// which have their own setter method. If done anyway, the request will fail.
8448    ///
8449    /// # Additional Parameters
8450    ///
8451    /// * *$.xgafv* (query-string) - V1 error format.
8452    /// * *access_token* (query-string) - OAuth access token.
8453    /// * *alt* (query-string) - Data format for response.
8454    /// * *callback* (query-string) - JSONP
8455    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8456    /// * *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.
8457    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8458    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8459    /// * *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.
8460    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8461    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8462    pub fn param<T>(
8463        mut self,
8464        name: T,
8465        value: T,
8466    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C>
8467    where
8468        T: AsRef<str>,
8469    {
8470        self._additional_params
8471            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8472        self
8473    }
8474
8475    /// Identifies the authorization scope for the method you are building.
8476    ///
8477    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8478    /// [`Scope::CloudPlatform`].
8479    ///
8480    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8481    /// tokens for more than one scope.
8482    ///
8483    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8484    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8485    /// sufficient, a read-write scope will do as well.
8486    pub fn add_scope<St>(
8487        mut self,
8488        scope: St,
8489    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C>
8490    where
8491        St: AsRef<str>,
8492    {
8493        self._scopes.insert(String::from(scope.as_ref()));
8494        self
8495    }
8496    /// Identifies the authorization scope(s) for the method you are building.
8497    ///
8498    /// See [`Self::add_scope()`] for details.
8499    pub fn add_scopes<I, St>(
8500        mut self,
8501        scopes: I,
8502    ) -> OrganizationLocationFirewallEndpointPatchCall<'a, C>
8503    where
8504        I: IntoIterator<Item = St>,
8505        St: AsRef<str>,
8506    {
8507        self._scopes
8508            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8509        self
8510    }
8511
8512    /// Removes all scopes, and no default scope will be used either.
8513    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8514    /// for details).
8515    pub fn clear_scopes(mut self) -> OrganizationLocationFirewallEndpointPatchCall<'a, C> {
8516        self._scopes.clear();
8517        self
8518    }
8519}
8520
8521/// 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`.
8522///
8523/// A builder for the *locations.operations.cancel* method supported by a *organization* resource.
8524/// It is not used directly, but through a [`OrganizationMethods`] instance.
8525///
8526/// # Example
8527///
8528/// Instantiate a resource method builder
8529///
8530/// ```test_harness,no_run
8531/// # extern crate hyper;
8532/// # extern crate hyper_rustls;
8533/// # extern crate google_networksecurity1 as networksecurity1;
8534/// use networksecurity1::api::CancelOperationRequest;
8535/// # async fn dox() {
8536/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8537///
8538/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8539/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8540/// #     secret,
8541/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8542/// # ).build().await.unwrap();
8543///
8544/// # let client = hyper_util::client::legacy::Client::builder(
8545/// #     hyper_util::rt::TokioExecutor::new()
8546/// # )
8547/// # .build(
8548/// #     hyper_rustls::HttpsConnectorBuilder::new()
8549/// #         .with_native_roots()
8550/// #         .unwrap()
8551/// #         .https_or_http()
8552/// #         .enable_http1()
8553/// #         .build()
8554/// # );
8555/// # let mut hub = NetworkSecurity::new(client, auth);
8556/// // As the method needs a request, you would usually fill it with the desired information
8557/// // into the respective structure. Some of the parts shown here might not be applicable !
8558/// // Values shown here are possibly random and not representative !
8559/// let mut req = CancelOperationRequest::default();
8560///
8561/// // You can configure optional parameters by calling the respective setters at will, and
8562/// // execute the final call using `doit()`.
8563/// // Values shown here are possibly random and not representative !
8564/// let result = hub.organizations().locations_operations_cancel(req, "name")
8565///              .doit().await;
8566/// # }
8567/// ```
8568pub struct OrganizationLocationOperationCancelCall<'a, C>
8569where
8570    C: 'a,
8571{
8572    hub: &'a NetworkSecurity<C>,
8573    _request: CancelOperationRequest,
8574    _name: String,
8575    _delegate: Option<&'a mut dyn common::Delegate>,
8576    _additional_params: HashMap<String, String>,
8577    _scopes: BTreeSet<String>,
8578}
8579
8580impl<'a, C> common::CallBuilder for OrganizationLocationOperationCancelCall<'a, C> {}
8581
8582impl<'a, C> OrganizationLocationOperationCancelCall<'a, C>
8583where
8584    C: common::Connector,
8585{
8586    /// Perform the operation you have build so far.
8587    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8588        use std::borrow::Cow;
8589        use std::io::{Read, Seek};
8590
8591        use common::{url::Params, ToParts};
8592        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8593
8594        let mut dd = common::DefaultDelegate;
8595        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8596        dlg.begin(common::MethodInfo {
8597            id: "networksecurity.organizations.locations.operations.cancel",
8598            http_method: hyper::Method::POST,
8599        });
8600
8601        for &field in ["alt", "name"].iter() {
8602            if self._additional_params.contains_key(field) {
8603                dlg.finished(false);
8604                return Err(common::Error::FieldClash(field));
8605            }
8606        }
8607
8608        let mut params = Params::with_capacity(4 + self._additional_params.len());
8609        params.push("name", self._name);
8610
8611        params.extend(self._additional_params.iter());
8612
8613        params.push("alt", "json");
8614        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
8615        if self._scopes.is_empty() {
8616            self._scopes
8617                .insert(Scope::CloudPlatform.as_ref().to_string());
8618        }
8619
8620        #[allow(clippy::single_element_loop)]
8621        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8622            url = params.uri_replacement(url, param_name, find_this, true);
8623        }
8624        {
8625            let to_remove = ["name"];
8626            params.remove_params(&to_remove);
8627        }
8628
8629        let url = params.parse_with_url(&url);
8630
8631        let mut json_mime_type = mime::APPLICATION_JSON;
8632        let mut request_value_reader = {
8633            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8634            common::remove_json_null_values(&mut value);
8635            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8636            serde_json::to_writer(&mut dst, &value).unwrap();
8637            dst
8638        };
8639        let request_size = request_value_reader
8640            .seek(std::io::SeekFrom::End(0))
8641            .unwrap();
8642        request_value_reader
8643            .seek(std::io::SeekFrom::Start(0))
8644            .unwrap();
8645
8646        loop {
8647            let token = match self
8648                .hub
8649                .auth
8650                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8651                .await
8652            {
8653                Ok(token) => token,
8654                Err(e) => match dlg.token(e) {
8655                    Ok(token) => token,
8656                    Err(e) => {
8657                        dlg.finished(false);
8658                        return Err(common::Error::MissingToken(e));
8659                    }
8660                },
8661            };
8662            request_value_reader
8663                .seek(std::io::SeekFrom::Start(0))
8664                .unwrap();
8665            let mut req_result = {
8666                let client = &self.hub.client;
8667                dlg.pre_request();
8668                let mut req_builder = hyper::Request::builder()
8669                    .method(hyper::Method::POST)
8670                    .uri(url.as_str())
8671                    .header(USER_AGENT, self.hub._user_agent.clone());
8672
8673                if let Some(token) = token.as_ref() {
8674                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8675                }
8676
8677                let request = req_builder
8678                    .header(CONTENT_TYPE, json_mime_type.to_string())
8679                    .header(CONTENT_LENGTH, request_size as u64)
8680                    .body(common::to_body(
8681                        request_value_reader.get_ref().clone().into(),
8682                    ));
8683
8684                client.request(request.unwrap()).await
8685            };
8686
8687            match req_result {
8688                Err(err) => {
8689                    if let common::Retry::After(d) = dlg.http_error(&err) {
8690                        sleep(d).await;
8691                        continue;
8692                    }
8693                    dlg.finished(false);
8694                    return Err(common::Error::HttpError(err));
8695                }
8696                Ok(res) => {
8697                    let (mut parts, body) = res.into_parts();
8698                    let mut body = common::Body::new(body);
8699                    if !parts.status.is_success() {
8700                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8701                        let error = serde_json::from_str(&common::to_string(&bytes));
8702                        let response = common::to_response(parts, bytes.into());
8703
8704                        if let common::Retry::After(d) =
8705                            dlg.http_failure(&response, error.as_ref().ok())
8706                        {
8707                            sleep(d).await;
8708                            continue;
8709                        }
8710
8711                        dlg.finished(false);
8712
8713                        return Err(match error {
8714                            Ok(value) => common::Error::BadRequest(value),
8715                            _ => common::Error::Failure(response),
8716                        });
8717                    }
8718                    let response = {
8719                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8720                        let encoded = common::to_string(&bytes);
8721                        match serde_json::from_str(&encoded) {
8722                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8723                            Err(error) => {
8724                                dlg.response_json_decode_error(&encoded, &error);
8725                                return Err(common::Error::JsonDecodeError(
8726                                    encoded.to_string(),
8727                                    error,
8728                                ));
8729                            }
8730                        }
8731                    };
8732
8733                    dlg.finished(true);
8734                    return Ok(response);
8735                }
8736            }
8737        }
8738    }
8739
8740    ///
8741    /// Sets the *request* property to the given value.
8742    ///
8743    /// Even though the property as already been set when instantiating this call,
8744    /// we provide this method for API completeness.
8745    pub fn request(
8746        mut self,
8747        new_value: CancelOperationRequest,
8748    ) -> OrganizationLocationOperationCancelCall<'a, C> {
8749        self._request = new_value;
8750        self
8751    }
8752    /// The name of the operation resource to be cancelled.
8753    ///
8754    /// Sets the *name* path property to the given value.
8755    ///
8756    /// Even though the property as already been set when instantiating this call,
8757    /// we provide this method for API completeness.
8758    pub fn name(mut self, new_value: &str) -> OrganizationLocationOperationCancelCall<'a, C> {
8759        self._name = new_value.to_string();
8760        self
8761    }
8762    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8763    /// while executing the actual API request.
8764    ///
8765    /// ````text
8766    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8767    /// ````
8768    ///
8769    /// Sets the *delegate* property to the given value.
8770    pub fn delegate(
8771        mut self,
8772        new_value: &'a mut dyn common::Delegate,
8773    ) -> OrganizationLocationOperationCancelCall<'a, C> {
8774        self._delegate = Some(new_value);
8775        self
8776    }
8777
8778    /// Set any additional parameter of the query string used in the request.
8779    /// It should be used to set parameters which are not yet available through their own
8780    /// setters.
8781    ///
8782    /// Please note that this method must not be used to set any of the known parameters
8783    /// which have their own setter method. If done anyway, the request will fail.
8784    ///
8785    /// # Additional Parameters
8786    ///
8787    /// * *$.xgafv* (query-string) - V1 error format.
8788    /// * *access_token* (query-string) - OAuth access token.
8789    /// * *alt* (query-string) - Data format for response.
8790    /// * *callback* (query-string) - JSONP
8791    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8792    /// * *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.
8793    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8794    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8795    /// * *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.
8796    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8797    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8798    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationOperationCancelCall<'a, C>
8799    where
8800        T: AsRef<str>,
8801    {
8802        self._additional_params
8803            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8804        self
8805    }
8806
8807    /// Identifies the authorization scope for the method you are building.
8808    ///
8809    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8810    /// [`Scope::CloudPlatform`].
8811    ///
8812    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8813    /// tokens for more than one scope.
8814    ///
8815    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8816    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8817    /// sufficient, a read-write scope will do as well.
8818    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationOperationCancelCall<'a, C>
8819    where
8820        St: AsRef<str>,
8821    {
8822        self._scopes.insert(String::from(scope.as_ref()));
8823        self
8824    }
8825    /// Identifies the authorization scope(s) for the method you are building.
8826    ///
8827    /// See [`Self::add_scope()`] for details.
8828    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationOperationCancelCall<'a, C>
8829    where
8830        I: IntoIterator<Item = St>,
8831        St: AsRef<str>,
8832    {
8833        self._scopes
8834            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8835        self
8836    }
8837
8838    /// Removes all scopes, and no default scope will be used either.
8839    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8840    /// for details).
8841    pub fn clear_scopes(mut self) -> OrganizationLocationOperationCancelCall<'a, C> {
8842        self._scopes.clear();
8843        self
8844    }
8845}
8846
8847/// 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`.
8848///
8849/// A builder for the *locations.operations.delete* method supported by a *organization* resource.
8850/// It is not used directly, but through a [`OrganizationMethods`] instance.
8851///
8852/// # Example
8853///
8854/// Instantiate a resource method builder
8855///
8856/// ```test_harness,no_run
8857/// # extern crate hyper;
8858/// # extern crate hyper_rustls;
8859/// # extern crate google_networksecurity1 as networksecurity1;
8860/// # async fn dox() {
8861/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8862///
8863/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8864/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8865/// #     secret,
8866/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8867/// # ).build().await.unwrap();
8868///
8869/// # let client = hyper_util::client::legacy::Client::builder(
8870/// #     hyper_util::rt::TokioExecutor::new()
8871/// # )
8872/// # .build(
8873/// #     hyper_rustls::HttpsConnectorBuilder::new()
8874/// #         .with_native_roots()
8875/// #         .unwrap()
8876/// #         .https_or_http()
8877/// #         .enable_http1()
8878/// #         .build()
8879/// # );
8880/// # let mut hub = NetworkSecurity::new(client, auth);
8881/// // You can configure optional parameters by calling the respective setters at will, and
8882/// // execute the final call using `doit()`.
8883/// // Values shown here are possibly random and not representative !
8884/// let result = hub.organizations().locations_operations_delete("name")
8885///              .doit().await;
8886/// # }
8887/// ```
8888pub struct OrganizationLocationOperationDeleteCall<'a, C>
8889where
8890    C: 'a,
8891{
8892    hub: &'a NetworkSecurity<C>,
8893    _name: String,
8894    _delegate: Option<&'a mut dyn common::Delegate>,
8895    _additional_params: HashMap<String, String>,
8896    _scopes: BTreeSet<String>,
8897}
8898
8899impl<'a, C> common::CallBuilder for OrganizationLocationOperationDeleteCall<'a, C> {}
8900
8901impl<'a, C> OrganizationLocationOperationDeleteCall<'a, C>
8902where
8903    C: common::Connector,
8904{
8905    /// Perform the operation you have build so far.
8906    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8907        use std::borrow::Cow;
8908        use std::io::{Read, Seek};
8909
8910        use common::{url::Params, ToParts};
8911        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8912
8913        let mut dd = common::DefaultDelegate;
8914        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8915        dlg.begin(common::MethodInfo {
8916            id: "networksecurity.organizations.locations.operations.delete",
8917            http_method: hyper::Method::DELETE,
8918        });
8919
8920        for &field in ["alt", "name"].iter() {
8921            if self._additional_params.contains_key(field) {
8922                dlg.finished(false);
8923                return Err(common::Error::FieldClash(field));
8924            }
8925        }
8926
8927        let mut params = Params::with_capacity(3 + self._additional_params.len());
8928        params.push("name", self._name);
8929
8930        params.extend(self._additional_params.iter());
8931
8932        params.push("alt", "json");
8933        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8934        if self._scopes.is_empty() {
8935            self._scopes
8936                .insert(Scope::CloudPlatform.as_ref().to_string());
8937        }
8938
8939        #[allow(clippy::single_element_loop)]
8940        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8941            url = params.uri_replacement(url, param_name, find_this, true);
8942        }
8943        {
8944            let to_remove = ["name"];
8945            params.remove_params(&to_remove);
8946        }
8947
8948        let url = params.parse_with_url(&url);
8949
8950        loop {
8951            let token = match self
8952                .hub
8953                .auth
8954                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8955                .await
8956            {
8957                Ok(token) => token,
8958                Err(e) => match dlg.token(e) {
8959                    Ok(token) => token,
8960                    Err(e) => {
8961                        dlg.finished(false);
8962                        return Err(common::Error::MissingToken(e));
8963                    }
8964                },
8965            };
8966            let mut req_result = {
8967                let client = &self.hub.client;
8968                dlg.pre_request();
8969                let mut req_builder = hyper::Request::builder()
8970                    .method(hyper::Method::DELETE)
8971                    .uri(url.as_str())
8972                    .header(USER_AGENT, self.hub._user_agent.clone());
8973
8974                if let Some(token) = token.as_ref() {
8975                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8976                }
8977
8978                let request = req_builder
8979                    .header(CONTENT_LENGTH, 0_u64)
8980                    .body(common::to_body::<String>(None));
8981
8982                client.request(request.unwrap()).await
8983            };
8984
8985            match req_result {
8986                Err(err) => {
8987                    if let common::Retry::After(d) = dlg.http_error(&err) {
8988                        sleep(d).await;
8989                        continue;
8990                    }
8991                    dlg.finished(false);
8992                    return Err(common::Error::HttpError(err));
8993                }
8994                Ok(res) => {
8995                    let (mut parts, body) = res.into_parts();
8996                    let mut body = common::Body::new(body);
8997                    if !parts.status.is_success() {
8998                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8999                        let error = serde_json::from_str(&common::to_string(&bytes));
9000                        let response = common::to_response(parts, bytes.into());
9001
9002                        if let common::Retry::After(d) =
9003                            dlg.http_failure(&response, error.as_ref().ok())
9004                        {
9005                            sleep(d).await;
9006                            continue;
9007                        }
9008
9009                        dlg.finished(false);
9010
9011                        return Err(match error {
9012                            Ok(value) => common::Error::BadRequest(value),
9013                            _ => common::Error::Failure(response),
9014                        });
9015                    }
9016                    let response = {
9017                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9018                        let encoded = common::to_string(&bytes);
9019                        match serde_json::from_str(&encoded) {
9020                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9021                            Err(error) => {
9022                                dlg.response_json_decode_error(&encoded, &error);
9023                                return Err(common::Error::JsonDecodeError(
9024                                    encoded.to_string(),
9025                                    error,
9026                                ));
9027                            }
9028                        }
9029                    };
9030
9031                    dlg.finished(true);
9032                    return Ok(response);
9033                }
9034            }
9035        }
9036    }
9037
9038    /// The name of the operation resource to be deleted.
9039    ///
9040    /// Sets the *name* path property to the given value.
9041    ///
9042    /// Even though the property as already been set when instantiating this call,
9043    /// we provide this method for API completeness.
9044    pub fn name(mut self, new_value: &str) -> OrganizationLocationOperationDeleteCall<'a, C> {
9045        self._name = new_value.to_string();
9046        self
9047    }
9048    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9049    /// while executing the actual API request.
9050    ///
9051    /// ````text
9052    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9053    /// ````
9054    ///
9055    /// Sets the *delegate* property to the given value.
9056    pub fn delegate(
9057        mut self,
9058        new_value: &'a mut dyn common::Delegate,
9059    ) -> OrganizationLocationOperationDeleteCall<'a, C> {
9060        self._delegate = Some(new_value);
9061        self
9062    }
9063
9064    /// Set any additional parameter of the query string used in the request.
9065    /// It should be used to set parameters which are not yet available through their own
9066    /// setters.
9067    ///
9068    /// Please note that this method must not be used to set any of the known parameters
9069    /// which have their own setter method. If done anyway, the request will fail.
9070    ///
9071    /// # Additional Parameters
9072    ///
9073    /// * *$.xgafv* (query-string) - V1 error format.
9074    /// * *access_token* (query-string) - OAuth access token.
9075    /// * *alt* (query-string) - Data format for response.
9076    /// * *callback* (query-string) - JSONP
9077    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9078    /// * *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.
9079    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9080    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9081    /// * *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.
9082    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9083    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9084    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationOperationDeleteCall<'a, C>
9085    where
9086        T: AsRef<str>,
9087    {
9088        self._additional_params
9089            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9090        self
9091    }
9092
9093    /// Identifies the authorization scope for the method you are building.
9094    ///
9095    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9096    /// [`Scope::CloudPlatform`].
9097    ///
9098    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9099    /// tokens for more than one scope.
9100    ///
9101    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9102    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9103    /// sufficient, a read-write scope will do as well.
9104    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationOperationDeleteCall<'a, C>
9105    where
9106        St: AsRef<str>,
9107    {
9108        self._scopes.insert(String::from(scope.as_ref()));
9109        self
9110    }
9111    /// Identifies the authorization scope(s) for the method you are building.
9112    ///
9113    /// See [`Self::add_scope()`] for details.
9114    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationOperationDeleteCall<'a, C>
9115    where
9116        I: IntoIterator<Item = St>,
9117        St: AsRef<str>,
9118    {
9119        self._scopes
9120            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9121        self
9122    }
9123
9124    /// Removes all scopes, and no default scope will be used either.
9125    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9126    /// for details).
9127    pub fn clear_scopes(mut self) -> OrganizationLocationOperationDeleteCall<'a, C> {
9128        self._scopes.clear();
9129        self
9130    }
9131}
9132
9133/// 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.
9134///
9135/// A builder for the *locations.operations.get* method supported by a *organization* resource.
9136/// It is not used directly, but through a [`OrganizationMethods`] instance.
9137///
9138/// # Example
9139///
9140/// Instantiate a resource method builder
9141///
9142/// ```test_harness,no_run
9143/// # extern crate hyper;
9144/// # extern crate hyper_rustls;
9145/// # extern crate google_networksecurity1 as networksecurity1;
9146/// # async fn dox() {
9147/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9148///
9149/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9150/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9151/// #     secret,
9152/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9153/// # ).build().await.unwrap();
9154///
9155/// # let client = hyper_util::client::legacy::Client::builder(
9156/// #     hyper_util::rt::TokioExecutor::new()
9157/// # )
9158/// # .build(
9159/// #     hyper_rustls::HttpsConnectorBuilder::new()
9160/// #         .with_native_roots()
9161/// #         .unwrap()
9162/// #         .https_or_http()
9163/// #         .enable_http1()
9164/// #         .build()
9165/// # );
9166/// # let mut hub = NetworkSecurity::new(client, auth);
9167/// // You can configure optional parameters by calling the respective setters at will, and
9168/// // execute the final call using `doit()`.
9169/// // Values shown here are possibly random and not representative !
9170/// let result = hub.organizations().locations_operations_get("name")
9171///              .doit().await;
9172/// # }
9173/// ```
9174pub struct OrganizationLocationOperationGetCall<'a, C>
9175where
9176    C: 'a,
9177{
9178    hub: &'a NetworkSecurity<C>,
9179    _name: String,
9180    _delegate: Option<&'a mut dyn common::Delegate>,
9181    _additional_params: HashMap<String, String>,
9182    _scopes: BTreeSet<String>,
9183}
9184
9185impl<'a, C> common::CallBuilder for OrganizationLocationOperationGetCall<'a, C> {}
9186
9187impl<'a, C> OrganizationLocationOperationGetCall<'a, C>
9188where
9189    C: common::Connector,
9190{
9191    /// Perform the operation you have build so far.
9192    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9193        use std::borrow::Cow;
9194        use std::io::{Read, Seek};
9195
9196        use common::{url::Params, ToParts};
9197        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9198
9199        let mut dd = common::DefaultDelegate;
9200        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9201        dlg.begin(common::MethodInfo {
9202            id: "networksecurity.organizations.locations.operations.get",
9203            http_method: hyper::Method::GET,
9204        });
9205
9206        for &field in ["alt", "name"].iter() {
9207            if self._additional_params.contains_key(field) {
9208                dlg.finished(false);
9209                return Err(common::Error::FieldClash(field));
9210            }
9211        }
9212
9213        let mut params = Params::with_capacity(3 + self._additional_params.len());
9214        params.push("name", self._name);
9215
9216        params.extend(self._additional_params.iter());
9217
9218        params.push("alt", "json");
9219        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9220        if self._scopes.is_empty() {
9221            self._scopes
9222                .insert(Scope::CloudPlatform.as_ref().to_string());
9223        }
9224
9225        #[allow(clippy::single_element_loop)]
9226        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9227            url = params.uri_replacement(url, param_name, find_this, true);
9228        }
9229        {
9230            let to_remove = ["name"];
9231            params.remove_params(&to_remove);
9232        }
9233
9234        let url = params.parse_with_url(&url);
9235
9236        loop {
9237            let token = match self
9238                .hub
9239                .auth
9240                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9241                .await
9242            {
9243                Ok(token) => token,
9244                Err(e) => match dlg.token(e) {
9245                    Ok(token) => token,
9246                    Err(e) => {
9247                        dlg.finished(false);
9248                        return Err(common::Error::MissingToken(e));
9249                    }
9250                },
9251            };
9252            let mut req_result = {
9253                let client = &self.hub.client;
9254                dlg.pre_request();
9255                let mut req_builder = hyper::Request::builder()
9256                    .method(hyper::Method::GET)
9257                    .uri(url.as_str())
9258                    .header(USER_AGENT, self.hub._user_agent.clone());
9259
9260                if let Some(token) = token.as_ref() {
9261                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9262                }
9263
9264                let request = req_builder
9265                    .header(CONTENT_LENGTH, 0_u64)
9266                    .body(common::to_body::<String>(None));
9267
9268                client.request(request.unwrap()).await
9269            };
9270
9271            match req_result {
9272                Err(err) => {
9273                    if let common::Retry::After(d) = dlg.http_error(&err) {
9274                        sleep(d).await;
9275                        continue;
9276                    }
9277                    dlg.finished(false);
9278                    return Err(common::Error::HttpError(err));
9279                }
9280                Ok(res) => {
9281                    let (mut parts, body) = res.into_parts();
9282                    let mut body = common::Body::new(body);
9283                    if !parts.status.is_success() {
9284                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9285                        let error = serde_json::from_str(&common::to_string(&bytes));
9286                        let response = common::to_response(parts, bytes.into());
9287
9288                        if let common::Retry::After(d) =
9289                            dlg.http_failure(&response, error.as_ref().ok())
9290                        {
9291                            sleep(d).await;
9292                            continue;
9293                        }
9294
9295                        dlg.finished(false);
9296
9297                        return Err(match error {
9298                            Ok(value) => common::Error::BadRequest(value),
9299                            _ => common::Error::Failure(response),
9300                        });
9301                    }
9302                    let response = {
9303                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9304                        let encoded = common::to_string(&bytes);
9305                        match serde_json::from_str(&encoded) {
9306                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9307                            Err(error) => {
9308                                dlg.response_json_decode_error(&encoded, &error);
9309                                return Err(common::Error::JsonDecodeError(
9310                                    encoded.to_string(),
9311                                    error,
9312                                ));
9313                            }
9314                        }
9315                    };
9316
9317                    dlg.finished(true);
9318                    return Ok(response);
9319                }
9320            }
9321        }
9322    }
9323
9324    /// The name of the operation resource.
9325    ///
9326    /// Sets the *name* path property to the given value.
9327    ///
9328    /// Even though the property as already been set when instantiating this call,
9329    /// we provide this method for API completeness.
9330    pub fn name(mut self, new_value: &str) -> OrganizationLocationOperationGetCall<'a, C> {
9331        self._name = new_value.to_string();
9332        self
9333    }
9334    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9335    /// while executing the actual API request.
9336    ///
9337    /// ````text
9338    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9339    /// ````
9340    ///
9341    /// Sets the *delegate* property to the given value.
9342    pub fn delegate(
9343        mut self,
9344        new_value: &'a mut dyn common::Delegate,
9345    ) -> OrganizationLocationOperationGetCall<'a, C> {
9346        self._delegate = Some(new_value);
9347        self
9348    }
9349
9350    /// Set any additional parameter of the query string used in the request.
9351    /// It should be used to set parameters which are not yet available through their own
9352    /// setters.
9353    ///
9354    /// Please note that this method must not be used to set any of the known parameters
9355    /// which have their own setter method. If done anyway, the request will fail.
9356    ///
9357    /// # Additional Parameters
9358    ///
9359    /// * *$.xgafv* (query-string) - V1 error format.
9360    /// * *access_token* (query-string) - OAuth access token.
9361    /// * *alt* (query-string) - Data format for response.
9362    /// * *callback* (query-string) - JSONP
9363    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9364    /// * *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.
9365    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9366    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9367    /// * *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.
9368    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9369    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9370    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationOperationGetCall<'a, C>
9371    where
9372        T: AsRef<str>,
9373    {
9374        self._additional_params
9375            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9376        self
9377    }
9378
9379    /// Identifies the authorization scope for the method you are building.
9380    ///
9381    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9382    /// [`Scope::CloudPlatform`].
9383    ///
9384    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9385    /// tokens for more than one scope.
9386    ///
9387    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9388    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9389    /// sufficient, a read-write scope will do as well.
9390    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationOperationGetCall<'a, C>
9391    where
9392        St: AsRef<str>,
9393    {
9394        self._scopes.insert(String::from(scope.as_ref()));
9395        self
9396    }
9397    /// Identifies the authorization scope(s) for the method you are building.
9398    ///
9399    /// See [`Self::add_scope()`] for details.
9400    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationOperationGetCall<'a, C>
9401    where
9402        I: IntoIterator<Item = St>,
9403        St: AsRef<str>,
9404    {
9405        self._scopes
9406            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9407        self
9408    }
9409
9410    /// Removes all scopes, and no default scope will be used either.
9411    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9412    /// for details).
9413    pub fn clear_scopes(mut self) -> OrganizationLocationOperationGetCall<'a, C> {
9414        self._scopes.clear();
9415        self
9416    }
9417}
9418
9419/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
9420///
9421/// A builder for the *locations.operations.list* method supported by a *organization* resource.
9422/// It is not used directly, but through a [`OrganizationMethods`] instance.
9423///
9424/// # Example
9425///
9426/// Instantiate a resource method builder
9427///
9428/// ```test_harness,no_run
9429/// # extern crate hyper;
9430/// # extern crate hyper_rustls;
9431/// # extern crate google_networksecurity1 as networksecurity1;
9432/// # async fn dox() {
9433/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9434///
9435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9436/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9437/// #     secret,
9438/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9439/// # ).build().await.unwrap();
9440///
9441/// # let client = hyper_util::client::legacy::Client::builder(
9442/// #     hyper_util::rt::TokioExecutor::new()
9443/// # )
9444/// # .build(
9445/// #     hyper_rustls::HttpsConnectorBuilder::new()
9446/// #         .with_native_roots()
9447/// #         .unwrap()
9448/// #         .https_or_http()
9449/// #         .enable_http1()
9450/// #         .build()
9451/// # );
9452/// # let mut hub = NetworkSecurity::new(client, auth);
9453/// // You can configure optional parameters by calling the respective setters at will, and
9454/// // execute the final call using `doit()`.
9455/// // Values shown here are possibly random and not representative !
9456/// let result = hub.organizations().locations_operations_list("name")
9457///              .page_token("kasd")
9458///              .page_size(-24)
9459///              .filter("sed")
9460///              .doit().await;
9461/// # }
9462/// ```
9463pub struct OrganizationLocationOperationListCall<'a, C>
9464where
9465    C: 'a,
9466{
9467    hub: &'a NetworkSecurity<C>,
9468    _name: String,
9469    _page_token: Option<String>,
9470    _page_size: Option<i32>,
9471    _filter: Option<String>,
9472    _delegate: Option<&'a mut dyn common::Delegate>,
9473    _additional_params: HashMap<String, String>,
9474    _scopes: BTreeSet<String>,
9475}
9476
9477impl<'a, C> common::CallBuilder for OrganizationLocationOperationListCall<'a, C> {}
9478
9479impl<'a, C> OrganizationLocationOperationListCall<'a, C>
9480where
9481    C: common::Connector,
9482{
9483    /// Perform the operation you have build so far.
9484    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
9485        use std::borrow::Cow;
9486        use std::io::{Read, Seek};
9487
9488        use common::{url::Params, ToParts};
9489        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9490
9491        let mut dd = common::DefaultDelegate;
9492        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9493        dlg.begin(common::MethodInfo {
9494            id: "networksecurity.organizations.locations.operations.list",
9495            http_method: hyper::Method::GET,
9496        });
9497
9498        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
9499            if self._additional_params.contains_key(field) {
9500                dlg.finished(false);
9501                return Err(common::Error::FieldClash(field));
9502            }
9503        }
9504
9505        let mut params = Params::with_capacity(6 + self._additional_params.len());
9506        params.push("name", self._name);
9507        if let Some(value) = self._page_token.as_ref() {
9508            params.push("pageToken", value);
9509        }
9510        if let Some(value) = self._page_size.as_ref() {
9511            params.push("pageSize", value.to_string());
9512        }
9513        if let Some(value) = self._filter.as_ref() {
9514            params.push("filter", value);
9515        }
9516
9517        params.extend(self._additional_params.iter());
9518
9519        params.push("alt", "json");
9520        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
9521        if self._scopes.is_empty() {
9522            self._scopes
9523                .insert(Scope::CloudPlatform.as_ref().to_string());
9524        }
9525
9526        #[allow(clippy::single_element_loop)]
9527        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9528            url = params.uri_replacement(url, param_name, find_this, true);
9529        }
9530        {
9531            let to_remove = ["name"];
9532            params.remove_params(&to_remove);
9533        }
9534
9535        let url = params.parse_with_url(&url);
9536
9537        loop {
9538            let token = match self
9539                .hub
9540                .auth
9541                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9542                .await
9543            {
9544                Ok(token) => token,
9545                Err(e) => match dlg.token(e) {
9546                    Ok(token) => token,
9547                    Err(e) => {
9548                        dlg.finished(false);
9549                        return Err(common::Error::MissingToken(e));
9550                    }
9551                },
9552            };
9553            let mut req_result = {
9554                let client = &self.hub.client;
9555                dlg.pre_request();
9556                let mut req_builder = hyper::Request::builder()
9557                    .method(hyper::Method::GET)
9558                    .uri(url.as_str())
9559                    .header(USER_AGENT, self.hub._user_agent.clone());
9560
9561                if let Some(token) = token.as_ref() {
9562                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9563                }
9564
9565                let request = req_builder
9566                    .header(CONTENT_LENGTH, 0_u64)
9567                    .body(common::to_body::<String>(None));
9568
9569                client.request(request.unwrap()).await
9570            };
9571
9572            match req_result {
9573                Err(err) => {
9574                    if let common::Retry::After(d) = dlg.http_error(&err) {
9575                        sleep(d).await;
9576                        continue;
9577                    }
9578                    dlg.finished(false);
9579                    return Err(common::Error::HttpError(err));
9580                }
9581                Ok(res) => {
9582                    let (mut parts, body) = res.into_parts();
9583                    let mut body = common::Body::new(body);
9584                    if !parts.status.is_success() {
9585                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9586                        let error = serde_json::from_str(&common::to_string(&bytes));
9587                        let response = common::to_response(parts, bytes.into());
9588
9589                        if let common::Retry::After(d) =
9590                            dlg.http_failure(&response, error.as_ref().ok())
9591                        {
9592                            sleep(d).await;
9593                            continue;
9594                        }
9595
9596                        dlg.finished(false);
9597
9598                        return Err(match error {
9599                            Ok(value) => common::Error::BadRequest(value),
9600                            _ => common::Error::Failure(response),
9601                        });
9602                    }
9603                    let response = {
9604                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9605                        let encoded = common::to_string(&bytes);
9606                        match serde_json::from_str(&encoded) {
9607                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9608                            Err(error) => {
9609                                dlg.response_json_decode_error(&encoded, &error);
9610                                return Err(common::Error::JsonDecodeError(
9611                                    encoded.to_string(),
9612                                    error,
9613                                ));
9614                            }
9615                        }
9616                    };
9617
9618                    dlg.finished(true);
9619                    return Ok(response);
9620                }
9621            }
9622        }
9623    }
9624
9625    /// The name of the operation's parent resource.
9626    ///
9627    /// Sets the *name* path property to the given value.
9628    ///
9629    /// Even though the property as already been set when instantiating this call,
9630    /// we provide this method for API completeness.
9631    pub fn name(mut self, new_value: &str) -> OrganizationLocationOperationListCall<'a, C> {
9632        self._name = new_value.to_string();
9633        self
9634    }
9635    /// The standard list page token.
9636    ///
9637    /// Sets the *page token* query property to the given value.
9638    pub fn page_token(mut self, new_value: &str) -> OrganizationLocationOperationListCall<'a, C> {
9639        self._page_token = Some(new_value.to_string());
9640        self
9641    }
9642    /// The standard list page size.
9643    ///
9644    /// Sets the *page size* query property to the given value.
9645    pub fn page_size(mut self, new_value: i32) -> OrganizationLocationOperationListCall<'a, C> {
9646        self._page_size = Some(new_value);
9647        self
9648    }
9649    /// The standard list filter.
9650    ///
9651    /// Sets the *filter* query property to the given value.
9652    pub fn filter(mut self, new_value: &str) -> OrganizationLocationOperationListCall<'a, C> {
9653        self._filter = Some(new_value.to_string());
9654        self
9655    }
9656    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9657    /// while executing the actual API request.
9658    ///
9659    /// ````text
9660    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9661    /// ````
9662    ///
9663    /// Sets the *delegate* property to the given value.
9664    pub fn delegate(
9665        mut self,
9666        new_value: &'a mut dyn common::Delegate,
9667    ) -> OrganizationLocationOperationListCall<'a, C> {
9668        self._delegate = Some(new_value);
9669        self
9670    }
9671
9672    /// Set any additional parameter of the query string used in the request.
9673    /// It should be used to set parameters which are not yet available through their own
9674    /// setters.
9675    ///
9676    /// Please note that this method must not be used to set any of the known parameters
9677    /// which have their own setter method. If done anyway, the request will fail.
9678    ///
9679    /// # Additional Parameters
9680    ///
9681    /// * *$.xgafv* (query-string) - V1 error format.
9682    /// * *access_token* (query-string) - OAuth access token.
9683    /// * *alt* (query-string) - Data format for response.
9684    /// * *callback* (query-string) - JSONP
9685    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9686    /// * *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.
9687    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9688    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9689    /// * *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.
9690    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9691    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9692    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationOperationListCall<'a, C>
9693    where
9694        T: AsRef<str>,
9695    {
9696        self._additional_params
9697            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9698        self
9699    }
9700
9701    /// Identifies the authorization scope for the method you are building.
9702    ///
9703    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9704    /// [`Scope::CloudPlatform`].
9705    ///
9706    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9707    /// tokens for more than one scope.
9708    ///
9709    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9710    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9711    /// sufficient, a read-write scope will do as well.
9712    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationOperationListCall<'a, C>
9713    where
9714        St: AsRef<str>,
9715    {
9716        self._scopes.insert(String::from(scope.as_ref()));
9717        self
9718    }
9719    /// Identifies the authorization scope(s) for the method you are building.
9720    ///
9721    /// See [`Self::add_scope()`] for details.
9722    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationOperationListCall<'a, C>
9723    where
9724        I: IntoIterator<Item = St>,
9725        St: AsRef<str>,
9726    {
9727        self._scopes
9728            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9729        self
9730    }
9731
9732    /// Removes all scopes, and no default scope will be used either.
9733    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9734    /// for details).
9735    pub fn clear_scopes(mut self) -> OrganizationLocationOperationListCall<'a, C> {
9736        self._scopes.clear();
9737        self
9738    }
9739}
9740
9741/// Creates a new SecurityProfileGroup in a given organization and location.
9742///
9743/// A builder for the *locations.securityProfileGroups.create* method supported by a *organization* resource.
9744/// It is not used directly, but through a [`OrganizationMethods`] instance.
9745///
9746/// # Example
9747///
9748/// Instantiate a resource method builder
9749///
9750/// ```test_harness,no_run
9751/// # extern crate hyper;
9752/// # extern crate hyper_rustls;
9753/// # extern crate google_networksecurity1 as networksecurity1;
9754/// use networksecurity1::api::SecurityProfileGroup;
9755/// # async fn dox() {
9756/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9757///
9758/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9760/// #     secret,
9761/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9762/// # ).build().await.unwrap();
9763///
9764/// # let client = hyper_util::client::legacy::Client::builder(
9765/// #     hyper_util::rt::TokioExecutor::new()
9766/// # )
9767/// # .build(
9768/// #     hyper_rustls::HttpsConnectorBuilder::new()
9769/// #         .with_native_roots()
9770/// #         .unwrap()
9771/// #         .https_or_http()
9772/// #         .enable_http1()
9773/// #         .build()
9774/// # );
9775/// # let mut hub = NetworkSecurity::new(client, auth);
9776/// // As the method needs a request, you would usually fill it with the desired information
9777/// // into the respective structure. Some of the parts shown here might not be applicable !
9778/// // Values shown here are possibly random and not representative !
9779/// let mut req = SecurityProfileGroup::default();
9780///
9781/// // You can configure optional parameters by calling the respective setters at will, and
9782/// // execute the final call using `doit()`.
9783/// // Values shown here are possibly random and not representative !
9784/// let result = hub.organizations().locations_security_profile_groups_create(req, "parent")
9785///              .security_profile_group_id("et")
9786///              .doit().await;
9787/// # }
9788/// ```
9789pub struct OrganizationLocationSecurityProfileGroupCreateCall<'a, C>
9790where
9791    C: 'a,
9792{
9793    hub: &'a NetworkSecurity<C>,
9794    _request: SecurityProfileGroup,
9795    _parent: String,
9796    _security_profile_group_id: Option<String>,
9797    _delegate: Option<&'a mut dyn common::Delegate>,
9798    _additional_params: HashMap<String, String>,
9799    _scopes: BTreeSet<String>,
9800}
9801
9802impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {}
9803
9804impl<'a, C> OrganizationLocationSecurityProfileGroupCreateCall<'a, C>
9805where
9806    C: common::Connector,
9807{
9808    /// Perform the operation you have build so far.
9809    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9810        use std::borrow::Cow;
9811        use std::io::{Read, Seek};
9812
9813        use common::{url::Params, ToParts};
9814        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9815
9816        let mut dd = common::DefaultDelegate;
9817        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9818        dlg.begin(common::MethodInfo {
9819            id: "networksecurity.organizations.locations.securityProfileGroups.create",
9820            http_method: hyper::Method::POST,
9821        });
9822
9823        for &field in ["alt", "parent", "securityProfileGroupId"].iter() {
9824            if self._additional_params.contains_key(field) {
9825                dlg.finished(false);
9826                return Err(common::Error::FieldClash(field));
9827            }
9828        }
9829
9830        let mut params = Params::with_capacity(5 + self._additional_params.len());
9831        params.push("parent", self._parent);
9832        if let Some(value) = self._security_profile_group_id.as_ref() {
9833            params.push("securityProfileGroupId", value);
9834        }
9835
9836        params.extend(self._additional_params.iter());
9837
9838        params.push("alt", "json");
9839        let mut url = self.hub._base_url.clone() + "v1/{+parent}/securityProfileGroups";
9840        if self._scopes.is_empty() {
9841            self._scopes
9842                .insert(Scope::CloudPlatform.as_ref().to_string());
9843        }
9844
9845        #[allow(clippy::single_element_loop)]
9846        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9847            url = params.uri_replacement(url, param_name, find_this, true);
9848        }
9849        {
9850            let to_remove = ["parent"];
9851            params.remove_params(&to_remove);
9852        }
9853
9854        let url = params.parse_with_url(&url);
9855
9856        let mut json_mime_type = mime::APPLICATION_JSON;
9857        let mut request_value_reader = {
9858            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9859            common::remove_json_null_values(&mut value);
9860            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9861            serde_json::to_writer(&mut dst, &value).unwrap();
9862            dst
9863        };
9864        let request_size = request_value_reader
9865            .seek(std::io::SeekFrom::End(0))
9866            .unwrap();
9867        request_value_reader
9868            .seek(std::io::SeekFrom::Start(0))
9869            .unwrap();
9870
9871        loop {
9872            let token = match self
9873                .hub
9874                .auth
9875                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9876                .await
9877            {
9878                Ok(token) => token,
9879                Err(e) => match dlg.token(e) {
9880                    Ok(token) => token,
9881                    Err(e) => {
9882                        dlg.finished(false);
9883                        return Err(common::Error::MissingToken(e));
9884                    }
9885                },
9886            };
9887            request_value_reader
9888                .seek(std::io::SeekFrom::Start(0))
9889                .unwrap();
9890            let mut req_result = {
9891                let client = &self.hub.client;
9892                dlg.pre_request();
9893                let mut req_builder = hyper::Request::builder()
9894                    .method(hyper::Method::POST)
9895                    .uri(url.as_str())
9896                    .header(USER_AGENT, self.hub._user_agent.clone());
9897
9898                if let Some(token) = token.as_ref() {
9899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9900                }
9901
9902                let request = req_builder
9903                    .header(CONTENT_TYPE, json_mime_type.to_string())
9904                    .header(CONTENT_LENGTH, request_size as u64)
9905                    .body(common::to_body(
9906                        request_value_reader.get_ref().clone().into(),
9907                    ));
9908
9909                client.request(request.unwrap()).await
9910            };
9911
9912            match req_result {
9913                Err(err) => {
9914                    if let common::Retry::After(d) = dlg.http_error(&err) {
9915                        sleep(d).await;
9916                        continue;
9917                    }
9918                    dlg.finished(false);
9919                    return Err(common::Error::HttpError(err));
9920                }
9921                Ok(res) => {
9922                    let (mut parts, body) = res.into_parts();
9923                    let mut body = common::Body::new(body);
9924                    if !parts.status.is_success() {
9925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9926                        let error = serde_json::from_str(&common::to_string(&bytes));
9927                        let response = common::to_response(parts, bytes.into());
9928
9929                        if let common::Retry::After(d) =
9930                            dlg.http_failure(&response, error.as_ref().ok())
9931                        {
9932                            sleep(d).await;
9933                            continue;
9934                        }
9935
9936                        dlg.finished(false);
9937
9938                        return Err(match error {
9939                            Ok(value) => common::Error::BadRequest(value),
9940                            _ => common::Error::Failure(response),
9941                        });
9942                    }
9943                    let response = {
9944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9945                        let encoded = common::to_string(&bytes);
9946                        match serde_json::from_str(&encoded) {
9947                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9948                            Err(error) => {
9949                                dlg.response_json_decode_error(&encoded, &error);
9950                                return Err(common::Error::JsonDecodeError(
9951                                    encoded.to_string(),
9952                                    error,
9953                                ));
9954                            }
9955                        }
9956                    };
9957
9958                    dlg.finished(true);
9959                    return Ok(response);
9960                }
9961            }
9962        }
9963    }
9964
9965    ///
9966    /// Sets the *request* property to the given value.
9967    ///
9968    /// Even though the property as already been set when instantiating this call,
9969    /// we provide this method for API completeness.
9970    pub fn request(
9971        mut self,
9972        new_value: SecurityProfileGroup,
9973    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {
9974        self._request = new_value;
9975        self
9976    }
9977    /// Required. The parent resource of the SecurityProfileGroup. Must be in the format `projects|organizations/*/locations/{location}`.
9978    ///
9979    /// Sets the *parent* path property to the given value.
9980    ///
9981    /// Even though the property as already been set when instantiating this call,
9982    /// we provide this method for API completeness.
9983    pub fn parent(
9984        mut self,
9985        new_value: &str,
9986    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {
9987        self._parent = new_value.to_string();
9988        self
9989    }
9990    /// Required. Short name of the SecurityProfileGroup resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "security_profile_group1".
9991    ///
9992    /// Sets the *security profile group id* query property to the given value.
9993    pub fn security_profile_group_id(
9994        mut self,
9995        new_value: &str,
9996    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {
9997        self._security_profile_group_id = Some(new_value.to_string());
9998        self
9999    }
10000    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10001    /// while executing the actual API request.
10002    ///
10003    /// ````text
10004    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10005    /// ````
10006    ///
10007    /// Sets the *delegate* property to the given value.
10008    pub fn delegate(
10009        mut self,
10010        new_value: &'a mut dyn common::Delegate,
10011    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {
10012        self._delegate = Some(new_value);
10013        self
10014    }
10015
10016    /// Set any additional parameter of the query string used in the request.
10017    /// It should be used to set parameters which are not yet available through their own
10018    /// setters.
10019    ///
10020    /// Please note that this method must not be used to set any of the known parameters
10021    /// which have their own setter method. If done anyway, the request will fail.
10022    ///
10023    /// # Additional Parameters
10024    ///
10025    /// * *$.xgafv* (query-string) - V1 error format.
10026    /// * *access_token* (query-string) - OAuth access token.
10027    /// * *alt* (query-string) - Data format for response.
10028    /// * *callback* (query-string) - JSONP
10029    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10030    /// * *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.
10031    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10032    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10033    /// * *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.
10034    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10035    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10036    pub fn param<T>(
10037        mut self,
10038        name: T,
10039        value: T,
10040    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C>
10041    where
10042        T: AsRef<str>,
10043    {
10044        self._additional_params
10045            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10046        self
10047    }
10048
10049    /// Identifies the authorization scope for the method you are building.
10050    ///
10051    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10052    /// [`Scope::CloudPlatform`].
10053    ///
10054    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10055    /// tokens for more than one scope.
10056    ///
10057    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10058    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10059    /// sufficient, a read-write scope will do as well.
10060    pub fn add_scope<St>(
10061        mut self,
10062        scope: St,
10063    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C>
10064    where
10065        St: AsRef<str>,
10066    {
10067        self._scopes.insert(String::from(scope.as_ref()));
10068        self
10069    }
10070    /// Identifies the authorization scope(s) for the method you are building.
10071    ///
10072    /// See [`Self::add_scope()`] for details.
10073    pub fn add_scopes<I, St>(
10074        mut self,
10075        scopes: I,
10076    ) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C>
10077    where
10078        I: IntoIterator<Item = St>,
10079        St: AsRef<str>,
10080    {
10081        self._scopes
10082            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10083        self
10084    }
10085
10086    /// Removes all scopes, and no default scope will be used either.
10087    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10088    /// for details).
10089    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileGroupCreateCall<'a, C> {
10090        self._scopes.clear();
10091        self
10092    }
10093}
10094
10095/// Deletes a single SecurityProfileGroup.
10096///
10097/// A builder for the *locations.securityProfileGroups.delete* method supported by a *organization* resource.
10098/// It is not used directly, but through a [`OrganizationMethods`] instance.
10099///
10100/// # Example
10101///
10102/// Instantiate a resource method builder
10103///
10104/// ```test_harness,no_run
10105/// # extern crate hyper;
10106/// # extern crate hyper_rustls;
10107/// # extern crate google_networksecurity1 as networksecurity1;
10108/// # async fn dox() {
10109/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10110///
10111/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10112/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10113/// #     secret,
10114/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10115/// # ).build().await.unwrap();
10116///
10117/// # let client = hyper_util::client::legacy::Client::builder(
10118/// #     hyper_util::rt::TokioExecutor::new()
10119/// # )
10120/// # .build(
10121/// #     hyper_rustls::HttpsConnectorBuilder::new()
10122/// #         .with_native_roots()
10123/// #         .unwrap()
10124/// #         .https_or_http()
10125/// #         .enable_http1()
10126/// #         .build()
10127/// # );
10128/// # let mut hub = NetworkSecurity::new(client, auth);
10129/// // You can configure optional parameters by calling the respective setters at will, and
10130/// // execute the final call using `doit()`.
10131/// // Values shown here are possibly random and not representative !
10132/// let result = hub.organizations().locations_security_profile_groups_delete("name")
10133///              .etag("erat")
10134///              .doit().await;
10135/// # }
10136/// ```
10137pub struct OrganizationLocationSecurityProfileGroupDeleteCall<'a, C>
10138where
10139    C: 'a,
10140{
10141    hub: &'a NetworkSecurity<C>,
10142    _name: String,
10143    _etag: Option<String>,
10144    _delegate: Option<&'a mut dyn common::Delegate>,
10145    _additional_params: HashMap<String, String>,
10146    _scopes: BTreeSet<String>,
10147}
10148
10149impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileGroupDeleteCall<'a, C> {}
10150
10151impl<'a, C> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C>
10152where
10153    C: common::Connector,
10154{
10155    /// Perform the operation you have build so far.
10156    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10157        use std::borrow::Cow;
10158        use std::io::{Read, Seek};
10159
10160        use common::{url::Params, ToParts};
10161        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10162
10163        let mut dd = common::DefaultDelegate;
10164        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10165        dlg.begin(common::MethodInfo {
10166            id: "networksecurity.organizations.locations.securityProfileGroups.delete",
10167            http_method: hyper::Method::DELETE,
10168        });
10169
10170        for &field in ["alt", "name", "etag"].iter() {
10171            if self._additional_params.contains_key(field) {
10172                dlg.finished(false);
10173                return Err(common::Error::FieldClash(field));
10174            }
10175        }
10176
10177        let mut params = Params::with_capacity(4 + self._additional_params.len());
10178        params.push("name", self._name);
10179        if let Some(value) = self._etag.as_ref() {
10180            params.push("etag", value);
10181        }
10182
10183        params.extend(self._additional_params.iter());
10184
10185        params.push("alt", "json");
10186        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10187        if self._scopes.is_empty() {
10188            self._scopes
10189                .insert(Scope::CloudPlatform.as_ref().to_string());
10190        }
10191
10192        #[allow(clippy::single_element_loop)]
10193        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10194            url = params.uri_replacement(url, param_name, find_this, true);
10195        }
10196        {
10197            let to_remove = ["name"];
10198            params.remove_params(&to_remove);
10199        }
10200
10201        let url = params.parse_with_url(&url);
10202
10203        loop {
10204            let token = match self
10205                .hub
10206                .auth
10207                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10208                .await
10209            {
10210                Ok(token) => token,
10211                Err(e) => match dlg.token(e) {
10212                    Ok(token) => token,
10213                    Err(e) => {
10214                        dlg.finished(false);
10215                        return Err(common::Error::MissingToken(e));
10216                    }
10217                },
10218            };
10219            let mut req_result = {
10220                let client = &self.hub.client;
10221                dlg.pre_request();
10222                let mut req_builder = hyper::Request::builder()
10223                    .method(hyper::Method::DELETE)
10224                    .uri(url.as_str())
10225                    .header(USER_AGENT, self.hub._user_agent.clone());
10226
10227                if let Some(token) = token.as_ref() {
10228                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10229                }
10230
10231                let request = req_builder
10232                    .header(CONTENT_LENGTH, 0_u64)
10233                    .body(common::to_body::<String>(None));
10234
10235                client.request(request.unwrap()).await
10236            };
10237
10238            match req_result {
10239                Err(err) => {
10240                    if let common::Retry::After(d) = dlg.http_error(&err) {
10241                        sleep(d).await;
10242                        continue;
10243                    }
10244                    dlg.finished(false);
10245                    return Err(common::Error::HttpError(err));
10246                }
10247                Ok(res) => {
10248                    let (mut parts, body) = res.into_parts();
10249                    let mut body = common::Body::new(body);
10250                    if !parts.status.is_success() {
10251                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10252                        let error = serde_json::from_str(&common::to_string(&bytes));
10253                        let response = common::to_response(parts, bytes.into());
10254
10255                        if let common::Retry::After(d) =
10256                            dlg.http_failure(&response, error.as_ref().ok())
10257                        {
10258                            sleep(d).await;
10259                            continue;
10260                        }
10261
10262                        dlg.finished(false);
10263
10264                        return Err(match error {
10265                            Ok(value) => common::Error::BadRequest(value),
10266                            _ => common::Error::Failure(response),
10267                        });
10268                    }
10269                    let response = {
10270                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10271                        let encoded = common::to_string(&bytes);
10272                        match serde_json::from_str(&encoded) {
10273                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10274                            Err(error) => {
10275                                dlg.response_json_decode_error(&encoded, &error);
10276                                return Err(common::Error::JsonDecodeError(
10277                                    encoded.to_string(),
10278                                    error,
10279                                ));
10280                            }
10281                        }
10282                    };
10283
10284                    dlg.finished(true);
10285                    return Ok(response);
10286                }
10287            }
10288        }
10289    }
10290
10291    /// Required. A name of the SecurityProfileGroup to delete. Must be in the format `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
10292    ///
10293    /// Sets the *name* path property to the given value.
10294    ///
10295    /// Even though the property as already been set when instantiating this call,
10296    /// we provide this method for API completeness.
10297    pub fn name(
10298        mut self,
10299        new_value: &str,
10300    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C> {
10301        self._name = new_value.to_string();
10302        self
10303    }
10304    /// Optional. If client provided etag is out of date, delete will return FAILED_PRECONDITION error.
10305    ///
10306    /// Sets the *etag* query property to the given value.
10307    pub fn etag(
10308        mut self,
10309        new_value: &str,
10310    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C> {
10311        self._etag = Some(new_value.to_string());
10312        self
10313    }
10314    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10315    /// while executing the actual API request.
10316    ///
10317    /// ````text
10318    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10319    /// ````
10320    ///
10321    /// Sets the *delegate* property to the given value.
10322    pub fn delegate(
10323        mut self,
10324        new_value: &'a mut dyn common::Delegate,
10325    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C> {
10326        self._delegate = Some(new_value);
10327        self
10328    }
10329
10330    /// Set any additional parameter of the query string used in the request.
10331    /// It should be used to set parameters which are not yet available through their own
10332    /// setters.
10333    ///
10334    /// Please note that this method must not be used to set any of the known parameters
10335    /// which have their own setter method. If done anyway, the request will fail.
10336    ///
10337    /// # Additional Parameters
10338    ///
10339    /// * *$.xgafv* (query-string) - V1 error format.
10340    /// * *access_token* (query-string) - OAuth access token.
10341    /// * *alt* (query-string) - Data format for response.
10342    /// * *callback* (query-string) - JSONP
10343    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10344    /// * *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.
10345    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10346    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10347    /// * *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.
10348    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10349    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10350    pub fn param<T>(
10351        mut self,
10352        name: T,
10353        value: T,
10354    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C>
10355    where
10356        T: AsRef<str>,
10357    {
10358        self._additional_params
10359            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10360        self
10361    }
10362
10363    /// Identifies the authorization scope for the method you are building.
10364    ///
10365    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10366    /// [`Scope::CloudPlatform`].
10367    ///
10368    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10369    /// tokens for more than one scope.
10370    ///
10371    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10372    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10373    /// sufficient, a read-write scope will do as well.
10374    pub fn add_scope<St>(
10375        mut self,
10376        scope: St,
10377    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C>
10378    where
10379        St: AsRef<str>,
10380    {
10381        self._scopes.insert(String::from(scope.as_ref()));
10382        self
10383    }
10384    /// Identifies the authorization scope(s) for the method you are building.
10385    ///
10386    /// See [`Self::add_scope()`] for details.
10387    pub fn add_scopes<I, St>(
10388        mut self,
10389        scopes: I,
10390    ) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C>
10391    where
10392        I: IntoIterator<Item = St>,
10393        St: AsRef<str>,
10394    {
10395        self._scopes
10396            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10397        self
10398    }
10399
10400    /// Removes all scopes, and no default scope will be used either.
10401    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10402    /// for details).
10403    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileGroupDeleteCall<'a, C> {
10404        self._scopes.clear();
10405        self
10406    }
10407}
10408
10409/// Gets details of a single SecurityProfileGroup.
10410///
10411/// A builder for the *locations.securityProfileGroups.get* method supported by a *organization* resource.
10412/// It is not used directly, but through a [`OrganizationMethods`] instance.
10413///
10414/// # Example
10415///
10416/// Instantiate a resource method builder
10417///
10418/// ```test_harness,no_run
10419/// # extern crate hyper;
10420/// # extern crate hyper_rustls;
10421/// # extern crate google_networksecurity1 as networksecurity1;
10422/// # async fn dox() {
10423/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10424///
10425/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10426/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10427/// #     secret,
10428/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10429/// # ).build().await.unwrap();
10430///
10431/// # let client = hyper_util::client::legacy::Client::builder(
10432/// #     hyper_util::rt::TokioExecutor::new()
10433/// # )
10434/// # .build(
10435/// #     hyper_rustls::HttpsConnectorBuilder::new()
10436/// #         .with_native_roots()
10437/// #         .unwrap()
10438/// #         .https_or_http()
10439/// #         .enable_http1()
10440/// #         .build()
10441/// # );
10442/// # let mut hub = NetworkSecurity::new(client, auth);
10443/// // You can configure optional parameters by calling the respective setters at will, and
10444/// // execute the final call using `doit()`.
10445/// // Values shown here are possibly random and not representative !
10446/// let result = hub.organizations().locations_security_profile_groups_get("name")
10447///              .doit().await;
10448/// # }
10449/// ```
10450pub struct OrganizationLocationSecurityProfileGroupGetCall<'a, C>
10451where
10452    C: 'a,
10453{
10454    hub: &'a NetworkSecurity<C>,
10455    _name: String,
10456    _delegate: Option<&'a mut dyn common::Delegate>,
10457    _additional_params: HashMap<String, String>,
10458    _scopes: BTreeSet<String>,
10459}
10460
10461impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileGroupGetCall<'a, C> {}
10462
10463impl<'a, C> OrganizationLocationSecurityProfileGroupGetCall<'a, C>
10464where
10465    C: common::Connector,
10466{
10467    /// Perform the operation you have build so far.
10468    pub async fn doit(mut self) -> common::Result<(common::Response, SecurityProfileGroup)> {
10469        use std::borrow::Cow;
10470        use std::io::{Read, Seek};
10471
10472        use common::{url::Params, ToParts};
10473        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10474
10475        let mut dd = common::DefaultDelegate;
10476        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10477        dlg.begin(common::MethodInfo {
10478            id: "networksecurity.organizations.locations.securityProfileGroups.get",
10479            http_method: hyper::Method::GET,
10480        });
10481
10482        for &field in ["alt", "name"].iter() {
10483            if self._additional_params.contains_key(field) {
10484                dlg.finished(false);
10485                return Err(common::Error::FieldClash(field));
10486            }
10487        }
10488
10489        let mut params = Params::with_capacity(3 + self._additional_params.len());
10490        params.push("name", self._name);
10491
10492        params.extend(self._additional_params.iter());
10493
10494        params.push("alt", "json");
10495        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10496        if self._scopes.is_empty() {
10497            self._scopes
10498                .insert(Scope::CloudPlatform.as_ref().to_string());
10499        }
10500
10501        #[allow(clippy::single_element_loop)]
10502        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10503            url = params.uri_replacement(url, param_name, find_this, true);
10504        }
10505        {
10506            let to_remove = ["name"];
10507            params.remove_params(&to_remove);
10508        }
10509
10510        let url = params.parse_with_url(&url);
10511
10512        loop {
10513            let token = match self
10514                .hub
10515                .auth
10516                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10517                .await
10518            {
10519                Ok(token) => token,
10520                Err(e) => match dlg.token(e) {
10521                    Ok(token) => token,
10522                    Err(e) => {
10523                        dlg.finished(false);
10524                        return Err(common::Error::MissingToken(e));
10525                    }
10526                },
10527            };
10528            let mut req_result = {
10529                let client = &self.hub.client;
10530                dlg.pre_request();
10531                let mut req_builder = hyper::Request::builder()
10532                    .method(hyper::Method::GET)
10533                    .uri(url.as_str())
10534                    .header(USER_AGENT, self.hub._user_agent.clone());
10535
10536                if let Some(token) = token.as_ref() {
10537                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10538                }
10539
10540                let request = req_builder
10541                    .header(CONTENT_LENGTH, 0_u64)
10542                    .body(common::to_body::<String>(None));
10543
10544                client.request(request.unwrap()).await
10545            };
10546
10547            match req_result {
10548                Err(err) => {
10549                    if let common::Retry::After(d) = dlg.http_error(&err) {
10550                        sleep(d).await;
10551                        continue;
10552                    }
10553                    dlg.finished(false);
10554                    return Err(common::Error::HttpError(err));
10555                }
10556                Ok(res) => {
10557                    let (mut parts, body) = res.into_parts();
10558                    let mut body = common::Body::new(body);
10559                    if !parts.status.is_success() {
10560                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10561                        let error = serde_json::from_str(&common::to_string(&bytes));
10562                        let response = common::to_response(parts, bytes.into());
10563
10564                        if let common::Retry::After(d) =
10565                            dlg.http_failure(&response, error.as_ref().ok())
10566                        {
10567                            sleep(d).await;
10568                            continue;
10569                        }
10570
10571                        dlg.finished(false);
10572
10573                        return Err(match error {
10574                            Ok(value) => common::Error::BadRequest(value),
10575                            _ => common::Error::Failure(response),
10576                        });
10577                    }
10578                    let response = {
10579                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10580                        let encoded = common::to_string(&bytes);
10581                        match serde_json::from_str(&encoded) {
10582                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10583                            Err(error) => {
10584                                dlg.response_json_decode_error(&encoded, &error);
10585                                return Err(common::Error::JsonDecodeError(
10586                                    encoded.to_string(),
10587                                    error,
10588                                ));
10589                            }
10590                        }
10591                    };
10592
10593                    dlg.finished(true);
10594                    return Ok(response);
10595                }
10596            }
10597        }
10598    }
10599
10600    /// Required. A name of the SecurityProfileGroup to get. Must be in the format `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
10601    ///
10602    /// Sets the *name* path property to the given value.
10603    ///
10604    /// Even though the property as already been set when instantiating this call,
10605    /// we provide this method for API completeness.
10606    pub fn name(
10607        mut self,
10608        new_value: &str,
10609    ) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C> {
10610        self._name = new_value.to_string();
10611        self
10612    }
10613    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10614    /// while executing the actual API request.
10615    ///
10616    /// ````text
10617    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10618    /// ````
10619    ///
10620    /// Sets the *delegate* property to the given value.
10621    pub fn delegate(
10622        mut self,
10623        new_value: &'a mut dyn common::Delegate,
10624    ) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C> {
10625        self._delegate = Some(new_value);
10626        self
10627    }
10628
10629    /// Set any additional parameter of the query string used in the request.
10630    /// It should be used to set parameters which are not yet available through their own
10631    /// setters.
10632    ///
10633    /// Please note that this method must not be used to set any of the known parameters
10634    /// which have their own setter method. If done anyway, the request will fail.
10635    ///
10636    /// # Additional Parameters
10637    ///
10638    /// * *$.xgafv* (query-string) - V1 error format.
10639    /// * *access_token* (query-string) - OAuth access token.
10640    /// * *alt* (query-string) - Data format for response.
10641    /// * *callback* (query-string) - JSONP
10642    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10643    /// * *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.
10644    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10645    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10646    /// * *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.
10647    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10648    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10649    pub fn param<T>(
10650        mut self,
10651        name: T,
10652        value: T,
10653    ) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C>
10654    where
10655        T: AsRef<str>,
10656    {
10657        self._additional_params
10658            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10659        self
10660    }
10661
10662    /// Identifies the authorization scope for the method you are building.
10663    ///
10664    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10665    /// [`Scope::CloudPlatform`].
10666    ///
10667    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10668    /// tokens for more than one scope.
10669    ///
10670    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10671    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10672    /// sufficient, a read-write scope will do as well.
10673    pub fn add_scope<St>(
10674        mut self,
10675        scope: St,
10676    ) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C>
10677    where
10678        St: AsRef<str>,
10679    {
10680        self._scopes.insert(String::from(scope.as_ref()));
10681        self
10682    }
10683    /// Identifies the authorization scope(s) for the method you are building.
10684    ///
10685    /// See [`Self::add_scope()`] for details.
10686    pub fn add_scopes<I, St>(
10687        mut self,
10688        scopes: I,
10689    ) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C>
10690    where
10691        I: IntoIterator<Item = St>,
10692        St: AsRef<str>,
10693    {
10694        self._scopes
10695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10696        self
10697    }
10698
10699    /// Removes all scopes, and no default scope will be used either.
10700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10701    /// for details).
10702    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileGroupGetCall<'a, C> {
10703        self._scopes.clear();
10704        self
10705    }
10706}
10707
10708/// Lists SecurityProfileGroups in a given organization and location.
10709///
10710/// A builder for the *locations.securityProfileGroups.list* method supported by a *organization* resource.
10711/// It is not used directly, but through a [`OrganizationMethods`] instance.
10712///
10713/// # Example
10714///
10715/// Instantiate a resource method builder
10716///
10717/// ```test_harness,no_run
10718/// # extern crate hyper;
10719/// # extern crate hyper_rustls;
10720/// # extern crate google_networksecurity1 as networksecurity1;
10721/// # async fn dox() {
10722/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10723///
10724/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10725/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10726/// #     secret,
10727/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10728/// # ).build().await.unwrap();
10729///
10730/// # let client = hyper_util::client::legacy::Client::builder(
10731/// #     hyper_util::rt::TokioExecutor::new()
10732/// # )
10733/// # .build(
10734/// #     hyper_rustls::HttpsConnectorBuilder::new()
10735/// #         .with_native_roots()
10736/// #         .unwrap()
10737/// #         .https_or_http()
10738/// #         .enable_http1()
10739/// #         .build()
10740/// # );
10741/// # let mut hub = NetworkSecurity::new(client, auth);
10742/// // You can configure optional parameters by calling the respective setters at will, and
10743/// // execute the final call using `doit()`.
10744/// // Values shown here are possibly random and not representative !
10745/// let result = hub.organizations().locations_security_profile_groups_list("parent")
10746///              .page_token("dolore")
10747///              .page_size(-22)
10748///              .doit().await;
10749/// # }
10750/// ```
10751pub struct OrganizationLocationSecurityProfileGroupListCall<'a, C>
10752where
10753    C: 'a,
10754{
10755    hub: &'a NetworkSecurity<C>,
10756    _parent: String,
10757    _page_token: Option<String>,
10758    _page_size: Option<i32>,
10759    _delegate: Option<&'a mut dyn common::Delegate>,
10760    _additional_params: HashMap<String, String>,
10761    _scopes: BTreeSet<String>,
10762}
10763
10764impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileGroupListCall<'a, C> {}
10765
10766impl<'a, C> OrganizationLocationSecurityProfileGroupListCall<'a, C>
10767where
10768    C: common::Connector,
10769{
10770    /// Perform the operation you have build so far.
10771    pub async fn doit(
10772        mut self,
10773    ) -> common::Result<(common::Response, ListSecurityProfileGroupsResponse)> {
10774        use std::borrow::Cow;
10775        use std::io::{Read, Seek};
10776
10777        use common::{url::Params, ToParts};
10778        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10779
10780        let mut dd = common::DefaultDelegate;
10781        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10782        dlg.begin(common::MethodInfo {
10783            id: "networksecurity.organizations.locations.securityProfileGroups.list",
10784            http_method: hyper::Method::GET,
10785        });
10786
10787        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
10788            if self._additional_params.contains_key(field) {
10789                dlg.finished(false);
10790                return Err(common::Error::FieldClash(field));
10791            }
10792        }
10793
10794        let mut params = Params::with_capacity(5 + self._additional_params.len());
10795        params.push("parent", self._parent);
10796        if let Some(value) = self._page_token.as_ref() {
10797            params.push("pageToken", value);
10798        }
10799        if let Some(value) = self._page_size.as_ref() {
10800            params.push("pageSize", value.to_string());
10801        }
10802
10803        params.extend(self._additional_params.iter());
10804
10805        params.push("alt", "json");
10806        let mut url = self.hub._base_url.clone() + "v1/{+parent}/securityProfileGroups";
10807        if self._scopes.is_empty() {
10808            self._scopes
10809                .insert(Scope::CloudPlatform.as_ref().to_string());
10810        }
10811
10812        #[allow(clippy::single_element_loop)]
10813        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10814            url = params.uri_replacement(url, param_name, find_this, true);
10815        }
10816        {
10817            let to_remove = ["parent"];
10818            params.remove_params(&to_remove);
10819        }
10820
10821        let url = params.parse_with_url(&url);
10822
10823        loop {
10824            let token = match self
10825                .hub
10826                .auth
10827                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10828                .await
10829            {
10830                Ok(token) => token,
10831                Err(e) => match dlg.token(e) {
10832                    Ok(token) => token,
10833                    Err(e) => {
10834                        dlg.finished(false);
10835                        return Err(common::Error::MissingToken(e));
10836                    }
10837                },
10838            };
10839            let mut req_result = {
10840                let client = &self.hub.client;
10841                dlg.pre_request();
10842                let mut req_builder = hyper::Request::builder()
10843                    .method(hyper::Method::GET)
10844                    .uri(url.as_str())
10845                    .header(USER_AGENT, self.hub._user_agent.clone());
10846
10847                if let Some(token) = token.as_ref() {
10848                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10849                }
10850
10851                let request = req_builder
10852                    .header(CONTENT_LENGTH, 0_u64)
10853                    .body(common::to_body::<String>(None));
10854
10855                client.request(request.unwrap()).await
10856            };
10857
10858            match req_result {
10859                Err(err) => {
10860                    if let common::Retry::After(d) = dlg.http_error(&err) {
10861                        sleep(d).await;
10862                        continue;
10863                    }
10864                    dlg.finished(false);
10865                    return Err(common::Error::HttpError(err));
10866                }
10867                Ok(res) => {
10868                    let (mut parts, body) = res.into_parts();
10869                    let mut body = common::Body::new(body);
10870                    if !parts.status.is_success() {
10871                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10872                        let error = serde_json::from_str(&common::to_string(&bytes));
10873                        let response = common::to_response(parts, bytes.into());
10874
10875                        if let common::Retry::After(d) =
10876                            dlg.http_failure(&response, error.as_ref().ok())
10877                        {
10878                            sleep(d).await;
10879                            continue;
10880                        }
10881
10882                        dlg.finished(false);
10883
10884                        return Err(match error {
10885                            Ok(value) => common::Error::BadRequest(value),
10886                            _ => common::Error::Failure(response),
10887                        });
10888                    }
10889                    let response = {
10890                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10891                        let encoded = common::to_string(&bytes);
10892                        match serde_json::from_str(&encoded) {
10893                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10894                            Err(error) => {
10895                                dlg.response_json_decode_error(&encoded, &error);
10896                                return Err(common::Error::JsonDecodeError(
10897                                    encoded.to_string(),
10898                                    error,
10899                                ));
10900                            }
10901                        }
10902                    };
10903
10904                    dlg.finished(true);
10905                    return Ok(response);
10906                }
10907            }
10908        }
10909    }
10910
10911    /// Required. The project or organization and location from which the SecurityProfileGroups should be listed, specified in the format `projects|organizations/*/locations/{location}`.
10912    ///
10913    /// Sets the *parent* path property to the given value.
10914    ///
10915    /// Even though the property as already been set when instantiating this call,
10916    /// we provide this method for API completeness.
10917    pub fn parent(
10918        mut self,
10919        new_value: &str,
10920    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C> {
10921        self._parent = new_value.to_string();
10922        self
10923    }
10924    /// The value returned by the last `ListSecurityProfileGroupsResponse` Indicates that this is a continuation of a prior `ListSecurityProfileGroups` call, and that the system should return the next page of data.
10925    ///
10926    /// Sets the *page token* query property to the given value.
10927    pub fn page_token(
10928        mut self,
10929        new_value: &str,
10930    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C> {
10931        self._page_token = Some(new_value.to_string());
10932        self
10933    }
10934    /// Maximum number of SecurityProfileGroups to return per call.
10935    ///
10936    /// Sets the *page size* query property to the given value.
10937    pub fn page_size(
10938        mut self,
10939        new_value: i32,
10940    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C> {
10941        self._page_size = Some(new_value);
10942        self
10943    }
10944    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10945    /// while executing the actual API request.
10946    ///
10947    /// ````text
10948    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10949    /// ````
10950    ///
10951    /// Sets the *delegate* property to the given value.
10952    pub fn delegate(
10953        mut self,
10954        new_value: &'a mut dyn common::Delegate,
10955    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C> {
10956        self._delegate = Some(new_value);
10957        self
10958    }
10959
10960    /// Set any additional parameter of the query string used in the request.
10961    /// It should be used to set parameters which are not yet available through their own
10962    /// setters.
10963    ///
10964    /// Please note that this method must not be used to set any of the known parameters
10965    /// which have their own setter method. If done anyway, the request will fail.
10966    ///
10967    /// # Additional Parameters
10968    ///
10969    /// * *$.xgafv* (query-string) - V1 error format.
10970    /// * *access_token* (query-string) - OAuth access token.
10971    /// * *alt* (query-string) - Data format for response.
10972    /// * *callback* (query-string) - JSONP
10973    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10974    /// * *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.
10975    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10976    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10977    /// * *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.
10978    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10979    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10980    pub fn param<T>(
10981        mut self,
10982        name: T,
10983        value: T,
10984    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C>
10985    where
10986        T: AsRef<str>,
10987    {
10988        self._additional_params
10989            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10990        self
10991    }
10992
10993    /// Identifies the authorization scope for the method you are building.
10994    ///
10995    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10996    /// [`Scope::CloudPlatform`].
10997    ///
10998    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10999    /// tokens for more than one scope.
11000    ///
11001    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11002    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11003    /// sufficient, a read-write scope will do as well.
11004    pub fn add_scope<St>(
11005        mut self,
11006        scope: St,
11007    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C>
11008    where
11009        St: AsRef<str>,
11010    {
11011        self._scopes.insert(String::from(scope.as_ref()));
11012        self
11013    }
11014    /// Identifies the authorization scope(s) for the method you are building.
11015    ///
11016    /// See [`Self::add_scope()`] for details.
11017    pub fn add_scopes<I, St>(
11018        mut self,
11019        scopes: I,
11020    ) -> OrganizationLocationSecurityProfileGroupListCall<'a, C>
11021    where
11022        I: IntoIterator<Item = St>,
11023        St: AsRef<str>,
11024    {
11025        self._scopes
11026            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11027        self
11028    }
11029
11030    /// Removes all scopes, and no default scope will be used either.
11031    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11032    /// for details).
11033    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileGroupListCall<'a, C> {
11034        self._scopes.clear();
11035        self
11036    }
11037}
11038
11039/// Updates the parameters of a single SecurityProfileGroup.
11040///
11041/// A builder for the *locations.securityProfileGroups.patch* method supported by a *organization* resource.
11042/// It is not used directly, but through a [`OrganizationMethods`] instance.
11043///
11044/// # Example
11045///
11046/// Instantiate a resource method builder
11047///
11048/// ```test_harness,no_run
11049/// # extern crate hyper;
11050/// # extern crate hyper_rustls;
11051/// # extern crate google_networksecurity1 as networksecurity1;
11052/// use networksecurity1::api::SecurityProfileGroup;
11053/// # async fn dox() {
11054/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11055///
11056/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11058/// #     secret,
11059/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11060/// # ).build().await.unwrap();
11061///
11062/// # let client = hyper_util::client::legacy::Client::builder(
11063/// #     hyper_util::rt::TokioExecutor::new()
11064/// # )
11065/// # .build(
11066/// #     hyper_rustls::HttpsConnectorBuilder::new()
11067/// #         .with_native_roots()
11068/// #         .unwrap()
11069/// #         .https_or_http()
11070/// #         .enable_http1()
11071/// #         .build()
11072/// # );
11073/// # let mut hub = NetworkSecurity::new(client, auth);
11074/// // As the method needs a request, you would usually fill it with the desired information
11075/// // into the respective structure. Some of the parts shown here might not be applicable !
11076/// // Values shown here are possibly random and not representative !
11077/// let mut req = SecurityProfileGroup::default();
11078///
11079/// // You can configure optional parameters by calling the respective setters at will, and
11080/// // execute the final call using `doit()`.
11081/// // Values shown here are possibly random and not representative !
11082/// let result = hub.organizations().locations_security_profile_groups_patch(req, "name")
11083///              .update_mask(FieldMask::new::<&str>(&[]))
11084///              .doit().await;
11085/// # }
11086/// ```
11087pub struct OrganizationLocationSecurityProfileGroupPatchCall<'a, C>
11088where
11089    C: 'a,
11090{
11091    hub: &'a NetworkSecurity<C>,
11092    _request: SecurityProfileGroup,
11093    _name: String,
11094    _update_mask: Option<common::FieldMask>,
11095    _delegate: Option<&'a mut dyn common::Delegate>,
11096    _additional_params: HashMap<String, String>,
11097    _scopes: BTreeSet<String>,
11098}
11099
11100impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {}
11101
11102impl<'a, C> OrganizationLocationSecurityProfileGroupPatchCall<'a, C>
11103where
11104    C: common::Connector,
11105{
11106    /// Perform the operation you have build so far.
11107    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11108        use std::borrow::Cow;
11109        use std::io::{Read, Seek};
11110
11111        use common::{url::Params, ToParts};
11112        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11113
11114        let mut dd = common::DefaultDelegate;
11115        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11116        dlg.begin(common::MethodInfo {
11117            id: "networksecurity.organizations.locations.securityProfileGroups.patch",
11118            http_method: hyper::Method::PATCH,
11119        });
11120
11121        for &field in ["alt", "name", "updateMask"].iter() {
11122            if self._additional_params.contains_key(field) {
11123                dlg.finished(false);
11124                return Err(common::Error::FieldClash(field));
11125            }
11126        }
11127
11128        let mut params = Params::with_capacity(5 + self._additional_params.len());
11129        params.push("name", self._name);
11130        if let Some(value) = self._update_mask.as_ref() {
11131            params.push("updateMask", value.to_string());
11132        }
11133
11134        params.extend(self._additional_params.iter());
11135
11136        params.push("alt", "json");
11137        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11138        if self._scopes.is_empty() {
11139            self._scopes
11140                .insert(Scope::CloudPlatform.as_ref().to_string());
11141        }
11142
11143        #[allow(clippy::single_element_loop)]
11144        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11145            url = params.uri_replacement(url, param_name, find_this, true);
11146        }
11147        {
11148            let to_remove = ["name"];
11149            params.remove_params(&to_remove);
11150        }
11151
11152        let url = params.parse_with_url(&url);
11153
11154        let mut json_mime_type = mime::APPLICATION_JSON;
11155        let mut request_value_reader = {
11156            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11157            common::remove_json_null_values(&mut value);
11158            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11159            serde_json::to_writer(&mut dst, &value).unwrap();
11160            dst
11161        };
11162        let request_size = request_value_reader
11163            .seek(std::io::SeekFrom::End(0))
11164            .unwrap();
11165        request_value_reader
11166            .seek(std::io::SeekFrom::Start(0))
11167            .unwrap();
11168
11169        loop {
11170            let token = match self
11171                .hub
11172                .auth
11173                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11174                .await
11175            {
11176                Ok(token) => token,
11177                Err(e) => match dlg.token(e) {
11178                    Ok(token) => token,
11179                    Err(e) => {
11180                        dlg.finished(false);
11181                        return Err(common::Error::MissingToken(e));
11182                    }
11183                },
11184            };
11185            request_value_reader
11186                .seek(std::io::SeekFrom::Start(0))
11187                .unwrap();
11188            let mut req_result = {
11189                let client = &self.hub.client;
11190                dlg.pre_request();
11191                let mut req_builder = hyper::Request::builder()
11192                    .method(hyper::Method::PATCH)
11193                    .uri(url.as_str())
11194                    .header(USER_AGENT, self.hub._user_agent.clone());
11195
11196                if let Some(token) = token.as_ref() {
11197                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11198                }
11199
11200                let request = req_builder
11201                    .header(CONTENT_TYPE, json_mime_type.to_string())
11202                    .header(CONTENT_LENGTH, request_size as u64)
11203                    .body(common::to_body(
11204                        request_value_reader.get_ref().clone().into(),
11205                    ));
11206
11207                client.request(request.unwrap()).await
11208            };
11209
11210            match req_result {
11211                Err(err) => {
11212                    if let common::Retry::After(d) = dlg.http_error(&err) {
11213                        sleep(d).await;
11214                        continue;
11215                    }
11216                    dlg.finished(false);
11217                    return Err(common::Error::HttpError(err));
11218                }
11219                Ok(res) => {
11220                    let (mut parts, body) = res.into_parts();
11221                    let mut body = common::Body::new(body);
11222                    if !parts.status.is_success() {
11223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11224                        let error = serde_json::from_str(&common::to_string(&bytes));
11225                        let response = common::to_response(parts, bytes.into());
11226
11227                        if let common::Retry::After(d) =
11228                            dlg.http_failure(&response, error.as_ref().ok())
11229                        {
11230                            sleep(d).await;
11231                            continue;
11232                        }
11233
11234                        dlg.finished(false);
11235
11236                        return Err(match error {
11237                            Ok(value) => common::Error::BadRequest(value),
11238                            _ => common::Error::Failure(response),
11239                        });
11240                    }
11241                    let response = {
11242                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11243                        let encoded = common::to_string(&bytes);
11244                        match serde_json::from_str(&encoded) {
11245                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11246                            Err(error) => {
11247                                dlg.response_json_decode_error(&encoded, &error);
11248                                return Err(common::Error::JsonDecodeError(
11249                                    encoded.to_string(),
11250                                    error,
11251                                ));
11252                            }
11253                        }
11254                    };
11255
11256                    dlg.finished(true);
11257                    return Ok(response);
11258                }
11259            }
11260        }
11261    }
11262
11263    ///
11264    /// Sets the *request* property to the given value.
11265    ///
11266    /// Even though the property as already been set when instantiating this call,
11267    /// we provide this method for API completeness.
11268    pub fn request(
11269        mut self,
11270        new_value: SecurityProfileGroup,
11271    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {
11272        self._request = new_value;
11273        self
11274    }
11275    /// Immutable. Identifier. Name of the SecurityProfileGroup resource. It matches pattern `projects|organizations/*/locations/{location}/securityProfileGroups/{security_profile_group}`.
11276    ///
11277    /// Sets the *name* path property to the given value.
11278    ///
11279    /// Even though the property as already been set when instantiating this call,
11280    /// we provide this method for API completeness.
11281    pub fn name(
11282        mut self,
11283        new_value: &str,
11284    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {
11285        self._name = new_value.to_string();
11286        self
11287    }
11288    /// Required. Field mask is used to specify the fields to be overwritten in the SecurityProfileGroup 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.
11289    ///
11290    /// Sets the *update mask* query property to the given value.
11291    pub fn update_mask(
11292        mut self,
11293        new_value: common::FieldMask,
11294    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {
11295        self._update_mask = Some(new_value);
11296        self
11297    }
11298    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11299    /// while executing the actual API request.
11300    ///
11301    /// ````text
11302    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11303    /// ````
11304    ///
11305    /// Sets the *delegate* property to the given value.
11306    pub fn delegate(
11307        mut self,
11308        new_value: &'a mut dyn common::Delegate,
11309    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {
11310        self._delegate = Some(new_value);
11311        self
11312    }
11313
11314    /// Set any additional parameter of the query string used in the request.
11315    /// It should be used to set parameters which are not yet available through their own
11316    /// setters.
11317    ///
11318    /// Please note that this method must not be used to set any of the known parameters
11319    /// which have their own setter method. If done anyway, the request will fail.
11320    ///
11321    /// # Additional Parameters
11322    ///
11323    /// * *$.xgafv* (query-string) - V1 error format.
11324    /// * *access_token* (query-string) - OAuth access token.
11325    /// * *alt* (query-string) - Data format for response.
11326    /// * *callback* (query-string) - JSONP
11327    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11328    /// * *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.
11329    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11330    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11331    /// * *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.
11332    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11333    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11334    pub fn param<T>(
11335        mut self,
11336        name: T,
11337        value: T,
11338    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C>
11339    where
11340        T: AsRef<str>,
11341    {
11342        self._additional_params
11343            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11344        self
11345    }
11346
11347    /// Identifies the authorization scope for the method you are building.
11348    ///
11349    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11350    /// [`Scope::CloudPlatform`].
11351    ///
11352    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11353    /// tokens for more than one scope.
11354    ///
11355    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11356    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11357    /// sufficient, a read-write scope will do as well.
11358    pub fn add_scope<St>(
11359        mut self,
11360        scope: St,
11361    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C>
11362    where
11363        St: AsRef<str>,
11364    {
11365        self._scopes.insert(String::from(scope.as_ref()));
11366        self
11367    }
11368    /// Identifies the authorization scope(s) for the method you are building.
11369    ///
11370    /// See [`Self::add_scope()`] for details.
11371    pub fn add_scopes<I, St>(
11372        mut self,
11373        scopes: I,
11374    ) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C>
11375    where
11376        I: IntoIterator<Item = St>,
11377        St: AsRef<str>,
11378    {
11379        self._scopes
11380            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11381        self
11382    }
11383
11384    /// Removes all scopes, and no default scope will be used either.
11385    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11386    /// for details).
11387    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileGroupPatchCall<'a, C> {
11388        self._scopes.clear();
11389        self
11390    }
11391}
11392
11393/// Creates a new SecurityProfile in a given organization and location.
11394///
11395/// A builder for the *locations.securityProfiles.create* method supported by a *organization* resource.
11396/// It is not used directly, but through a [`OrganizationMethods`] instance.
11397///
11398/// # Example
11399///
11400/// Instantiate a resource method builder
11401///
11402/// ```test_harness,no_run
11403/// # extern crate hyper;
11404/// # extern crate hyper_rustls;
11405/// # extern crate google_networksecurity1 as networksecurity1;
11406/// use networksecurity1::api::SecurityProfile;
11407/// # async fn dox() {
11408/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11409///
11410/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11411/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11412/// #     secret,
11413/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11414/// # ).build().await.unwrap();
11415///
11416/// # let client = hyper_util::client::legacy::Client::builder(
11417/// #     hyper_util::rt::TokioExecutor::new()
11418/// # )
11419/// # .build(
11420/// #     hyper_rustls::HttpsConnectorBuilder::new()
11421/// #         .with_native_roots()
11422/// #         .unwrap()
11423/// #         .https_or_http()
11424/// #         .enable_http1()
11425/// #         .build()
11426/// # );
11427/// # let mut hub = NetworkSecurity::new(client, auth);
11428/// // As the method needs a request, you would usually fill it with the desired information
11429/// // into the respective structure. Some of the parts shown here might not be applicable !
11430/// // Values shown here are possibly random and not representative !
11431/// let mut req = SecurityProfile::default();
11432///
11433/// // You can configure optional parameters by calling the respective setters at will, and
11434/// // execute the final call using `doit()`.
11435/// // Values shown here are possibly random and not representative !
11436/// let result = hub.organizations().locations_security_profiles_create(req, "parent")
11437///              .security_profile_id("consetetur")
11438///              .doit().await;
11439/// # }
11440/// ```
11441pub struct OrganizationLocationSecurityProfileCreateCall<'a, C>
11442where
11443    C: 'a,
11444{
11445    hub: &'a NetworkSecurity<C>,
11446    _request: SecurityProfile,
11447    _parent: String,
11448    _security_profile_id: Option<String>,
11449    _delegate: Option<&'a mut dyn common::Delegate>,
11450    _additional_params: HashMap<String, String>,
11451    _scopes: BTreeSet<String>,
11452}
11453
11454impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileCreateCall<'a, C> {}
11455
11456impl<'a, C> OrganizationLocationSecurityProfileCreateCall<'a, C>
11457where
11458    C: common::Connector,
11459{
11460    /// Perform the operation you have build so far.
11461    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11462        use std::borrow::Cow;
11463        use std::io::{Read, Seek};
11464
11465        use common::{url::Params, ToParts};
11466        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11467
11468        let mut dd = common::DefaultDelegate;
11469        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11470        dlg.begin(common::MethodInfo {
11471            id: "networksecurity.organizations.locations.securityProfiles.create",
11472            http_method: hyper::Method::POST,
11473        });
11474
11475        for &field in ["alt", "parent", "securityProfileId"].iter() {
11476            if self._additional_params.contains_key(field) {
11477                dlg.finished(false);
11478                return Err(common::Error::FieldClash(field));
11479            }
11480        }
11481
11482        let mut params = Params::with_capacity(5 + self._additional_params.len());
11483        params.push("parent", self._parent);
11484        if let Some(value) = self._security_profile_id.as_ref() {
11485            params.push("securityProfileId", value);
11486        }
11487
11488        params.extend(self._additional_params.iter());
11489
11490        params.push("alt", "json");
11491        let mut url = self.hub._base_url.clone() + "v1/{+parent}/securityProfiles";
11492        if self._scopes.is_empty() {
11493            self._scopes
11494                .insert(Scope::CloudPlatform.as_ref().to_string());
11495        }
11496
11497        #[allow(clippy::single_element_loop)]
11498        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11499            url = params.uri_replacement(url, param_name, find_this, true);
11500        }
11501        {
11502            let to_remove = ["parent"];
11503            params.remove_params(&to_remove);
11504        }
11505
11506        let url = params.parse_with_url(&url);
11507
11508        let mut json_mime_type = mime::APPLICATION_JSON;
11509        let mut request_value_reader = {
11510            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11511            common::remove_json_null_values(&mut value);
11512            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11513            serde_json::to_writer(&mut dst, &value).unwrap();
11514            dst
11515        };
11516        let request_size = request_value_reader
11517            .seek(std::io::SeekFrom::End(0))
11518            .unwrap();
11519        request_value_reader
11520            .seek(std::io::SeekFrom::Start(0))
11521            .unwrap();
11522
11523        loop {
11524            let token = match self
11525                .hub
11526                .auth
11527                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11528                .await
11529            {
11530                Ok(token) => token,
11531                Err(e) => match dlg.token(e) {
11532                    Ok(token) => token,
11533                    Err(e) => {
11534                        dlg.finished(false);
11535                        return Err(common::Error::MissingToken(e));
11536                    }
11537                },
11538            };
11539            request_value_reader
11540                .seek(std::io::SeekFrom::Start(0))
11541                .unwrap();
11542            let mut req_result = {
11543                let client = &self.hub.client;
11544                dlg.pre_request();
11545                let mut req_builder = hyper::Request::builder()
11546                    .method(hyper::Method::POST)
11547                    .uri(url.as_str())
11548                    .header(USER_AGENT, self.hub._user_agent.clone());
11549
11550                if let Some(token) = token.as_ref() {
11551                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11552                }
11553
11554                let request = req_builder
11555                    .header(CONTENT_TYPE, json_mime_type.to_string())
11556                    .header(CONTENT_LENGTH, request_size as u64)
11557                    .body(common::to_body(
11558                        request_value_reader.get_ref().clone().into(),
11559                    ));
11560
11561                client.request(request.unwrap()).await
11562            };
11563
11564            match req_result {
11565                Err(err) => {
11566                    if let common::Retry::After(d) = dlg.http_error(&err) {
11567                        sleep(d).await;
11568                        continue;
11569                    }
11570                    dlg.finished(false);
11571                    return Err(common::Error::HttpError(err));
11572                }
11573                Ok(res) => {
11574                    let (mut parts, body) = res.into_parts();
11575                    let mut body = common::Body::new(body);
11576                    if !parts.status.is_success() {
11577                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11578                        let error = serde_json::from_str(&common::to_string(&bytes));
11579                        let response = common::to_response(parts, bytes.into());
11580
11581                        if let common::Retry::After(d) =
11582                            dlg.http_failure(&response, error.as_ref().ok())
11583                        {
11584                            sleep(d).await;
11585                            continue;
11586                        }
11587
11588                        dlg.finished(false);
11589
11590                        return Err(match error {
11591                            Ok(value) => common::Error::BadRequest(value),
11592                            _ => common::Error::Failure(response),
11593                        });
11594                    }
11595                    let response = {
11596                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11597                        let encoded = common::to_string(&bytes);
11598                        match serde_json::from_str(&encoded) {
11599                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11600                            Err(error) => {
11601                                dlg.response_json_decode_error(&encoded, &error);
11602                                return Err(common::Error::JsonDecodeError(
11603                                    encoded.to_string(),
11604                                    error,
11605                                ));
11606                            }
11607                        }
11608                    };
11609
11610                    dlg.finished(true);
11611                    return Ok(response);
11612                }
11613            }
11614        }
11615    }
11616
11617    ///
11618    /// Sets the *request* property to the given value.
11619    ///
11620    /// Even though the property as already been set when instantiating this call,
11621    /// we provide this method for API completeness.
11622    pub fn request(
11623        mut self,
11624        new_value: SecurityProfile,
11625    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C> {
11626        self._request = new_value;
11627        self
11628    }
11629    /// Required. The parent resource of the SecurityProfile. Must be in the format `projects|organizations/*/locations/{location}`.
11630    ///
11631    /// Sets the *parent* path property to the given value.
11632    ///
11633    /// Even though the property as already been set when instantiating this call,
11634    /// we provide this method for API completeness.
11635    pub fn parent(
11636        mut self,
11637        new_value: &str,
11638    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C> {
11639        self._parent = new_value.to_string();
11640        self
11641    }
11642    /// Required. Short name of the SecurityProfile resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "security_profile1".
11643    ///
11644    /// Sets the *security profile id* query property to the given value.
11645    pub fn security_profile_id(
11646        mut self,
11647        new_value: &str,
11648    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C> {
11649        self._security_profile_id = Some(new_value.to_string());
11650        self
11651    }
11652    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11653    /// while executing the actual API request.
11654    ///
11655    /// ````text
11656    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11657    /// ````
11658    ///
11659    /// Sets the *delegate* property to the given value.
11660    pub fn delegate(
11661        mut self,
11662        new_value: &'a mut dyn common::Delegate,
11663    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C> {
11664        self._delegate = Some(new_value);
11665        self
11666    }
11667
11668    /// Set any additional parameter of the query string used in the request.
11669    /// It should be used to set parameters which are not yet available through their own
11670    /// setters.
11671    ///
11672    /// Please note that this method must not be used to set any of the known parameters
11673    /// which have their own setter method. If done anyway, the request will fail.
11674    ///
11675    /// # Additional Parameters
11676    ///
11677    /// * *$.xgafv* (query-string) - V1 error format.
11678    /// * *access_token* (query-string) - OAuth access token.
11679    /// * *alt* (query-string) - Data format for response.
11680    /// * *callback* (query-string) - JSONP
11681    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11682    /// * *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.
11683    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11684    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11685    /// * *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.
11686    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11687    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11688    pub fn param<T>(
11689        mut self,
11690        name: T,
11691        value: T,
11692    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C>
11693    where
11694        T: AsRef<str>,
11695    {
11696        self._additional_params
11697            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11698        self
11699    }
11700
11701    /// Identifies the authorization scope for the method you are building.
11702    ///
11703    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11704    /// [`Scope::CloudPlatform`].
11705    ///
11706    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11707    /// tokens for more than one scope.
11708    ///
11709    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11710    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11711    /// sufficient, a read-write scope will do as well.
11712    pub fn add_scope<St>(
11713        mut self,
11714        scope: St,
11715    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C>
11716    where
11717        St: AsRef<str>,
11718    {
11719        self._scopes.insert(String::from(scope.as_ref()));
11720        self
11721    }
11722    /// Identifies the authorization scope(s) for the method you are building.
11723    ///
11724    /// See [`Self::add_scope()`] for details.
11725    pub fn add_scopes<I, St>(
11726        mut self,
11727        scopes: I,
11728    ) -> OrganizationLocationSecurityProfileCreateCall<'a, C>
11729    where
11730        I: IntoIterator<Item = St>,
11731        St: AsRef<str>,
11732    {
11733        self._scopes
11734            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11735        self
11736    }
11737
11738    /// Removes all scopes, and no default scope will be used either.
11739    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11740    /// for details).
11741    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileCreateCall<'a, C> {
11742        self._scopes.clear();
11743        self
11744    }
11745}
11746
11747/// Deletes a single SecurityProfile.
11748///
11749/// A builder for the *locations.securityProfiles.delete* method supported by a *organization* resource.
11750/// It is not used directly, but through a [`OrganizationMethods`] instance.
11751///
11752/// # Example
11753///
11754/// Instantiate a resource method builder
11755///
11756/// ```test_harness,no_run
11757/// # extern crate hyper;
11758/// # extern crate hyper_rustls;
11759/// # extern crate google_networksecurity1 as networksecurity1;
11760/// # async fn dox() {
11761/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11762///
11763/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11764/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11765/// #     secret,
11766/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11767/// # ).build().await.unwrap();
11768///
11769/// # let client = hyper_util::client::legacy::Client::builder(
11770/// #     hyper_util::rt::TokioExecutor::new()
11771/// # )
11772/// # .build(
11773/// #     hyper_rustls::HttpsConnectorBuilder::new()
11774/// #         .with_native_roots()
11775/// #         .unwrap()
11776/// #         .https_or_http()
11777/// #         .enable_http1()
11778/// #         .build()
11779/// # );
11780/// # let mut hub = NetworkSecurity::new(client, auth);
11781/// // You can configure optional parameters by calling the respective setters at will, and
11782/// // execute the final call using `doit()`.
11783/// // Values shown here are possibly random and not representative !
11784/// let result = hub.organizations().locations_security_profiles_delete("name")
11785///              .etag("dolor")
11786///              .doit().await;
11787/// # }
11788/// ```
11789pub struct OrganizationLocationSecurityProfileDeleteCall<'a, C>
11790where
11791    C: 'a,
11792{
11793    hub: &'a NetworkSecurity<C>,
11794    _name: String,
11795    _etag: Option<String>,
11796    _delegate: Option<&'a mut dyn common::Delegate>,
11797    _additional_params: HashMap<String, String>,
11798    _scopes: BTreeSet<String>,
11799}
11800
11801impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileDeleteCall<'a, C> {}
11802
11803impl<'a, C> OrganizationLocationSecurityProfileDeleteCall<'a, C>
11804where
11805    C: common::Connector,
11806{
11807    /// Perform the operation you have build so far.
11808    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11809        use std::borrow::Cow;
11810        use std::io::{Read, Seek};
11811
11812        use common::{url::Params, ToParts};
11813        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11814
11815        let mut dd = common::DefaultDelegate;
11816        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11817        dlg.begin(common::MethodInfo {
11818            id: "networksecurity.organizations.locations.securityProfiles.delete",
11819            http_method: hyper::Method::DELETE,
11820        });
11821
11822        for &field in ["alt", "name", "etag"].iter() {
11823            if self._additional_params.contains_key(field) {
11824                dlg.finished(false);
11825                return Err(common::Error::FieldClash(field));
11826            }
11827        }
11828
11829        let mut params = Params::with_capacity(4 + self._additional_params.len());
11830        params.push("name", self._name);
11831        if let Some(value) = self._etag.as_ref() {
11832            params.push("etag", value);
11833        }
11834
11835        params.extend(self._additional_params.iter());
11836
11837        params.push("alt", "json");
11838        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11839        if self._scopes.is_empty() {
11840            self._scopes
11841                .insert(Scope::CloudPlatform.as_ref().to_string());
11842        }
11843
11844        #[allow(clippy::single_element_loop)]
11845        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11846            url = params.uri_replacement(url, param_name, find_this, true);
11847        }
11848        {
11849            let to_remove = ["name"];
11850            params.remove_params(&to_remove);
11851        }
11852
11853        let url = params.parse_with_url(&url);
11854
11855        loop {
11856            let token = match self
11857                .hub
11858                .auth
11859                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11860                .await
11861            {
11862                Ok(token) => token,
11863                Err(e) => match dlg.token(e) {
11864                    Ok(token) => token,
11865                    Err(e) => {
11866                        dlg.finished(false);
11867                        return Err(common::Error::MissingToken(e));
11868                    }
11869                },
11870            };
11871            let mut req_result = {
11872                let client = &self.hub.client;
11873                dlg.pre_request();
11874                let mut req_builder = hyper::Request::builder()
11875                    .method(hyper::Method::DELETE)
11876                    .uri(url.as_str())
11877                    .header(USER_AGENT, self.hub._user_agent.clone());
11878
11879                if let Some(token) = token.as_ref() {
11880                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11881                }
11882
11883                let request = req_builder
11884                    .header(CONTENT_LENGTH, 0_u64)
11885                    .body(common::to_body::<String>(None));
11886
11887                client.request(request.unwrap()).await
11888            };
11889
11890            match req_result {
11891                Err(err) => {
11892                    if let common::Retry::After(d) = dlg.http_error(&err) {
11893                        sleep(d).await;
11894                        continue;
11895                    }
11896                    dlg.finished(false);
11897                    return Err(common::Error::HttpError(err));
11898                }
11899                Ok(res) => {
11900                    let (mut parts, body) = res.into_parts();
11901                    let mut body = common::Body::new(body);
11902                    if !parts.status.is_success() {
11903                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11904                        let error = serde_json::from_str(&common::to_string(&bytes));
11905                        let response = common::to_response(parts, bytes.into());
11906
11907                        if let common::Retry::After(d) =
11908                            dlg.http_failure(&response, error.as_ref().ok())
11909                        {
11910                            sleep(d).await;
11911                            continue;
11912                        }
11913
11914                        dlg.finished(false);
11915
11916                        return Err(match error {
11917                            Ok(value) => common::Error::BadRequest(value),
11918                            _ => common::Error::Failure(response),
11919                        });
11920                    }
11921                    let response = {
11922                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11923                        let encoded = common::to_string(&bytes);
11924                        match serde_json::from_str(&encoded) {
11925                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11926                            Err(error) => {
11927                                dlg.response_json_decode_error(&encoded, &error);
11928                                return Err(common::Error::JsonDecodeError(
11929                                    encoded.to_string(),
11930                                    error,
11931                                ));
11932                            }
11933                        }
11934                    };
11935
11936                    dlg.finished(true);
11937                    return Ok(response);
11938                }
11939            }
11940        }
11941    }
11942
11943    /// Required. A name of the SecurityProfile to delete. Must be in the format `projects|organizations/*/locations/{location}/securityProfiles/{security_profile_id}`.
11944    ///
11945    /// Sets the *name* path property to the given value.
11946    ///
11947    /// Even though the property as already been set when instantiating this call,
11948    /// we provide this method for API completeness.
11949    pub fn name(mut self, new_value: &str) -> OrganizationLocationSecurityProfileDeleteCall<'a, C> {
11950        self._name = new_value.to_string();
11951        self
11952    }
11953    /// Optional. If client provided etag is out of date, delete will return FAILED_PRECONDITION error.
11954    ///
11955    /// Sets the *etag* query property to the given value.
11956    pub fn etag(mut self, new_value: &str) -> OrganizationLocationSecurityProfileDeleteCall<'a, C> {
11957        self._etag = Some(new_value.to_string());
11958        self
11959    }
11960    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11961    /// while executing the actual API request.
11962    ///
11963    /// ````text
11964    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11965    /// ````
11966    ///
11967    /// Sets the *delegate* property to the given value.
11968    pub fn delegate(
11969        mut self,
11970        new_value: &'a mut dyn common::Delegate,
11971    ) -> OrganizationLocationSecurityProfileDeleteCall<'a, C> {
11972        self._delegate = Some(new_value);
11973        self
11974    }
11975
11976    /// Set any additional parameter of the query string used in the request.
11977    /// It should be used to set parameters which are not yet available through their own
11978    /// setters.
11979    ///
11980    /// Please note that this method must not be used to set any of the known parameters
11981    /// which have their own setter method. If done anyway, the request will fail.
11982    ///
11983    /// # Additional Parameters
11984    ///
11985    /// * *$.xgafv* (query-string) - V1 error format.
11986    /// * *access_token* (query-string) - OAuth access token.
11987    /// * *alt* (query-string) - Data format for response.
11988    /// * *callback* (query-string) - JSONP
11989    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11990    /// * *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.
11991    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11992    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11993    /// * *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.
11994    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11995    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11996    pub fn param<T>(
11997        mut self,
11998        name: T,
11999        value: T,
12000    ) -> OrganizationLocationSecurityProfileDeleteCall<'a, C>
12001    where
12002        T: AsRef<str>,
12003    {
12004        self._additional_params
12005            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12006        self
12007    }
12008
12009    /// Identifies the authorization scope for the method you are building.
12010    ///
12011    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12012    /// [`Scope::CloudPlatform`].
12013    ///
12014    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12015    /// tokens for more than one scope.
12016    ///
12017    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12018    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12019    /// sufficient, a read-write scope will do as well.
12020    pub fn add_scope<St>(
12021        mut self,
12022        scope: St,
12023    ) -> OrganizationLocationSecurityProfileDeleteCall<'a, C>
12024    where
12025        St: AsRef<str>,
12026    {
12027        self._scopes.insert(String::from(scope.as_ref()));
12028        self
12029    }
12030    /// Identifies the authorization scope(s) for the method you are building.
12031    ///
12032    /// See [`Self::add_scope()`] for details.
12033    pub fn add_scopes<I, St>(
12034        mut self,
12035        scopes: I,
12036    ) -> OrganizationLocationSecurityProfileDeleteCall<'a, C>
12037    where
12038        I: IntoIterator<Item = St>,
12039        St: AsRef<str>,
12040    {
12041        self._scopes
12042            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12043        self
12044    }
12045
12046    /// Removes all scopes, and no default scope will be used either.
12047    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12048    /// for details).
12049    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileDeleteCall<'a, C> {
12050        self._scopes.clear();
12051        self
12052    }
12053}
12054
12055/// Gets details of a single SecurityProfile.
12056///
12057/// A builder for the *locations.securityProfiles.get* method supported by a *organization* resource.
12058/// It is not used directly, but through a [`OrganizationMethods`] instance.
12059///
12060/// # Example
12061///
12062/// Instantiate a resource method builder
12063///
12064/// ```test_harness,no_run
12065/// # extern crate hyper;
12066/// # extern crate hyper_rustls;
12067/// # extern crate google_networksecurity1 as networksecurity1;
12068/// # async fn dox() {
12069/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12070///
12071/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12072/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12073/// #     secret,
12074/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12075/// # ).build().await.unwrap();
12076///
12077/// # let client = hyper_util::client::legacy::Client::builder(
12078/// #     hyper_util::rt::TokioExecutor::new()
12079/// # )
12080/// # .build(
12081/// #     hyper_rustls::HttpsConnectorBuilder::new()
12082/// #         .with_native_roots()
12083/// #         .unwrap()
12084/// #         .https_or_http()
12085/// #         .enable_http1()
12086/// #         .build()
12087/// # );
12088/// # let mut hub = NetworkSecurity::new(client, auth);
12089/// // You can configure optional parameters by calling the respective setters at will, and
12090/// // execute the final call using `doit()`.
12091/// // Values shown here are possibly random and not representative !
12092/// let result = hub.organizations().locations_security_profiles_get("name")
12093///              .doit().await;
12094/// # }
12095/// ```
12096pub struct OrganizationLocationSecurityProfileGetCall<'a, C>
12097where
12098    C: 'a,
12099{
12100    hub: &'a NetworkSecurity<C>,
12101    _name: String,
12102    _delegate: Option<&'a mut dyn common::Delegate>,
12103    _additional_params: HashMap<String, String>,
12104    _scopes: BTreeSet<String>,
12105}
12106
12107impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileGetCall<'a, C> {}
12108
12109impl<'a, C> OrganizationLocationSecurityProfileGetCall<'a, C>
12110where
12111    C: common::Connector,
12112{
12113    /// Perform the operation you have build so far.
12114    pub async fn doit(mut self) -> common::Result<(common::Response, SecurityProfile)> {
12115        use std::borrow::Cow;
12116        use std::io::{Read, Seek};
12117
12118        use common::{url::Params, ToParts};
12119        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12120
12121        let mut dd = common::DefaultDelegate;
12122        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12123        dlg.begin(common::MethodInfo {
12124            id: "networksecurity.organizations.locations.securityProfiles.get",
12125            http_method: hyper::Method::GET,
12126        });
12127
12128        for &field in ["alt", "name"].iter() {
12129            if self._additional_params.contains_key(field) {
12130                dlg.finished(false);
12131                return Err(common::Error::FieldClash(field));
12132            }
12133        }
12134
12135        let mut params = Params::with_capacity(3 + self._additional_params.len());
12136        params.push("name", self._name);
12137
12138        params.extend(self._additional_params.iter());
12139
12140        params.push("alt", "json");
12141        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12142        if self._scopes.is_empty() {
12143            self._scopes
12144                .insert(Scope::CloudPlatform.as_ref().to_string());
12145        }
12146
12147        #[allow(clippy::single_element_loop)]
12148        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12149            url = params.uri_replacement(url, param_name, find_this, true);
12150        }
12151        {
12152            let to_remove = ["name"];
12153            params.remove_params(&to_remove);
12154        }
12155
12156        let url = params.parse_with_url(&url);
12157
12158        loop {
12159            let token = match self
12160                .hub
12161                .auth
12162                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12163                .await
12164            {
12165                Ok(token) => token,
12166                Err(e) => match dlg.token(e) {
12167                    Ok(token) => token,
12168                    Err(e) => {
12169                        dlg.finished(false);
12170                        return Err(common::Error::MissingToken(e));
12171                    }
12172                },
12173            };
12174            let mut req_result = {
12175                let client = &self.hub.client;
12176                dlg.pre_request();
12177                let mut req_builder = hyper::Request::builder()
12178                    .method(hyper::Method::GET)
12179                    .uri(url.as_str())
12180                    .header(USER_AGENT, self.hub._user_agent.clone());
12181
12182                if let Some(token) = token.as_ref() {
12183                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12184                }
12185
12186                let request = req_builder
12187                    .header(CONTENT_LENGTH, 0_u64)
12188                    .body(common::to_body::<String>(None));
12189
12190                client.request(request.unwrap()).await
12191            };
12192
12193            match req_result {
12194                Err(err) => {
12195                    if let common::Retry::After(d) = dlg.http_error(&err) {
12196                        sleep(d).await;
12197                        continue;
12198                    }
12199                    dlg.finished(false);
12200                    return Err(common::Error::HttpError(err));
12201                }
12202                Ok(res) => {
12203                    let (mut parts, body) = res.into_parts();
12204                    let mut body = common::Body::new(body);
12205                    if !parts.status.is_success() {
12206                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12207                        let error = serde_json::from_str(&common::to_string(&bytes));
12208                        let response = common::to_response(parts, bytes.into());
12209
12210                        if let common::Retry::After(d) =
12211                            dlg.http_failure(&response, error.as_ref().ok())
12212                        {
12213                            sleep(d).await;
12214                            continue;
12215                        }
12216
12217                        dlg.finished(false);
12218
12219                        return Err(match error {
12220                            Ok(value) => common::Error::BadRequest(value),
12221                            _ => common::Error::Failure(response),
12222                        });
12223                    }
12224                    let response = {
12225                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12226                        let encoded = common::to_string(&bytes);
12227                        match serde_json::from_str(&encoded) {
12228                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12229                            Err(error) => {
12230                                dlg.response_json_decode_error(&encoded, &error);
12231                                return Err(common::Error::JsonDecodeError(
12232                                    encoded.to_string(),
12233                                    error,
12234                                ));
12235                            }
12236                        }
12237                    };
12238
12239                    dlg.finished(true);
12240                    return Ok(response);
12241                }
12242            }
12243        }
12244    }
12245
12246    /// Required. A name of the SecurityProfile to get. Must be in the format `projects|organizations/*/locations/{location}/securityProfiles/{security_profile_id}`.
12247    ///
12248    /// Sets the *name* path property to the given value.
12249    ///
12250    /// Even though the property as already been set when instantiating this call,
12251    /// we provide this method for API completeness.
12252    pub fn name(mut self, new_value: &str) -> OrganizationLocationSecurityProfileGetCall<'a, C> {
12253        self._name = new_value.to_string();
12254        self
12255    }
12256    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12257    /// while executing the actual API request.
12258    ///
12259    /// ````text
12260    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12261    /// ````
12262    ///
12263    /// Sets the *delegate* property to the given value.
12264    pub fn delegate(
12265        mut self,
12266        new_value: &'a mut dyn common::Delegate,
12267    ) -> OrganizationLocationSecurityProfileGetCall<'a, C> {
12268        self._delegate = Some(new_value);
12269        self
12270    }
12271
12272    /// Set any additional parameter of the query string used in the request.
12273    /// It should be used to set parameters which are not yet available through their own
12274    /// setters.
12275    ///
12276    /// Please note that this method must not be used to set any of the known parameters
12277    /// which have their own setter method. If done anyway, the request will fail.
12278    ///
12279    /// # Additional Parameters
12280    ///
12281    /// * *$.xgafv* (query-string) - V1 error format.
12282    /// * *access_token* (query-string) - OAuth access token.
12283    /// * *alt* (query-string) - Data format for response.
12284    /// * *callback* (query-string) - JSONP
12285    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12286    /// * *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.
12287    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12288    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12289    /// * *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.
12290    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12291    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12292    pub fn param<T>(
12293        mut self,
12294        name: T,
12295        value: T,
12296    ) -> OrganizationLocationSecurityProfileGetCall<'a, C>
12297    where
12298        T: AsRef<str>,
12299    {
12300        self._additional_params
12301            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12302        self
12303    }
12304
12305    /// Identifies the authorization scope for the method you are building.
12306    ///
12307    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12308    /// [`Scope::CloudPlatform`].
12309    ///
12310    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12311    /// tokens for more than one scope.
12312    ///
12313    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12314    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12315    /// sufficient, a read-write scope will do as well.
12316    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationSecurityProfileGetCall<'a, C>
12317    where
12318        St: AsRef<str>,
12319    {
12320        self._scopes.insert(String::from(scope.as_ref()));
12321        self
12322    }
12323    /// Identifies the authorization scope(s) for the method you are building.
12324    ///
12325    /// See [`Self::add_scope()`] for details.
12326    pub fn add_scopes<I, St>(
12327        mut self,
12328        scopes: I,
12329    ) -> OrganizationLocationSecurityProfileGetCall<'a, C>
12330    where
12331        I: IntoIterator<Item = St>,
12332        St: AsRef<str>,
12333    {
12334        self._scopes
12335            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12336        self
12337    }
12338
12339    /// Removes all scopes, and no default scope will be used either.
12340    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12341    /// for details).
12342    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileGetCall<'a, C> {
12343        self._scopes.clear();
12344        self
12345    }
12346}
12347
12348/// Lists SecurityProfiles in a given organization and location.
12349///
12350/// A builder for the *locations.securityProfiles.list* method supported by a *organization* resource.
12351/// It is not used directly, but through a [`OrganizationMethods`] instance.
12352///
12353/// # Example
12354///
12355/// Instantiate a resource method builder
12356///
12357/// ```test_harness,no_run
12358/// # extern crate hyper;
12359/// # extern crate hyper_rustls;
12360/// # extern crate google_networksecurity1 as networksecurity1;
12361/// # async fn dox() {
12362/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12363///
12364/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12365/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12366/// #     secret,
12367/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12368/// # ).build().await.unwrap();
12369///
12370/// # let client = hyper_util::client::legacy::Client::builder(
12371/// #     hyper_util::rt::TokioExecutor::new()
12372/// # )
12373/// # .build(
12374/// #     hyper_rustls::HttpsConnectorBuilder::new()
12375/// #         .with_native_roots()
12376/// #         .unwrap()
12377/// #         .https_or_http()
12378/// #         .enable_http1()
12379/// #         .build()
12380/// # );
12381/// # let mut hub = NetworkSecurity::new(client, auth);
12382/// // You can configure optional parameters by calling the respective setters at will, and
12383/// // execute the final call using `doit()`.
12384/// // Values shown here are possibly random and not representative !
12385/// let result = hub.organizations().locations_security_profiles_list("parent")
12386///              .page_token("sadipscing")
12387///              .page_size(-15)
12388///              .doit().await;
12389/// # }
12390/// ```
12391pub struct OrganizationLocationSecurityProfileListCall<'a, C>
12392where
12393    C: 'a,
12394{
12395    hub: &'a NetworkSecurity<C>,
12396    _parent: String,
12397    _page_token: Option<String>,
12398    _page_size: Option<i32>,
12399    _delegate: Option<&'a mut dyn common::Delegate>,
12400    _additional_params: HashMap<String, String>,
12401    _scopes: BTreeSet<String>,
12402}
12403
12404impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfileListCall<'a, C> {}
12405
12406impl<'a, C> OrganizationLocationSecurityProfileListCall<'a, C>
12407where
12408    C: common::Connector,
12409{
12410    /// Perform the operation you have build so far.
12411    pub async fn doit(
12412        mut self,
12413    ) -> common::Result<(common::Response, ListSecurityProfilesResponse)> {
12414        use std::borrow::Cow;
12415        use std::io::{Read, Seek};
12416
12417        use common::{url::Params, ToParts};
12418        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12419
12420        let mut dd = common::DefaultDelegate;
12421        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12422        dlg.begin(common::MethodInfo {
12423            id: "networksecurity.organizations.locations.securityProfiles.list",
12424            http_method: hyper::Method::GET,
12425        });
12426
12427        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
12428            if self._additional_params.contains_key(field) {
12429                dlg.finished(false);
12430                return Err(common::Error::FieldClash(field));
12431            }
12432        }
12433
12434        let mut params = Params::with_capacity(5 + self._additional_params.len());
12435        params.push("parent", self._parent);
12436        if let Some(value) = self._page_token.as_ref() {
12437            params.push("pageToken", value);
12438        }
12439        if let Some(value) = self._page_size.as_ref() {
12440            params.push("pageSize", value.to_string());
12441        }
12442
12443        params.extend(self._additional_params.iter());
12444
12445        params.push("alt", "json");
12446        let mut url = self.hub._base_url.clone() + "v1/{+parent}/securityProfiles";
12447        if self._scopes.is_empty() {
12448            self._scopes
12449                .insert(Scope::CloudPlatform.as_ref().to_string());
12450        }
12451
12452        #[allow(clippy::single_element_loop)]
12453        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12454            url = params.uri_replacement(url, param_name, find_this, true);
12455        }
12456        {
12457            let to_remove = ["parent"];
12458            params.remove_params(&to_remove);
12459        }
12460
12461        let url = params.parse_with_url(&url);
12462
12463        loop {
12464            let token = match self
12465                .hub
12466                .auth
12467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12468                .await
12469            {
12470                Ok(token) => token,
12471                Err(e) => match dlg.token(e) {
12472                    Ok(token) => token,
12473                    Err(e) => {
12474                        dlg.finished(false);
12475                        return Err(common::Error::MissingToken(e));
12476                    }
12477                },
12478            };
12479            let mut req_result = {
12480                let client = &self.hub.client;
12481                dlg.pre_request();
12482                let mut req_builder = hyper::Request::builder()
12483                    .method(hyper::Method::GET)
12484                    .uri(url.as_str())
12485                    .header(USER_AGENT, self.hub._user_agent.clone());
12486
12487                if let Some(token) = token.as_ref() {
12488                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12489                }
12490
12491                let request = req_builder
12492                    .header(CONTENT_LENGTH, 0_u64)
12493                    .body(common::to_body::<String>(None));
12494
12495                client.request(request.unwrap()).await
12496            };
12497
12498            match req_result {
12499                Err(err) => {
12500                    if let common::Retry::After(d) = dlg.http_error(&err) {
12501                        sleep(d).await;
12502                        continue;
12503                    }
12504                    dlg.finished(false);
12505                    return Err(common::Error::HttpError(err));
12506                }
12507                Ok(res) => {
12508                    let (mut parts, body) = res.into_parts();
12509                    let mut body = common::Body::new(body);
12510                    if !parts.status.is_success() {
12511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12512                        let error = serde_json::from_str(&common::to_string(&bytes));
12513                        let response = common::to_response(parts, bytes.into());
12514
12515                        if let common::Retry::After(d) =
12516                            dlg.http_failure(&response, error.as_ref().ok())
12517                        {
12518                            sleep(d).await;
12519                            continue;
12520                        }
12521
12522                        dlg.finished(false);
12523
12524                        return Err(match error {
12525                            Ok(value) => common::Error::BadRequest(value),
12526                            _ => common::Error::Failure(response),
12527                        });
12528                    }
12529                    let response = {
12530                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12531                        let encoded = common::to_string(&bytes);
12532                        match serde_json::from_str(&encoded) {
12533                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12534                            Err(error) => {
12535                                dlg.response_json_decode_error(&encoded, &error);
12536                                return Err(common::Error::JsonDecodeError(
12537                                    encoded.to_string(),
12538                                    error,
12539                                ));
12540                            }
12541                        }
12542                    };
12543
12544                    dlg.finished(true);
12545                    return Ok(response);
12546                }
12547            }
12548        }
12549    }
12550
12551    /// Required. The project or organization and location from which the SecurityProfiles should be listed, specified in the format `projects|organizations/*/locations/{location}`.
12552    ///
12553    /// Sets the *parent* path property to the given value.
12554    ///
12555    /// Even though the property as already been set when instantiating this call,
12556    /// we provide this method for API completeness.
12557    pub fn parent(mut self, new_value: &str) -> OrganizationLocationSecurityProfileListCall<'a, C> {
12558        self._parent = new_value.to_string();
12559        self
12560    }
12561    /// The value returned by the last `ListSecurityProfilesResponse` Indicates that this is a continuation of a prior `ListSecurityProfiles` call, and that the system should return the next page of data.
12562    ///
12563    /// Sets the *page token* query property to the given value.
12564    pub fn page_token(
12565        mut self,
12566        new_value: &str,
12567    ) -> OrganizationLocationSecurityProfileListCall<'a, C> {
12568        self._page_token = Some(new_value.to_string());
12569        self
12570    }
12571    /// Maximum number of SecurityProfiles to return per call.
12572    ///
12573    /// Sets the *page size* query property to the given value.
12574    pub fn page_size(
12575        mut self,
12576        new_value: i32,
12577    ) -> OrganizationLocationSecurityProfileListCall<'a, C> {
12578        self._page_size = Some(new_value);
12579        self
12580    }
12581    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12582    /// while executing the actual API request.
12583    ///
12584    /// ````text
12585    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12586    /// ````
12587    ///
12588    /// Sets the *delegate* property to the given value.
12589    pub fn delegate(
12590        mut self,
12591        new_value: &'a mut dyn common::Delegate,
12592    ) -> OrganizationLocationSecurityProfileListCall<'a, C> {
12593        self._delegate = Some(new_value);
12594        self
12595    }
12596
12597    /// Set any additional parameter of the query string used in the request.
12598    /// It should be used to set parameters which are not yet available through their own
12599    /// setters.
12600    ///
12601    /// Please note that this method must not be used to set any of the known parameters
12602    /// which have their own setter method. If done anyway, the request will fail.
12603    ///
12604    /// # Additional Parameters
12605    ///
12606    /// * *$.xgafv* (query-string) - V1 error format.
12607    /// * *access_token* (query-string) - OAuth access token.
12608    /// * *alt* (query-string) - Data format for response.
12609    /// * *callback* (query-string) - JSONP
12610    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12611    /// * *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.
12612    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12613    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12614    /// * *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.
12615    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12616    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12617    pub fn param<T>(
12618        mut self,
12619        name: T,
12620        value: T,
12621    ) -> OrganizationLocationSecurityProfileListCall<'a, C>
12622    where
12623        T: AsRef<str>,
12624    {
12625        self._additional_params
12626            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12627        self
12628    }
12629
12630    /// Identifies the authorization scope for the method you are building.
12631    ///
12632    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12633    /// [`Scope::CloudPlatform`].
12634    ///
12635    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12636    /// tokens for more than one scope.
12637    ///
12638    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12639    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12640    /// sufficient, a read-write scope will do as well.
12641    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationSecurityProfileListCall<'a, C>
12642    where
12643        St: AsRef<str>,
12644    {
12645        self._scopes.insert(String::from(scope.as_ref()));
12646        self
12647    }
12648    /// Identifies the authorization scope(s) for the method you are building.
12649    ///
12650    /// See [`Self::add_scope()`] for details.
12651    pub fn add_scopes<I, St>(
12652        mut self,
12653        scopes: I,
12654    ) -> OrganizationLocationSecurityProfileListCall<'a, C>
12655    where
12656        I: IntoIterator<Item = St>,
12657        St: AsRef<str>,
12658    {
12659        self._scopes
12660            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12661        self
12662    }
12663
12664    /// Removes all scopes, and no default scope will be used either.
12665    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12666    /// for details).
12667    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfileListCall<'a, C> {
12668        self._scopes.clear();
12669        self
12670    }
12671}
12672
12673/// Updates the parameters of a single SecurityProfile.
12674///
12675/// A builder for the *locations.securityProfiles.patch* method supported by a *organization* resource.
12676/// It is not used directly, but through a [`OrganizationMethods`] instance.
12677///
12678/// # Example
12679///
12680/// Instantiate a resource method builder
12681///
12682/// ```test_harness,no_run
12683/// # extern crate hyper;
12684/// # extern crate hyper_rustls;
12685/// # extern crate google_networksecurity1 as networksecurity1;
12686/// use networksecurity1::api::SecurityProfile;
12687/// # async fn dox() {
12688/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12689///
12690/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12692/// #     secret,
12693/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12694/// # ).build().await.unwrap();
12695///
12696/// # let client = hyper_util::client::legacy::Client::builder(
12697/// #     hyper_util::rt::TokioExecutor::new()
12698/// # )
12699/// # .build(
12700/// #     hyper_rustls::HttpsConnectorBuilder::new()
12701/// #         .with_native_roots()
12702/// #         .unwrap()
12703/// #         .https_or_http()
12704/// #         .enable_http1()
12705/// #         .build()
12706/// # );
12707/// # let mut hub = NetworkSecurity::new(client, auth);
12708/// // As the method needs a request, you would usually fill it with the desired information
12709/// // into the respective structure. Some of the parts shown here might not be applicable !
12710/// // Values shown here are possibly random and not representative !
12711/// let mut req = SecurityProfile::default();
12712///
12713/// // You can configure optional parameters by calling the respective setters at will, and
12714/// // execute the final call using `doit()`.
12715/// // Values shown here are possibly random and not representative !
12716/// let result = hub.organizations().locations_security_profiles_patch(req, "name")
12717///              .update_mask(FieldMask::new::<&str>(&[]))
12718///              .doit().await;
12719/// # }
12720/// ```
12721pub struct OrganizationLocationSecurityProfilePatchCall<'a, C>
12722where
12723    C: 'a,
12724{
12725    hub: &'a NetworkSecurity<C>,
12726    _request: SecurityProfile,
12727    _name: String,
12728    _update_mask: Option<common::FieldMask>,
12729    _delegate: Option<&'a mut dyn common::Delegate>,
12730    _additional_params: HashMap<String, String>,
12731    _scopes: BTreeSet<String>,
12732}
12733
12734impl<'a, C> common::CallBuilder for OrganizationLocationSecurityProfilePatchCall<'a, C> {}
12735
12736impl<'a, C> OrganizationLocationSecurityProfilePatchCall<'a, C>
12737where
12738    C: common::Connector,
12739{
12740    /// Perform the operation you have build so far.
12741    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12742        use std::borrow::Cow;
12743        use std::io::{Read, Seek};
12744
12745        use common::{url::Params, ToParts};
12746        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12747
12748        let mut dd = common::DefaultDelegate;
12749        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12750        dlg.begin(common::MethodInfo {
12751            id: "networksecurity.organizations.locations.securityProfiles.patch",
12752            http_method: hyper::Method::PATCH,
12753        });
12754
12755        for &field in ["alt", "name", "updateMask"].iter() {
12756            if self._additional_params.contains_key(field) {
12757                dlg.finished(false);
12758                return Err(common::Error::FieldClash(field));
12759            }
12760        }
12761
12762        let mut params = Params::with_capacity(5 + self._additional_params.len());
12763        params.push("name", self._name);
12764        if let Some(value) = self._update_mask.as_ref() {
12765            params.push("updateMask", value.to_string());
12766        }
12767
12768        params.extend(self._additional_params.iter());
12769
12770        params.push("alt", "json");
12771        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12772        if self._scopes.is_empty() {
12773            self._scopes
12774                .insert(Scope::CloudPlatform.as_ref().to_string());
12775        }
12776
12777        #[allow(clippy::single_element_loop)]
12778        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12779            url = params.uri_replacement(url, param_name, find_this, true);
12780        }
12781        {
12782            let to_remove = ["name"];
12783            params.remove_params(&to_remove);
12784        }
12785
12786        let url = params.parse_with_url(&url);
12787
12788        let mut json_mime_type = mime::APPLICATION_JSON;
12789        let mut request_value_reader = {
12790            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12791            common::remove_json_null_values(&mut value);
12792            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12793            serde_json::to_writer(&mut dst, &value).unwrap();
12794            dst
12795        };
12796        let request_size = request_value_reader
12797            .seek(std::io::SeekFrom::End(0))
12798            .unwrap();
12799        request_value_reader
12800            .seek(std::io::SeekFrom::Start(0))
12801            .unwrap();
12802
12803        loop {
12804            let token = match self
12805                .hub
12806                .auth
12807                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12808                .await
12809            {
12810                Ok(token) => token,
12811                Err(e) => match dlg.token(e) {
12812                    Ok(token) => token,
12813                    Err(e) => {
12814                        dlg.finished(false);
12815                        return Err(common::Error::MissingToken(e));
12816                    }
12817                },
12818            };
12819            request_value_reader
12820                .seek(std::io::SeekFrom::Start(0))
12821                .unwrap();
12822            let mut req_result = {
12823                let client = &self.hub.client;
12824                dlg.pre_request();
12825                let mut req_builder = hyper::Request::builder()
12826                    .method(hyper::Method::PATCH)
12827                    .uri(url.as_str())
12828                    .header(USER_AGENT, self.hub._user_agent.clone());
12829
12830                if let Some(token) = token.as_ref() {
12831                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12832                }
12833
12834                let request = req_builder
12835                    .header(CONTENT_TYPE, json_mime_type.to_string())
12836                    .header(CONTENT_LENGTH, request_size as u64)
12837                    .body(common::to_body(
12838                        request_value_reader.get_ref().clone().into(),
12839                    ));
12840
12841                client.request(request.unwrap()).await
12842            };
12843
12844            match req_result {
12845                Err(err) => {
12846                    if let common::Retry::After(d) = dlg.http_error(&err) {
12847                        sleep(d).await;
12848                        continue;
12849                    }
12850                    dlg.finished(false);
12851                    return Err(common::Error::HttpError(err));
12852                }
12853                Ok(res) => {
12854                    let (mut parts, body) = res.into_parts();
12855                    let mut body = common::Body::new(body);
12856                    if !parts.status.is_success() {
12857                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12858                        let error = serde_json::from_str(&common::to_string(&bytes));
12859                        let response = common::to_response(parts, bytes.into());
12860
12861                        if let common::Retry::After(d) =
12862                            dlg.http_failure(&response, error.as_ref().ok())
12863                        {
12864                            sleep(d).await;
12865                            continue;
12866                        }
12867
12868                        dlg.finished(false);
12869
12870                        return Err(match error {
12871                            Ok(value) => common::Error::BadRequest(value),
12872                            _ => common::Error::Failure(response),
12873                        });
12874                    }
12875                    let response = {
12876                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12877                        let encoded = common::to_string(&bytes);
12878                        match serde_json::from_str(&encoded) {
12879                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12880                            Err(error) => {
12881                                dlg.response_json_decode_error(&encoded, &error);
12882                                return Err(common::Error::JsonDecodeError(
12883                                    encoded.to_string(),
12884                                    error,
12885                                ));
12886                            }
12887                        }
12888                    };
12889
12890                    dlg.finished(true);
12891                    return Ok(response);
12892                }
12893            }
12894        }
12895    }
12896
12897    ///
12898    /// Sets the *request* property to the given value.
12899    ///
12900    /// Even though the property as already been set when instantiating this call,
12901    /// we provide this method for API completeness.
12902    pub fn request(
12903        mut self,
12904        new_value: SecurityProfile,
12905    ) -> OrganizationLocationSecurityProfilePatchCall<'a, C> {
12906        self._request = new_value;
12907        self
12908    }
12909    /// Immutable. Identifier. Name of the SecurityProfile resource. It matches pattern `projects|organizations/*/locations/{location}/securityProfiles/{security_profile}`.
12910    ///
12911    /// Sets the *name* path property to the given value.
12912    ///
12913    /// Even though the property as already been set when instantiating this call,
12914    /// we provide this method for API completeness.
12915    pub fn name(mut self, new_value: &str) -> OrganizationLocationSecurityProfilePatchCall<'a, C> {
12916        self._name = new_value.to_string();
12917        self
12918    }
12919    /// Required. Field mask is used to specify the fields to be overwritten in the SecurityProfile 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.
12920    ///
12921    /// Sets the *update mask* query property to the given value.
12922    pub fn update_mask(
12923        mut self,
12924        new_value: common::FieldMask,
12925    ) -> OrganizationLocationSecurityProfilePatchCall<'a, C> {
12926        self._update_mask = Some(new_value);
12927        self
12928    }
12929    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12930    /// while executing the actual API request.
12931    ///
12932    /// ````text
12933    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12934    /// ````
12935    ///
12936    /// Sets the *delegate* property to the given value.
12937    pub fn delegate(
12938        mut self,
12939        new_value: &'a mut dyn common::Delegate,
12940    ) -> OrganizationLocationSecurityProfilePatchCall<'a, C> {
12941        self._delegate = Some(new_value);
12942        self
12943    }
12944
12945    /// Set any additional parameter of the query string used in the request.
12946    /// It should be used to set parameters which are not yet available through their own
12947    /// setters.
12948    ///
12949    /// Please note that this method must not be used to set any of the known parameters
12950    /// which have their own setter method. If done anyway, the request will fail.
12951    ///
12952    /// # Additional Parameters
12953    ///
12954    /// * *$.xgafv* (query-string) - V1 error format.
12955    /// * *access_token* (query-string) - OAuth access token.
12956    /// * *alt* (query-string) - Data format for response.
12957    /// * *callback* (query-string) - JSONP
12958    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12959    /// * *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.
12960    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12961    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12962    /// * *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.
12963    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12964    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12965    pub fn param<T>(
12966        mut self,
12967        name: T,
12968        value: T,
12969    ) -> OrganizationLocationSecurityProfilePatchCall<'a, C>
12970    where
12971        T: AsRef<str>,
12972    {
12973        self._additional_params
12974            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12975        self
12976    }
12977
12978    /// Identifies the authorization scope for the method you are building.
12979    ///
12980    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12981    /// [`Scope::CloudPlatform`].
12982    ///
12983    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12984    /// tokens for more than one scope.
12985    ///
12986    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12987    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12988    /// sufficient, a read-write scope will do as well.
12989    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationSecurityProfilePatchCall<'a, C>
12990    where
12991        St: AsRef<str>,
12992    {
12993        self._scopes.insert(String::from(scope.as_ref()));
12994        self
12995    }
12996    /// Identifies the authorization scope(s) for the method you are building.
12997    ///
12998    /// See [`Self::add_scope()`] for details.
12999    pub fn add_scopes<I, St>(
13000        mut self,
13001        scopes: I,
13002    ) -> OrganizationLocationSecurityProfilePatchCall<'a, C>
13003    where
13004        I: IntoIterator<Item = St>,
13005        St: AsRef<str>,
13006    {
13007        self._scopes
13008            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13009        self
13010    }
13011
13012    /// Removes all scopes, and no default scope will be used either.
13013    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13014    /// for details).
13015    pub fn clear_scopes(mut self) -> OrganizationLocationSecurityProfilePatchCall<'a, C> {
13016        self._scopes.clear();
13017        self
13018    }
13019}
13020
13021/// Adds items to an address group.
13022///
13023/// A builder for the *locations.addressGroups.addItems* method supported by a *project* resource.
13024/// It is not used directly, but through a [`ProjectMethods`] instance.
13025///
13026/// # Example
13027///
13028/// Instantiate a resource method builder
13029///
13030/// ```test_harness,no_run
13031/// # extern crate hyper;
13032/// # extern crate hyper_rustls;
13033/// # extern crate google_networksecurity1 as networksecurity1;
13034/// use networksecurity1::api::AddAddressGroupItemsRequest;
13035/// # async fn dox() {
13036/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13037///
13038/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13039/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13040/// #     secret,
13041/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13042/// # ).build().await.unwrap();
13043///
13044/// # let client = hyper_util::client::legacy::Client::builder(
13045/// #     hyper_util::rt::TokioExecutor::new()
13046/// # )
13047/// # .build(
13048/// #     hyper_rustls::HttpsConnectorBuilder::new()
13049/// #         .with_native_roots()
13050/// #         .unwrap()
13051/// #         .https_or_http()
13052/// #         .enable_http1()
13053/// #         .build()
13054/// # );
13055/// # let mut hub = NetworkSecurity::new(client, auth);
13056/// // As the method needs a request, you would usually fill it with the desired information
13057/// // into the respective structure. Some of the parts shown here might not be applicable !
13058/// // Values shown here are possibly random and not representative !
13059/// let mut req = AddAddressGroupItemsRequest::default();
13060///
13061/// // You can configure optional parameters by calling the respective setters at will, and
13062/// // execute the final call using `doit()`.
13063/// // Values shown here are possibly random and not representative !
13064/// let result = hub.projects().locations_address_groups_add_items(req, "addressGroup")
13065///              .doit().await;
13066/// # }
13067/// ```
13068pub struct ProjectLocationAddressGroupAddItemCall<'a, C>
13069where
13070    C: 'a,
13071{
13072    hub: &'a NetworkSecurity<C>,
13073    _request: AddAddressGroupItemsRequest,
13074    _address_group: String,
13075    _delegate: Option<&'a mut dyn common::Delegate>,
13076    _additional_params: HashMap<String, String>,
13077    _scopes: BTreeSet<String>,
13078}
13079
13080impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupAddItemCall<'a, C> {}
13081
13082impl<'a, C> ProjectLocationAddressGroupAddItemCall<'a, C>
13083where
13084    C: common::Connector,
13085{
13086    /// Perform the operation you have build so far.
13087    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13088        use std::borrow::Cow;
13089        use std::io::{Read, Seek};
13090
13091        use common::{url::Params, ToParts};
13092        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13093
13094        let mut dd = common::DefaultDelegate;
13095        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13096        dlg.begin(common::MethodInfo {
13097            id: "networksecurity.projects.locations.addressGroups.addItems",
13098            http_method: hyper::Method::POST,
13099        });
13100
13101        for &field in ["alt", "addressGroup"].iter() {
13102            if self._additional_params.contains_key(field) {
13103                dlg.finished(false);
13104                return Err(common::Error::FieldClash(field));
13105            }
13106        }
13107
13108        let mut params = Params::with_capacity(4 + self._additional_params.len());
13109        params.push("addressGroup", self._address_group);
13110
13111        params.extend(self._additional_params.iter());
13112
13113        params.push("alt", "json");
13114        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:addItems";
13115        if self._scopes.is_empty() {
13116            self._scopes
13117                .insert(Scope::CloudPlatform.as_ref().to_string());
13118        }
13119
13120        #[allow(clippy::single_element_loop)]
13121        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
13122            url = params.uri_replacement(url, param_name, find_this, true);
13123        }
13124        {
13125            let to_remove = ["addressGroup"];
13126            params.remove_params(&to_remove);
13127        }
13128
13129        let url = params.parse_with_url(&url);
13130
13131        let mut json_mime_type = mime::APPLICATION_JSON;
13132        let mut request_value_reader = {
13133            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13134            common::remove_json_null_values(&mut value);
13135            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13136            serde_json::to_writer(&mut dst, &value).unwrap();
13137            dst
13138        };
13139        let request_size = request_value_reader
13140            .seek(std::io::SeekFrom::End(0))
13141            .unwrap();
13142        request_value_reader
13143            .seek(std::io::SeekFrom::Start(0))
13144            .unwrap();
13145
13146        loop {
13147            let token = match self
13148                .hub
13149                .auth
13150                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13151                .await
13152            {
13153                Ok(token) => token,
13154                Err(e) => match dlg.token(e) {
13155                    Ok(token) => token,
13156                    Err(e) => {
13157                        dlg.finished(false);
13158                        return Err(common::Error::MissingToken(e));
13159                    }
13160                },
13161            };
13162            request_value_reader
13163                .seek(std::io::SeekFrom::Start(0))
13164                .unwrap();
13165            let mut req_result = {
13166                let client = &self.hub.client;
13167                dlg.pre_request();
13168                let mut req_builder = hyper::Request::builder()
13169                    .method(hyper::Method::POST)
13170                    .uri(url.as_str())
13171                    .header(USER_AGENT, self.hub._user_agent.clone());
13172
13173                if let Some(token) = token.as_ref() {
13174                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13175                }
13176
13177                let request = req_builder
13178                    .header(CONTENT_TYPE, json_mime_type.to_string())
13179                    .header(CONTENT_LENGTH, request_size as u64)
13180                    .body(common::to_body(
13181                        request_value_reader.get_ref().clone().into(),
13182                    ));
13183
13184                client.request(request.unwrap()).await
13185            };
13186
13187            match req_result {
13188                Err(err) => {
13189                    if let common::Retry::After(d) = dlg.http_error(&err) {
13190                        sleep(d).await;
13191                        continue;
13192                    }
13193                    dlg.finished(false);
13194                    return Err(common::Error::HttpError(err));
13195                }
13196                Ok(res) => {
13197                    let (mut parts, body) = res.into_parts();
13198                    let mut body = common::Body::new(body);
13199                    if !parts.status.is_success() {
13200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13201                        let error = serde_json::from_str(&common::to_string(&bytes));
13202                        let response = common::to_response(parts, bytes.into());
13203
13204                        if let common::Retry::After(d) =
13205                            dlg.http_failure(&response, error.as_ref().ok())
13206                        {
13207                            sleep(d).await;
13208                            continue;
13209                        }
13210
13211                        dlg.finished(false);
13212
13213                        return Err(match error {
13214                            Ok(value) => common::Error::BadRequest(value),
13215                            _ => common::Error::Failure(response),
13216                        });
13217                    }
13218                    let response = {
13219                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13220                        let encoded = common::to_string(&bytes);
13221                        match serde_json::from_str(&encoded) {
13222                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13223                            Err(error) => {
13224                                dlg.response_json_decode_error(&encoded, &error);
13225                                return Err(common::Error::JsonDecodeError(
13226                                    encoded.to_string(),
13227                                    error,
13228                                ));
13229                            }
13230                        }
13231                    };
13232
13233                    dlg.finished(true);
13234                    return Ok(response);
13235                }
13236            }
13237        }
13238    }
13239
13240    ///
13241    /// Sets the *request* property to the given value.
13242    ///
13243    /// Even though the property as already been set when instantiating this call,
13244    /// we provide this method for API completeness.
13245    pub fn request(
13246        mut self,
13247        new_value: AddAddressGroupItemsRequest,
13248    ) -> ProjectLocationAddressGroupAddItemCall<'a, C> {
13249        self._request = new_value;
13250        self
13251    }
13252    /// Required. A name of the AddressGroup to add items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
13253    ///
13254    /// Sets the *address group* path property to the given value.
13255    ///
13256    /// Even though the property as already been set when instantiating this call,
13257    /// we provide this method for API completeness.
13258    pub fn address_group(
13259        mut self,
13260        new_value: &str,
13261    ) -> ProjectLocationAddressGroupAddItemCall<'a, C> {
13262        self._address_group = new_value.to_string();
13263        self
13264    }
13265    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13266    /// while executing the actual API request.
13267    ///
13268    /// ````text
13269    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13270    /// ````
13271    ///
13272    /// Sets the *delegate* property to the given value.
13273    pub fn delegate(
13274        mut self,
13275        new_value: &'a mut dyn common::Delegate,
13276    ) -> ProjectLocationAddressGroupAddItemCall<'a, C> {
13277        self._delegate = Some(new_value);
13278        self
13279    }
13280
13281    /// Set any additional parameter of the query string used in the request.
13282    /// It should be used to set parameters which are not yet available through their own
13283    /// setters.
13284    ///
13285    /// Please note that this method must not be used to set any of the known parameters
13286    /// which have their own setter method. If done anyway, the request will fail.
13287    ///
13288    /// # Additional Parameters
13289    ///
13290    /// * *$.xgafv* (query-string) - V1 error format.
13291    /// * *access_token* (query-string) - OAuth access token.
13292    /// * *alt* (query-string) - Data format for response.
13293    /// * *callback* (query-string) - JSONP
13294    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13295    /// * *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.
13296    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13297    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13298    /// * *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.
13299    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13300    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13301    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupAddItemCall<'a, C>
13302    where
13303        T: AsRef<str>,
13304    {
13305        self._additional_params
13306            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13307        self
13308    }
13309
13310    /// Identifies the authorization scope for the method you are building.
13311    ///
13312    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13313    /// [`Scope::CloudPlatform`].
13314    ///
13315    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13316    /// tokens for more than one scope.
13317    ///
13318    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13319    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13320    /// sufficient, a read-write scope will do as well.
13321    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupAddItemCall<'a, C>
13322    where
13323        St: AsRef<str>,
13324    {
13325        self._scopes.insert(String::from(scope.as_ref()));
13326        self
13327    }
13328    /// Identifies the authorization scope(s) for the method you are building.
13329    ///
13330    /// See [`Self::add_scope()`] for details.
13331    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupAddItemCall<'a, C>
13332    where
13333        I: IntoIterator<Item = St>,
13334        St: AsRef<str>,
13335    {
13336        self._scopes
13337            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13338        self
13339    }
13340
13341    /// Removes all scopes, and no default scope will be used either.
13342    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13343    /// for details).
13344    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupAddItemCall<'a, C> {
13345        self._scopes.clear();
13346        self
13347    }
13348}
13349
13350/// Clones items from one address group to another.
13351///
13352/// A builder for the *locations.addressGroups.cloneItems* method supported by a *project* resource.
13353/// It is not used directly, but through a [`ProjectMethods`] instance.
13354///
13355/// # Example
13356///
13357/// Instantiate a resource method builder
13358///
13359/// ```test_harness,no_run
13360/// # extern crate hyper;
13361/// # extern crate hyper_rustls;
13362/// # extern crate google_networksecurity1 as networksecurity1;
13363/// use networksecurity1::api::CloneAddressGroupItemsRequest;
13364/// # async fn dox() {
13365/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13366///
13367/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13368/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13369/// #     secret,
13370/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13371/// # ).build().await.unwrap();
13372///
13373/// # let client = hyper_util::client::legacy::Client::builder(
13374/// #     hyper_util::rt::TokioExecutor::new()
13375/// # )
13376/// # .build(
13377/// #     hyper_rustls::HttpsConnectorBuilder::new()
13378/// #         .with_native_roots()
13379/// #         .unwrap()
13380/// #         .https_or_http()
13381/// #         .enable_http1()
13382/// #         .build()
13383/// # );
13384/// # let mut hub = NetworkSecurity::new(client, auth);
13385/// // As the method needs a request, you would usually fill it with the desired information
13386/// // into the respective structure. Some of the parts shown here might not be applicable !
13387/// // Values shown here are possibly random and not representative !
13388/// let mut req = CloneAddressGroupItemsRequest::default();
13389///
13390/// // You can configure optional parameters by calling the respective setters at will, and
13391/// // execute the final call using `doit()`.
13392/// // Values shown here are possibly random and not representative !
13393/// let result = hub.projects().locations_address_groups_clone_items(req, "addressGroup")
13394///              .doit().await;
13395/// # }
13396/// ```
13397pub struct ProjectLocationAddressGroupCloneItemCall<'a, C>
13398where
13399    C: 'a,
13400{
13401    hub: &'a NetworkSecurity<C>,
13402    _request: CloneAddressGroupItemsRequest,
13403    _address_group: String,
13404    _delegate: Option<&'a mut dyn common::Delegate>,
13405    _additional_params: HashMap<String, String>,
13406    _scopes: BTreeSet<String>,
13407}
13408
13409impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupCloneItemCall<'a, C> {}
13410
13411impl<'a, C> ProjectLocationAddressGroupCloneItemCall<'a, C>
13412where
13413    C: common::Connector,
13414{
13415    /// Perform the operation you have build so far.
13416    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13417        use std::borrow::Cow;
13418        use std::io::{Read, Seek};
13419
13420        use common::{url::Params, ToParts};
13421        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13422
13423        let mut dd = common::DefaultDelegate;
13424        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13425        dlg.begin(common::MethodInfo {
13426            id: "networksecurity.projects.locations.addressGroups.cloneItems",
13427            http_method: hyper::Method::POST,
13428        });
13429
13430        for &field in ["alt", "addressGroup"].iter() {
13431            if self._additional_params.contains_key(field) {
13432                dlg.finished(false);
13433                return Err(common::Error::FieldClash(field));
13434            }
13435        }
13436
13437        let mut params = Params::with_capacity(4 + self._additional_params.len());
13438        params.push("addressGroup", self._address_group);
13439
13440        params.extend(self._additional_params.iter());
13441
13442        params.push("alt", "json");
13443        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:cloneItems";
13444        if self._scopes.is_empty() {
13445            self._scopes
13446                .insert(Scope::CloudPlatform.as_ref().to_string());
13447        }
13448
13449        #[allow(clippy::single_element_loop)]
13450        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
13451            url = params.uri_replacement(url, param_name, find_this, true);
13452        }
13453        {
13454            let to_remove = ["addressGroup"];
13455            params.remove_params(&to_remove);
13456        }
13457
13458        let url = params.parse_with_url(&url);
13459
13460        let mut json_mime_type = mime::APPLICATION_JSON;
13461        let mut request_value_reader = {
13462            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13463            common::remove_json_null_values(&mut value);
13464            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13465            serde_json::to_writer(&mut dst, &value).unwrap();
13466            dst
13467        };
13468        let request_size = request_value_reader
13469            .seek(std::io::SeekFrom::End(0))
13470            .unwrap();
13471        request_value_reader
13472            .seek(std::io::SeekFrom::Start(0))
13473            .unwrap();
13474
13475        loop {
13476            let token = match self
13477                .hub
13478                .auth
13479                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13480                .await
13481            {
13482                Ok(token) => token,
13483                Err(e) => match dlg.token(e) {
13484                    Ok(token) => token,
13485                    Err(e) => {
13486                        dlg.finished(false);
13487                        return Err(common::Error::MissingToken(e));
13488                    }
13489                },
13490            };
13491            request_value_reader
13492                .seek(std::io::SeekFrom::Start(0))
13493                .unwrap();
13494            let mut req_result = {
13495                let client = &self.hub.client;
13496                dlg.pre_request();
13497                let mut req_builder = hyper::Request::builder()
13498                    .method(hyper::Method::POST)
13499                    .uri(url.as_str())
13500                    .header(USER_AGENT, self.hub._user_agent.clone());
13501
13502                if let Some(token) = token.as_ref() {
13503                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13504                }
13505
13506                let request = req_builder
13507                    .header(CONTENT_TYPE, json_mime_type.to_string())
13508                    .header(CONTENT_LENGTH, request_size as u64)
13509                    .body(common::to_body(
13510                        request_value_reader.get_ref().clone().into(),
13511                    ));
13512
13513                client.request(request.unwrap()).await
13514            };
13515
13516            match req_result {
13517                Err(err) => {
13518                    if let common::Retry::After(d) = dlg.http_error(&err) {
13519                        sleep(d).await;
13520                        continue;
13521                    }
13522                    dlg.finished(false);
13523                    return Err(common::Error::HttpError(err));
13524                }
13525                Ok(res) => {
13526                    let (mut parts, body) = res.into_parts();
13527                    let mut body = common::Body::new(body);
13528                    if !parts.status.is_success() {
13529                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13530                        let error = serde_json::from_str(&common::to_string(&bytes));
13531                        let response = common::to_response(parts, bytes.into());
13532
13533                        if let common::Retry::After(d) =
13534                            dlg.http_failure(&response, error.as_ref().ok())
13535                        {
13536                            sleep(d).await;
13537                            continue;
13538                        }
13539
13540                        dlg.finished(false);
13541
13542                        return Err(match error {
13543                            Ok(value) => common::Error::BadRequest(value),
13544                            _ => common::Error::Failure(response),
13545                        });
13546                    }
13547                    let response = {
13548                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13549                        let encoded = common::to_string(&bytes);
13550                        match serde_json::from_str(&encoded) {
13551                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13552                            Err(error) => {
13553                                dlg.response_json_decode_error(&encoded, &error);
13554                                return Err(common::Error::JsonDecodeError(
13555                                    encoded.to_string(),
13556                                    error,
13557                                ));
13558                            }
13559                        }
13560                    };
13561
13562                    dlg.finished(true);
13563                    return Ok(response);
13564                }
13565            }
13566        }
13567    }
13568
13569    ///
13570    /// Sets the *request* property to the given value.
13571    ///
13572    /// Even though the property as already been set when instantiating this call,
13573    /// we provide this method for API completeness.
13574    pub fn request(
13575        mut self,
13576        new_value: CloneAddressGroupItemsRequest,
13577    ) -> ProjectLocationAddressGroupCloneItemCall<'a, C> {
13578        self._request = new_value;
13579        self
13580    }
13581    /// Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
13582    ///
13583    /// Sets the *address group* path property to the given value.
13584    ///
13585    /// Even though the property as already been set when instantiating this call,
13586    /// we provide this method for API completeness.
13587    pub fn address_group(
13588        mut self,
13589        new_value: &str,
13590    ) -> ProjectLocationAddressGroupCloneItemCall<'a, C> {
13591        self._address_group = new_value.to_string();
13592        self
13593    }
13594    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13595    /// while executing the actual API request.
13596    ///
13597    /// ````text
13598    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13599    /// ````
13600    ///
13601    /// Sets the *delegate* property to the given value.
13602    pub fn delegate(
13603        mut self,
13604        new_value: &'a mut dyn common::Delegate,
13605    ) -> ProjectLocationAddressGroupCloneItemCall<'a, C> {
13606        self._delegate = Some(new_value);
13607        self
13608    }
13609
13610    /// Set any additional parameter of the query string used in the request.
13611    /// It should be used to set parameters which are not yet available through their own
13612    /// setters.
13613    ///
13614    /// Please note that this method must not be used to set any of the known parameters
13615    /// which have their own setter method. If done anyway, the request will fail.
13616    ///
13617    /// # Additional Parameters
13618    ///
13619    /// * *$.xgafv* (query-string) - V1 error format.
13620    /// * *access_token* (query-string) - OAuth access token.
13621    /// * *alt* (query-string) - Data format for response.
13622    /// * *callback* (query-string) - JSONP
13623    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13624    /// * *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.
13625    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13626    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13627    /// * *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.
13628    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13629    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13630    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupCloneItemCall<'a, C>
13631    where
13632        T: AsRef<str>,
13633    {
13634        self._additional_params
13635            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13636        self
13637    }
13638
13639    /// Identifies the authorization scope for the method you are building.
13640    ///
13641    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13642    /// [`Scope::CloudPlatform`].
13643    ///
13644    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13645    /// tokens for more than one scope.
13646    ///
13647    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13648    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13649    /// sufficient, a read-write scope will do as well.
13650    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupCloneItemCall<'a, C>
13651    where
13652        St: AsRef<str>,
13653    {
13654        self._scopes.insert(String::from(scope.as_ref()));
13655        self
13656    }
13657    /// Identifies the authorization scope(s) for the method you are building.
13658    ///
13659    /// See [`Self::add_scope()`] for details.
13660    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupCloneItemCall<'a, C>
13661    where
13662        I: IntoIterator<Item = St>,
13663        St: AsRef<str>,
13664    {
13665        self._scopes
13666            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13667        self
13668    }
13669
13670    /// Removes all scopes, and no default scope will be used either.
13671    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13672    /// for details).
13673    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupCloneItemCall<'a, C> {
13674        self._scopes.clear();
13675        self
13676    }
13677}
13678
13679/// Creates a new address group in a given project and location.
13680///
13681/// A builder for the *locations.addressGroups.create* method supported by a *project* resource.
13682/// It is not used directly, but through a [`ProjectMethods`] instance.
13683///
13684/// # Example
13685///
13686/// Instantiate a resource method builder
13687///
13688/// ```test_harness,no_run
13689/// # extern crate hyper;
13690/// # extern crate hyper_rustls;
13691/// # extern crate google_networksecurity1 as networksecurity1;
13692/// use networksecurity1::api::AddressGroup;
13693/// # async fn dox() {
13694/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13695///
13696/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13698/// #     secret,
13699/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13700/// # ).build().await.unwrap();
13701///
13702/// # let client = hyper_util::client::legacy::Client::builder(
13703/// #     hyper_util::rt::TokioExecutor::new()
13704/// # )
13705/// # .build(
13706/// #     hyper_rustls::HttpsConnectorBuilder::new()
13707/// #         .with_native_roots()
13708/// #         .unwrap()
13709/// #         .https_or_http()
13710/// #         .enable_http1()
13711/// #         .build()
13712/// # );
13713/// # let mut hub = NetworkSecurity::new(client, auth);
13714/// // As the method needs a request, you would usually fill it with the desired information
13715/// // into the respective structure. Some of the parts shown here might not be applicable !
13716/// // Values shown here are possibly random and not representative !
13717/// let mut req = AddressGroup::default();
13718///
13719/// // You can configure optional parameters by calling the respective setters at will, and
13720/// // execute the final call using `doit()`.
13721/// // Values shown here are possibly random and not representative !
13722/// let result = hub.projects().locations_address_groups_create(req, "parent")
13723///              .request_id("invidunt")
13724///              .address_group_id("Stet")
13725///              .doit().await;
13726/// # }
13727/// ```
13728pub struct ProjectLocationAddressGroupCreateCall<'a, C>
13729where
13730    C: 'a,
13731{
13732    hub: &'a NetworkSecurity<C>,
13733    _request: AddressGroup,
13734    _parent: String,
13735    _request_id: Option<String>,
13736    _address_group_id: Option<String>,
13737    _delegate: Option<&'a mut dyn common::Delegate>,
13738    _additional_params: HashMap<String, String>,
13739    _scopes: BTreeSet<String>,
13740}
13741
13742impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupCreateCall<'a, C> {}
13743
13744impl<'a, C> ProjectLocationAddressGroupCreateCall<'a, C>
13745where
13746    C: common::Connector,
13747{
13748    /// Perform the operation you have build so far.
13749    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13750        use std::borrow::Cow;
13751        use std::io::{Read, Seek};
13752
13753        use common::{url::Params, ToParts};
13754        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13755
13756        let mut dd = common::DefaultDelegate;
13757        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13758        dlg.begin(common::MethodInfo {
13759            id: "networksecurity.projects.locations.addressGroups.create",
13760            http_method: hyper::Method::POST,
13761        });
13762
13763        for &field in ["alt", "parent", "requestId", "addressGroupId"].iter() {
13764            if self._additional_params.contains_key(field) {
13765                dlg.finished(false);
13766                return Err(common::Error::FieldClash(field));
13767            }
13768        }
13769
13770        let mut params = Params::with_capacity(6 + self._additional_params.len());
13771        params.push("parent", self._parent);
13772        if let Some(value) = self._request_id.as_ref() {
13773            params.push("requestId", value);
13774        }
13775        if let Some(value) = self._address_group_id.as_ref() {
13776            params.push("addressGroupId", value);
13777        }
13778
13779        params.extend(self._additional_params.iter());
13780
13781        params.push("alt", "json");
13782        let mut url = self.hub._base_url.clone() + "v1/{+parent}/addressGroups";
13783        if self._scopes.is_empty() {
13784            self._scopes
13785                .insert(Scope::CloudPlatform.as_ref().to_string());
13786        }
13787
13788        #[allow(clippy::single_element_loop)]
13789        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13790            url = params.uri_replacement(url, param_name, find_this, true);
13791        }
13792        {
13793            let to_remove = ["parent"];
13794            params.remove_params(&to_remove);
13795        }
13796
13797        let url = params.parse_with_url(&url);
13798
13799        let mut json_mime_type = mime::APPLICATION_JSON;
13800        let mut request_value_reader = {
13801            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13802            common::remove_json_null_values(&mut value);
13803            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13804            serde_json::to_writer(&mut dst, &value).unwrap();
13805            dst
13806        };
13807        let request_size = request_value_reader
13808            .seek(std::io::SeekFrom::End(0))
13809            .unwrap();
13810        request_value_reader
13811            .seek(std::io::SeekFrom::Start(0))
13812            .unwrap();
13813
13814        loop {
13815            let token = match self
13816                .hub
13817                .auth
13818                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13819                .await
13820            {
13821                Ok(token) => token,
13822                Err(e) => match dlg.token(e) {
13823                    Ok(token) => token,
13824                    Err(e) => {
13825                        dlg.finished(false);
13826                        return Err(common::Error::MissingToken(e));
13827                    }
13828                },
13829            };
13830            request_value_reader
13831                .seek(std::io::SeekFrom::Start(0))
13832                .unwrap();
13833            let mut req_result = {
13834                let client = &self.hub.client;
13835                dlg.pre_request();
13836                let mut req_builder = hyper::Request::builder()
13837                    .method(hyper::Method::POST)
13838                    .uri(url.as_str())
13839                    .header(USER_AGENT, self.hub._user_agent.clone());
13840
13841                if let Some(token) = token.as_ref() {
13842                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13843                }
13844
13845                let request = req_builder
13846                    .header(CONTENT_TYPE, json_mime_type.to_string())
13847                    .header(CONTENT_LENGTH, request_size as u64)
13848                    .body(common::to_body(
13849                        request_value_reader.get_ref().clone().into(),
13850                    ));
13851
13852                client.request(request.unwrap()).await
13853            };
13854
13855            match req_result {
13856                Err(err) => {
13857                    if let common::Retry::After(d) = dlg.http_error(&err) {
13858                        sleep(d).await;
13859                        continue;
13860                    }
13861                    dlg.finished(false);
13862                    return Err(common::Error::HttpError(err));
13863                }
13864                Ok(res) => {
13865                    let (mut parts, body) = res.into_parts();
13866                    let mut body = common::Body::new(body);
13867                    if !parts.status.is_success() {
13868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13869                        let error = serde_json::from_str(&common::to_string(&bytes));
13870                        let response = common::to_response(parts, bytes.into());
13871
13872                        if let common::Retry::After(d) =
13873                            dlg.http_failure(&response, error.as_ref().ok())
13874                        {
13875                            sleep(d).await;
13876                            continue;
13877                        }
13878
13879                        dlg.finished(false);
13880
13881                        return Err(match error {
13882                            Ok(value) => common::Error::BadRequest(value),
13883                            _ => common::Error::Failure(response),
13884                        });
13885                    }
13886                    let response = {
13887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13888                        let encoded = common::to_string(&bytes);
13889                        match serde_json::from_str(&encoded) {
13890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13891                            Err(error) => {
13892                                dlg.response_json_decode_error(&encoded, &error);
13893                                return Err(common::Error::JsonDecodeError(
13894                                    encoded.to_string(),
13895                                    error,
13896                                ));
13897                            }
13898                        }
13899                    };
13900
13901                    dlg.finished(true);
13902                    return Ok(response);
13903                }
13904            }
13905        }
13906    }
13907
13908    ///
13909    /// Sets the *request* property to the given value.
13910    ///
13911    /// Even though the property as already been set when instantiating this call,
13912    /// we provide this method for API completeness.
13913    pub fn request(
13914        mut self,
13915        new_value: AddressGroup,
13916    ) -> ProjectLocationAddressGroupCreateCall<'a, C> {
13917        self._request = new_value;
13918        self
13919    }
13920    /// Required. The parent resource of the AddressGroup. Must be in the format `projects/*/locations/{location}`.
13921    ///
13922    /// Sets the *parent* path property to the given value.
13923    ///
13924    /// Even though the property as already been set when instantiating this call,
13925    /// we provide this method for API completeness.
13926    pub fn parent(mut self, new_value: &str) -> ProjectLocationAddressGroupCreateCall<'a, C> {
13927        self._parent = new_value.to_string();
13928        self
13929    }
13930    /// Optional. 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).
13931    ///
13932    /// Sets the *request id* query property to the given value.
13933    pub fn request_id(mut self, new_value: &str) -> ProjectLocationAddressGroupCreateCall<'a, C> {
13934        self._request_id = Some(new_value.to_string());
13935        self
13936    }
13937    /// Required. Short name of the AddressGroup resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "authz_policy".
13938    ///
13939    /// Sets the *address group id* query property to the given value.
13940    pub fn address_group_id(
13941        mut self,
13942        new_value: &str,
13943    ) -> ProjectLocationAddressGroupCreateCall<'a, C> {
13944        self._address_group_id = Some(new_value.to_string());
13945        self
13946    }
13947    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13948    /// while executing the actual API request.
13949    ///
13950    /// ````text
13951    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13952    /// ````
13953    ///
13954    /// Sets the *delegate* property to the given value.
13955    pub fn delegate(
13956        mut self,
13957        new_value: &'a mut dyn common::Delegate,
13958    ) -> ProjectLocationAddressGroupCreateCall<'a, C> {
13959        self._delegate = Some(new_value);
13960        self
13961    }
13962
13963    /// Set any additional parameter of the query string used in the request.
13964    /// It should be used to set parameters which are not yet available through their own
13965    /// setters.
13966    ///
13967    /// Please note that this method must not be used to set any of the known parameters
13968    /// which have their own setter method. If done anyway, the request will fail.
13969    ///
13970    /// # Additional Parameters
13971    ///
13972    /// * *$.xgafv* (query-string) - V1 error format.
13973    /// * *access_token* (query-string) - OAuth access token.
13974    /// * *alt* (query-string) - Data format for response.
13975    /// * *callback* (query-string) - JSONP
13976    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13977    /// * *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.
13978    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13979    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13980    /// * *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.
13981    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13982    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13983    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupCreateCall<'a, C>
13984    where
13985        T: AsRef<str>,
13986    {
13987        self._additional_params
13988            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13989        self
13990    }
13991
13992    /// Identifies the authorization scope for the method you are building.
13993    ///
13994    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13995    /// [`Scope::CloudPlatform`].
13996    ///
13997    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13998    /// tokens for more than one scope.
13999    ///
14000    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14001    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14002    /// sufficient, a read-write scope will do as well.
14003    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupCreateCall<'a, C>
14004    where
14005        St: AsRef<str>,
14006    {
14007        self._scopes.insert(String::from(scope.as_ref()));
14008        self
14009    }
14010    /// Identifies the authorization scope(s) for the method you are building.
14011    ///
14012    /// See [`Self::add_scope()`] for details.
14013    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupCreateCall<'a, C>
14014    where
14015        I: IntoIterator<Item = St>,
14016        St: AsRef<str>,
14017    {
14018        self._scopes
14019            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14020        self
14021    }
14022
14023    /// Removes all scopes, and no default scope will be used either.
14024    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14025    /// for details).
14026    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupCreateCall<'a, C> {
14027        self._scopes.clear();
14028        self
14029    }
14030}
14031
14032/// Deletes a single address group.
14033///
14034/// A builder for the *locations.addressGroups.delete* method supported by a *project* resource.
14035/// It is not used directly, but through a [`ProjectMethods`] instance.
14036///
14037/// # Example
14038///
14039/// Instantiate a resource method builder
14040///
14041/// ```test_harness,no_run
14042/// # extern crate hyper;
14043/// # extern crate hyper_rustls;
14044/// # extern crate google_networksecurity1 as networksecurity1;
14045/// # async fn dox() {
14046/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14047///
14048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14049/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14050/// #     secret,
14051/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14052/// # ).build().await.unwrap();
14053///
14054/// # let client = hyper_util::client::legacy::Client::builder(
14055/// #     hyper_util::rt::TokioExecutor::new()
14056/// # )
14057/// # .build(
14058/// #     hyper_rustls::HttpsConnectorBuilder::new()
14059/// #         .with_native_roots()
14060/// #         .unwrap()
14061/// #         .https_or_http()
14062/// #         .enable_http1()
14063/// #         .build()
14064/// # );
14065/// # let mut hub = NetworkSecurity::new(client, auth);
14066/// // You can configure optional parameters by calling the respective setters at will, and
14067/// // execute the final call using `doit()`.
14068/// // Values shown here are possibly random and not representative !
14069/// let result = hub.projects().locations_address_groups_delete("name")
14070///              .request_id("elitr")
14071///              .doit().await;
14072/// # }
14073/// ```
14074pub struct ProjectLocationAddressGroupDeleteCall<'a, C>
14075where
14076    C: 'a,
14077{
14078    hub: &'a NetworkSecurity<C>,
14079    _name: String,
14080    _request_id: Option<String>,
14081    _delegate: Option<&'a mut dyn common::Delegate>,
14082    _additional_params: HashMap<String, String>,
14083    _scopes: BTreeSet<String>,
14084}
14085
14086impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupDeleteCall<'a, C> {}
14087
14088impl<'a, C> ProjectLocationAddressGroupDeleteCall<'a, C>
14089where
14090    C: common::Connector,
14091{
14092    /// Perform the operation you have build so far.
14093    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14094        use std::borrow::Cow;
14095        use std::io::{Read, Seek};
14096
14097        use common::{url::Params, ToParts};
14098        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14099
14100        let mut dd = common::DefaultDelegate;
14101        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14102        dlg.begin(common::MethodInfo {
14103            id: "networksecurity.projects.locations.addressGroups.delete",
14104            http_method: hyper::Method::DELETE,
14105        });
14106
14107        for &field in ["alt", "name", "requestId"].iter() {
14108            if self._additional_params.contains_key(field) {
14109                dlg.finished(false);
14110                return Err(common::Error::FieldClash(field));
14111            }
14112        }
14113
14114        let mut params = Params::with_capacity(4 + self._additional_params.len());
14115        params.push("name", self._name);
14116        if let Some(value) = self._request_id.as_ref() {
14117            params.push("requestId", value);
14118        }
14119
14120        params.extend(self._additional_params.iter());
14121
14122        params.push("alt", "json");
14123        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14124        if self._scopes.is_empty() {
14125            self._scopes
14126                .insert(Scope::CloudPlatform.as_ref().to_string());
14127        }
14128
14129        #[allow(clippy::single_element_loop)]
14130        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14131            url = params.uri_replacement(url, param_name, find_this, true);
14132        }
14133        {
14134            let to_remove = ["name"];
14135            params.remove_params(&to_remove);
14136        }
14137
14138        let url = params.parse_with_url(&url);
14139
14140        loop {
14141            let token = match self
14142                .hub
14143                .auth
14144                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14145                .await
14146            {
14147                Ok(token) => token,
14148                Err(e) => match dlg.token(e) {
14149                    Ok(token) => token,
14150                    Err(e) => {
14151                        dlg.finished(false);
14152                        return Err(common::Error::MissingToken(e));
14153                    }
14154                },
14155            };
14156            let mut req_result = {
14157                let client = &self.hub.client;
14158                dlg.pre_request();
14159                let mut req_builder = hyper::Request::builder()
14160                    .method(hyper::Method::DELETE)
14161                    .uri(url.as_str())
14162                    .header(USER_AGENT, self.hub._user_agent.clone());
14163
14164                if let Some(token) = token.as_ref() {
14165                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14166                }
14167
14168                let request = req_builder
14169                    .header(CONTENT_LENGTH, 0_u64)
14170                    .body(common::to_body::<String>(None));
14171
14172                client.request(request.unwrap()).await
14173            };
14174
14175            match req_result {
14176                Err(err) => {
14177                    if let common::Retry::After(d) = dlg.http_error(&err) {
14178                        sleep(d).await;
14179                        continue;
14180                    }
14181                    dlg.finished(false);
14182                    return Err(common::Error::HttpError(err));
14183                }
14184                Ok(res) => {
14185                    let (mut parts, body) = res.into_parts();
14186                    let mut body = common::Body::new(body);
14187                    if !parts.status.is_success() {
14188                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14189                        let error = serde_json::from_str(&common::to_string(&bytes));
14190                        let response = common::to_response(parts, bytes.into());
14191
14192                        if let common::Retry::After(d) =
14193                            dlg.http_failure(&response, error.as_ref().ok())
14194                        {
14195                            sleep(d).await;
14196                            continue;
14197                        }
14198
14199                        dlg.finished(false);
14200
14201                        return Err(match error {
14202                            Ok(value) => common::Error::BadRequest(value),
14203                            _ => common::Error::Failure(response),
14204                        });
14205                    }
14206                    let response = {
14207                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14208                        let encoded = common::to_string(&bytes);
14209                        match serde_json::from_str(&encoded) {
14210                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14211                            Err(error) => {
14212                                dlg.response_json_decode_error(&encoded, &error);
14213                                return Err(common::Error::JsonDecodeError(
14214                                    encoded.to_string(),
14215                                    error,
14216                                ));
14217                            }
14218                        }
14219                    };
14220
14221                    dlg.finished(true);
14222                    return Ok(response);
14223                }
14224            }
14225        }
14226    }
14227
14228    /// Required. A name of the AddressGroup to delete. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
14229    ///
14230    /// Sets the *name* path property to the given value.
14231    ///
14232    /// Even though the property as already been set when instantiating this call,
14233    /// we provide this method for API completeness.
14234    pub fn name(mut self, new_value: &str) -> ProjectLocationAddressGroupDeleteCall<'a, C> {
14235        self._name = new_value.to_string();
14236        self
14237    }
14238    /// Optional. 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).
14239    ///
14240    /// Sets the *request id* query property to the given value.
14241    pub fn request_id(mut self, new_value: &str) -> ProjectLocationAddressGroupDeleteCall<'a, C> {
14242        self._request_id = Some(new_value.to_string());
14243        self
14244    }
14245    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14246    /// while executing the actual API request.
14247    ///
14248    /// ````text
14249    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14250    /// ````
14251    ///
14252    /// Sets the *delegate* property to the given value.
14253    pub fn delegate(
14254        mut self,
14255        new_value: &'a mut dyn common::Delegate,
14256    ) -> ProjectLocationAddressGroupDeleteCall<'a, C> {
14257        self._delegate = Some(new_value);
14258        self
14259    }
14260
14261    /// Set any additional parameter of the query string used in the request.
14262    /// It should be used to set parameters which are not yet available through their own
14263    /// setters.
14264    ///
14265    /// Please note that this method must not be used to set any of the known parameters
14266    /// which have their own setter method. If done anyway, the request will fail.
14267    ///
14268    /// # Additional Parameters
14269    ///
14270    /// * *$.xgafv* (query-string) - V1 error format.
14271    /// * *access_token* (query-string) - OAuth access token.
14272    /// * *alt* (query-string) - Data format for response.
14273    /// * *callback* (query-string) - JSONP
14274    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14275    /// * *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.
14276    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14277    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14278    /// * *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.
14279    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14280    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14281    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupDeleteCall<'a, C>
14282    where
14283        T: AsRef<str>,
14284    {
14285        self._additional_params
14286            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14287        self
14288    }
14289
14290    /// Identifies the authorization scope for the method you are building.
14291    ///
14292    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14293    /// [`Scope::CloudPlatform`].
14294    ///
14295    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14296    /// tokens for more than one scope.
14297    ///
14298    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14299    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14300    /// sufficient, a read-write scope will do as well.
14301    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupDeleteCall<'a, C>
14302    where
14303        St: AsRef<str>,
14304    {
14305        self._scopes.insert(String::from(scope.as_ref()));
14306        self
14307    }
14308    /// Identifies the authorization scope(s) for the method you are building.
14309    ///
14310    /// See [`Self::add_scope()`] for details.
14311    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupDeleteCall<'a, C>
14312    where
14313        I: IntoIterator<Item = St>,
14314        St: AsRef<str>,
14315    {
14316        self._scopes
14317            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14318        self
14319    }
14320
14321    /// Removes all scopes, and no default scope will be used either.
14322    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14323    /// for details).
14324    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupDeleteCall<'a, C> {
14325        self._scopes.clear();
14326        self
14327    }
14328}
14329
14330/// Gets details of a single address group.
14331///
14332/// A builder for the *locations.addressGroups.get* method supported by a *project* resource.
14333/// It is not used directly, but through a [`ProjectMethods`] instance.
14334///
14335/// # Example
14336///
14337/// Instantiate a resource method builder
14338///
14339/// ```test_harness,no_run
14340/// # extern crate hyper;
14341/// # extern crate hyper_rustls;
14342/// # extern crate google_networksecurity1 as networksecurity1;
14343/// # async fn dox() {
14344/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14345///
14346/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14347/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14348/// #     secret,
14349/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14350/// # ).build().await.unwrap();
14351///
14352/// # let client = hyper_util::client::legacy::Client::builder(
14353/// #     hyper_util::rt::TokioExecutor::new()
14354/// # )
14355/// # .build(
14356/// #     hyper_rustls::HttpsConnectorBuilder::new()
14357/// #         .with_native_roots()
14358/// #         .unwrap()
14359/// #         .https_or_http()
14360/// #         .enable_http1()
14361/// #         .build()
14362/// # );
14363/// # let mut hub = NetworkSecurity::new(client, auth);
14364/// // You can configure optional parameters by calling the respective setters at will, and
14365/// // execute the final call using `doit()`.
14366/// // Values shown here are possibly random and not representative !
14367/// let result = hub.projects().locations_address_groups_get("name")
14368///              .doit().await;
14369/// # }
14370/// ```
14371pub struct ProjectLocationAddressGroupGetCall<'a, C>
14372where
14373    C: 'a,
14374{
14375    hub: &'a NetworkSecurity<C>,
14376    _name: String,
14377    _delegate: Option<&'a mut dyn common::Delegate>,
14378    _additional_params: HashMap<String, String>,
14379    _scopes: BTreeSet<String>,
14380}
14381
14382impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupGetCall<'a, C> {}
14383
14384impl<'a, C> ProjectLocationAddressGroupGetCall<'a, C>
14385where
14386    C: common::Connector,
14387{
14388    /// Perform the operation you have build so far.
14389    pub async fn doit(mut self) -> common::Result<(common::Response, AddressGroup)> {
14390        use std::borrow::Cow;
14391        use std::io::{Read, Seek};
14392
14393        use common::{url::Params, ToParts};
14394        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14395
14396        let mut dd = common::DefaultDelegate;
14397        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14398        dlg.begin(common::MethodInfo {
14399            id: "networksecurity.projects.locations.addressGroups.get",
14400            http_method: hyper::Method::GET,
14401        });
14402
14403        for &field in ["alt", "name"].iter() {
14404            if self._additional_params.contains_key(field) {
14405                dlg.finished(false);
14406                return Err(common::Error::FieldClash(field));
14407            }
14408        }
14409
14410        let mut params = Params::with_capacity(3 + self._additional_params.len());
14411        params.push("name", self._name);
14412
14413        params.extend(self._additional_params.iter());
14414
14415        params.push("alt", "json");
14416        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14417        if self._scopes.is_empty() {
14418            self._scopes
14419                .insert(Scope::CloudPlatform.as_ref().to_string());
14420        }
14421
14422        #[allow(clippy::single_element_loop)]
14423        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14424            url = params.uri_replacement(url, param_name, find_this, true);
14425        }
14426        {
14427            let to_remove = ["name"];
14428            params.remove_params(&to_remove);
14429        }
14430
14431        let url = params.parse_with_url(&url);
14432
14433        loop {
14434            let token = match self
14435                .hub
14436                .auth
14437                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14438                .await
14439            {
14440                Ok(token) => token,
14441                Err(e) => match dlg.token(e) {
14442                    Ok(token) => token,
14443                    Err(e) => {
14444                        dlg.finished(false);
14445                        return Err(common::Error::MissingToken(e));
14446                    }
14447                },
14448            };
14449            let mut req_result = {
14450                let client = &self.hub.client;
14451                dlg.pre_request();
14452                let mut req_builder = hyper::Request::builder()
14453                    .method(hyper::Method::GET)
14454                    .uri(url.as_str())
14455                    .header(USER_AGENT, self.hub._user_agent.clone());
14456
14457                if let Some(token) = token.as_ref() {
14458                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14459                }
14460
14461                let request = req_builder
14462                    .header(CONTENT_LENGTH, 0_u64)
14463                    .body(common::to_body::<String>(None));
14464
14465                client.request(request.unwrap()).await
14466            };
14467
14468            match req_result {
14469                Err(err) => {
14470                    if let common::Retry::After(d) = dlg.http_error(&err) {
14471                        sleep(d).await;
14472                        continue;
14473                    }
14474                    dlg.finished(false);
14475                    return Err(common::Error::HttpError(err));
14476                }
14477                Ok(res) => {
14478                    let (mut parts, body) = res.into_parts();
14479                    let mut body = common::Body::new(body);
14480                    if !parts.status.is_success() {
14481                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14482                        let error = serde_json::from_str(&common::to_string(&bytes));
14483                        let response = common::to_response(parts, bytes.into());
14484
14485                        if let common::Retry::After(d) =
14486                            dlg.http_failure(&response, error.as_ref().ok())
14487                        {
14488                            sleep(d).await;
14489                            continue;
14490                        }
14491
14492                        dlg.finished(false);
14493
14494                        return Err(match error {
14495                            Ok(value) => common::Error::BadRequest(value),
14496                            _ => common::Error::Failure(response),
14497                        });
14498                    }
14499                    let response = {
14500                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14501                        let encoded = common::to_string(&bytes);
14502                        match serde_json::from_str(&encoded) {
14503                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14504                            Err(error) => {
14505                                dlg.response_json_decode_error(&encoded, &error);
14506                                return Err(common::Error::JsonDecodeError(
14507                                    encoded.to_string(),
14508                                    error,
14509                                ));
14510                            }
14511                        }
14512                    };
14513
14514                    dlg.finished(true);
14515                    return Ok(response);
14516                }
14517            }
14518        }
14519    }
14520
14521    /// Required. A name of the AddressGroup to get. Must be in the format `projects/*/locations/{location}/addressGroups/*`.
14522    ///
14523    /// Sets the *name* path property to the given value.
14524    ///
14525    /// Even though the property as already been set when instantiating this call,
14526    /// we provide this method for API completeness.
14527    pub fn name(mut self, new_value: &str) -> ProjectLocationAddressGroupGetCall<'a, C> {
14528        self._name = new_value.to_string();
14529        self
14530    }
14531    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14532    /// while executing the actual API request.
14533    ///
14534    /// ````text
14535    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14536    /// ````
14537    ///
14538    /// Sets the *delegate* property to the given value.
14539    pub fn delegate(
14540        mut self,
14541        new_value: &'a mut dyn common::Delegate,
14542    ) -> ProjectLocationAddressGroupGetCall<'a, C> {
14543        self._delegate = Some(new_value);
14544        self
14545    }
14546
14547    /// Set any additional parameter of the query string used in the request.
14548    /// It should be used to set parameters which are not yet available through their own
14549    /// setters.
14550    ///
14551    /// Please note that this method must not be used to set any of the known parameters
14552    /// which have their own setter method. If done anyway, the request will fail.
14553    ///
14554    /// # Additional Parameters
14555    ///
14556    /// * *$.xgafv* (query-string) - V1 error format.
14557    /// * *access_token* (query-string) - OAuth access token.
14558    /// * *alt* (query-string) - Data format for response.
14559    /// * *callback* (query-string) - JSONP
14560    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14561    /// * *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.
14562    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14563    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14564    /// * *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.
14565    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14566    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14567    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupGetCall<'a, C>
14568    where
14569        T: AsRef<str>,
14570    {
14571        self._additional_params
14572            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14573        self
14574    }
14575
14576    /// Identifies the authorization scope for the method you are building.
14577    ///
14578    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14579    /// [`Scope::CloudPlatform`].
14580    ///
14581    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14582    /// tokens for more than one scope.
14583    ///
14584    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14585    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14586    /// sufficient, a read-write scope will do as well.
14587    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupGetCall<'a, C>
14588    where
14589        St: AsRef<str>,
14590    {
14591        self._scopes.insert(String::from(scope.as_ref()));
14592        self
14593    }
14594    /// Identifies the authorization scope(s) for the method you are building.
14595    ///
14596    /// See [`Self::add_scope()`] for details.
14597    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupGetCall<'a, C>
14598    where
14599        I: IntoIterator<Item = St>,
14600        St: AsRef<str>,
14601    {
14602        self._scopes
14603            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14604        self
14605    }
14606
14607    /// Removes all scopes, and no default scope will be used either.
14608    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14609    /// for details).
14610    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupGetCall<'a, C> {
14611        self._scopes.clear();
14612        self
14613    }
14614}
14615
14616/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
14617///
14618/// A builder for the *locations.addressGroups.getIamPolicy* method supported by a *project* resource.
14619/// It is not used directly, but through a [`ProjectMethods`] instance.
14620///
14621/// # Example
14622///
14623/// Instantiate a resource method builder
14624///
14625/// ```test_harness,no_run
14626/// # extern crate hyper;
14627/// # extern crate hyper_rustls;
14628/// # extern crate google_networksecurity1 as networksecurity1;
14629/// # async fn dox() {
14630/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14631///
14632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14633/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14634/// #     secret,
14635/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14636/// # ).build().await.unwrap();
14637///
14638/// # let client = hyper_util::client::legacy::Client::builder(
14639/// #     hyper_util::rt::TokioExecutor::new()
14640/// # )
14641/// # .build(
14642/// #     hyper_rustls::HttpsConnectorBuilder::new()
14643/// #         .with_native_roots()
14644/// #         .unwrap()
14645/// #         .https_or_http()
14646/// #         .enable_http1()
14647/// #         .build()
14648/// # );
14649/// # let mut hub = NetworkSecurity::new(client, auth);
14650/// // You can configure optional parameters by calling the respective setters at will, and
14651/// // execute the final call using `doit()`.
14652/// // Values shown here are possibly random and not representative !
14653/// let result = hub.projects().locations_address_groups_get_iam_policy("resource")
14654///              .options_requested_policy_version(-61)
14655///              .doit().await;
14656/// # }
14657/// ```
14658pub struct ProjectLocationAddressGroupGetIamPolicyCall<'a, C>
14659where
14660    C: 'a,
14661{
14662    hub: &'a NetworkSecurity<C>,
14663    _resource: String,
14664    _options_requested_policy_version: Option<i32>,
14665    _delegate: Option<&'a mut dyn common::Delegate>,
14666    _additional_params: HashMap<String, String>,
14667    _scopes: BTreeSet<String>,
14668}
14669
14670impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupGetIamPolicyCall<'a, C> {}
14671
14672impl<'a, C> ProjectLocationAddressGroupGetIamPolicyCall<'a, C>
14673where
14674    C: common::Connector,
14675{
14676    /// Perform the operation you have build so far.
14677    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
14678        use std::borrow::Cow;
14679        use std::io::{Read, Seek};
14680
14681        use common::{url::Params, ToParts};
14682        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14683
14684        let mut dd = common::DefaultDelegate;
14685        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14686        dlg.begin(common::MethodInfo {
14687            id: "networksecurity.projects.locations.addressGroups.getIamPolicy",
14688            http_method: hyper::Method::GET,
14689        });
14690
14691        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
14692            if self._additional_params.contains_key(field) {
14693                dlg.finished(false);
14694                return Err(common::Error::FieldClash(field));
14695            }
14696        }
14697
14698        let mut params = Params::with_capacity(4 + self._additional_params.len());
14699        params.push("resource", self._resource);
14700        if let Some(value) = self._options_requested_policy_version.as_ref() {
14701            params.push("options.requestedPolicyVersion", value.to_string());
14702        }
14703
14704        params.extend(self._additional_params.iter());
14705
14706        params.push("alt", "json");
14707        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
14708        if self._scopes.is_empty() {
14709            self._scopes
14710                .insert(Scope::CloudPlatform.as_ref().to_string());
14711        }
14712
14713        #[allow(clippy::single_element_loop)]
14714        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14715            url = params.uri_replacement(url, param_name, find_this, true);
14716        }
14717        {
14718            let to_remove = ["resource"];
14719            params.remove_params(&to_remove);
14720        }
14721
14722        let url = params.parse_with_url(&url);
14723
14724        loop {
14725            let token = match self
14726                .hub
14727                .auth
14728                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14729                .await
14730            {
14731                Ok(token) => token,
14732                Err(e) => match dlg.token(e) {
14733                    Ok(token) => token,
14734                    Err(e) => {
14735                        dlg.finished(false);
14736                        return Err(common::Error::MissingToken(e));
14737                    }
14738                },
14739            };
14740            let mut req_result = {
14741                let client = &self.hub.client;
14742                dlg.pre_request();
14743                let mut req_builder = hyper::Request::builder()
14744                    .method(hyper::Method::GET)
14745                    .uri(url.as_str())
14746                    .header(USER_AGENT, self.hub._user_agent.clone());
14747
14748                if let Some(token) = token.as_ref() {
14749                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14750                }
14751
14752                let request = req_builder
14753                    .header(CONTENT_LENGTH, 0_u64)
14754                    .body(common::to_body::<String>(None));
14755
14756                client.request(request.unwrap()).await
14757            };
14758
14759            match req_result {
14760                Err(err) => {
14761                    if let common::Retry::After(d) = dlg.http_error(&err) {
14762                        sleep(d).await;
14763                        continue;
14764                    }
14765                    dlg.finished(false);
14766                    return Err(common::Error::HttpError(err));
14767                }
14768                Ok(res) => {
14769                    let (mut parts, body) = res.into_parts();
14770                    let mut body = common::Body::new(body);
14771                    if !parts.status.is_success() {
14772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14773                        let error = serde_json::from_str(&common::to_string(&bytes));
14774                        let response = common::to_response(parts, bytes.into());
14775
14776                        if let common::Retry::After(d) =
14777                            dlg.http_failure(&response, error.as_ref().ok())
14778                        {
14779                            sleep(d).await;
14780                            continue;
14781                        }
14782
14783                        dlg.finished(false);
14784
14785                        return Err(match error {
14786                            Ok(value) => common::Error::BadRequest(value),
14787                            _ => common::Error::Failure(response),
14788                        });
14789                    }
14790                    let response = {
14791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14792                        let encoded = common::to_string(&bytes);
14793                        match serde_json::from_str(&encoded) {
14794                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14795                            Err(error) => {
14796                                dlg.response_json_decode_error(&encoded, &error);
14797                                return Err(common::Error::JsonDecodeError(
14798                                    encoded.to_string(),
14799                                    error,
14800                                ));
14801                            }
14802                        }
14803                    };
14804
14805                    dlg.finished(true);
14806                    return Ok(response);
14807                }
14808            }
14809        }
14810    }
14811
14812    /// 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.
14813    ///
14814    /// Sets the *resource* path property to the given value.
14815    ///
14816    /// Even though the property as already been set when instantiating this call,
14817    /// we provide this method for API completeness.
14818    pub fn resource(
14819        mut self,
14820        new_value: &str,
14821    ) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C> {
14822        self._resource = new_value.to_string();
14823        self
14824    }
14825    /// 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).
14826    ///
14827    /// Sets the *options.requested policy version* query property to the given value.
14828    pub fn options_requested_policy_version(
14829        mut self,
14830        new_value: i32,
14831    ) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C> {
14832        self._options_requested_policy_version = Some(new_value);
14833        self
14834    }
14835    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14836    /// while executing the actual API request.
14837    ///
14838    /// ````text
14839    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14840    /// ````
14841    ///
14842    /// Sets the *delegate* property to the given value.
14843    pub fn delegate(
14844        mut self,
14845        new_value: &'a mut dyn common::Delegate,
14846    ) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C> {
14847        self._delegate = Some(new_value);
14848        self
14849    }
14850
14851    /// Set any additional parameter of the query string used in the request.
14852    /// It should be used to set parameters which are not yet available through their own
14853    /// setters.
14854    ///
14855    /// Please note that this method must not be used to set any of the known parameters
14856    /// which have their own setter method. If done anyway, the request will fail.
14857    ///
14858    /// # Additional Parameters
14859    ///
14860    /// * *$.xgafv* (query-string) - V1 error format.
14861    /// * *access_token* (query-string) - OAuth access token.
14862    /// * *alt* (query-string) - Data format for response.
14863    /// * *callback* (query-string) - JSONP
14864    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14865    /// * *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.
14866    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14867    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14868    /// * *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.
14869    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14870    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14871    pub fn param<T>(
14872        mut self,
14873        name: T,
14874        value: T,
14875    ) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C>
14876    where
14877        T: AsRef<str>,
14878    {
14879        self._additional_params
14880            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14881        self
14882    }
14883
14884    /// Identifies the authorization scope for the method you are building.
14885    ///
14886    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14887    /// [`Scope::CloudPlatform`].
14888    ///
14889    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14890    /// tokens for more than one scope.
14891    ///
14892    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14893    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14894    /// sufficient, a read-write scope will do as well.
14895    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C>
14896    where
14897        St: AsRef<str>,
14898    {
14899        self._scopes.insert(String::from(scope.as_ref()));
14900        self
14901    }
14902    /// Identifies the authorization scope(s) for the method you are building.
14903    ///
14904    /// See [`Self::add_scope()`] for details.
14905    pub fn add_scopes<I, St>(
14906        mut self,
14907        scopes: I,
14908    ) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C>
14909    where
14910        I: IntoIterator<Item = St>,
14911        St: AsRef<str>,
14912    {
14913        self._scopes
14914            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14915        self
14916    }
14917
14918    /// Removes all scopes, and no default scope will be used either.
14919    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14920    /// for details).
14921    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupGetIamPolicyCall<'a, C> {
14922        self._scopes.clear();
14923        self
14924    }
14925}
14926
14927/// Lists address groups in a given project and location.
14928///
14929/// A builder for the *locations.addressGroups.list* method supported by a *project* resource.
14930/// It is not used directly, but through a [`ProjectMethods`] instance.
14931///
14932/// # Example
14933///
14934/// Instantiate a resource method builder
14935///
14936/// ```test_harness,no_run
14937/// # extern crate hyper;
14938/// # extern crate hyper_rustls;
14939/// # extern crate google_networksecurity1 as networksecurity1;
14940/// # async fn dox() {
14941/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14942///
14943/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14944/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14945/// #     secret,
14946/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14947/// # ).build().await.unwrap();
14948///
14949/// # let client = hyper_util::client::legacy::Client::builder(
14950/// #     hyper_util::rt::TokioExecutor::new()
14951/// # )
14952/// # .build(
14953/// #     hyper_rustls::HttpsConnectorBuilder::new()
14954/// #         .with_native_roots()
14955/// #         .unwrap()
14956/// #         .https_or_http()
14957/// #         .enable_http1()
14958/// #         .build()
14959/// # );
14960/// # let mut hub = NetworkSecurity::new(client, auth);
14961/// // You can configure optional parameters by calling the respective setters at will, and
14962/// // execute the final call using `doit()`.
14963/// // Values shown here are possibly random and not representative !
14964/// let result = hub.projects().locations_address_groups_list("parent")
14965///              .page_token("accusam")
14966///              .page_size(-59)
14967///              .doit().await;
14968/// # }
14969/// ```
14970pub struct ProjectLocationAddressGroupListCall<'a, C>
14971where
14972    C: 'a,
14973{
14974    hub: &'a NetworkSecurity<C>,
14975    _parent: String,
14976    _page_token: Option<String>,
14977    _page_size: Option<i32>,
14978    _delegate: Option<&'a mut dyn common::Delegate>,
14979    _additional_params: HashMap<String, String>,
14980    _scopes: BTreeSet<String>,
14981}
14982
14983impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupListCall<'a, C> {}
14984
14985impl<'a, C> ProjectLocationAddressGroupListCall<'a, C>
14986where
14987    C: common::Connector,
14988{
14989    /// Perform the operation you have build so far.
14990    pub async fn doit(mut self) -> common::Result<(common::Response, ListAddressGroupsResponse)> {
14991        use std::borrow::Cow;
14992        use std::io::{Read, Seek};
14993
14994        use common::{url::Params, ToParts};
14995        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14996
14997        let mut dd = common::DefaultDelegate;
14998        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14999        dlg.begin(common::MethodInfo {
15000            id: "networksecurity.projects.locations.addressGroups.list",
15001            http_method: hyper::Method::GET,
15002        });
15003
15004        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
15005            if self._additional_params.contains_key(field) {
15006                dlg.finished(false);
15007                return Err(common::Error::FieldClash(field));
15008            }
15009        }
15010
15011        let mut params = Params::with_capacity(5 + self._additional_params.len());
15012        params.push("parent", self._parent);
15013        if let Some(value) = self._page_token.as_ref() {
15014            params.push("pageToken", value);
15015        }
15016        if let Some(value) = self._page_size.as_ref() {
15017            params.push("pageSize", value.to_string());
15018        }
15019
15020        params.extend(self._additional_params.iter());
15021
15022        params.push("alt", "json");
15023        let mut url = self.hub._base_url.clone() + "v1/{+parent}/addressGroups";
15024        if self._scopes.is_empty() {
15025            self._scopes
15026                .insert(Scope::CloudPlatform.as_ref().to_string());
15027        }
15028
15029        #[allow(clippy::single_element_loop)]
15030        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15031            url = params.uri_replacement(url, param_name, find_this, true);
15032        }
15033        {
15034            let to_remove = ["parent"];
15035            params.remove_params(&to_remove);
15036        }
15037
15038        let url = params.parse_with_url(&url);
15039
15040        loop {
15041            let token = match self
15042                .hub
15043                .auth
15044                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15045                .await
15046            {
15047                Ok(token) => token,
15048                Err(e) => match dlg.token(e) {
15049                    Ok(token) => token,
15050                    Err(e) => {
15051                        dlg.finished(false);
15052                        return Err(common::Error::MissingToken(e));
15053                    }
15054                },
15055            };
15056            let mut req_result = {
15057                let client = &self.hub.client;
15058                dlg.pre_request();
15059                let mut req_builder = hyper::Request::builder()
15060                    .method(hyper::Method::GET)
15061                    .uri(url.as_str())
15062                    .header(USER_AGENT, self.hub._user_agent.clone());
15063
15064                if let Some(token) = token.as_ref() {
15065                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15066                }
15067
15068                let request = req_builder
15069                    .header(CONTENT_LENGTH, 0_u64)
15070                    .body(common::to_body::<String>(None));
15071
15072                client.request(request.unwrap()).await
15073            };
15074
15075            match req_result {
15076                Err(err) => {
15077                    if let common::Retry::After(d) = dlg.http_error(&err) {
15078                        sleep(d).await;
15079                        continue;
15080                    }
15081                    dlg.finished(false);
15082                    return Err(common::Error::HttpError(err));
15083                }
15084                Ok(res) => {
15085                    let (mut parts, body) = res.into_parts();
15086                    let mut body = common::Body::new(body);
15087                    if !parts.status.is_success() {
15088                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15089                        let error = serde_json::from_str(&common::to_string(&bytes));
15090                        let response = common::to_response(parts, bytes.into());
15091
15092                        if let common::Retry::After(d) =
15093                            dlg.http_failure(&response, error.as_ref().ok())
15094                        {
15095                            sleep(d).await;
15096                            continue;
15097                        }
15098
15099                        dlg.finished(false);
15100
15101                        return Err(match error {
15102                            Ok(value) => common::Error::BadRequest(value),
15103                            _ => common::Error::Failure(response),
15104                        });
15105                    }
15106                    let response = {
15107                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15108                        let encoded = common::to_string(&bytes);
15109                        match serde_json::from_str(&encoded) {
15110                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15111                            Err(error) => {
15112                                dlg.response_json_decode_error(&encoded, &error);
15113                                return Err(common::Error::JsonDecodeError(
15114                                    encoded.to_string(),
15115                                    error,
15116                                ));
15117                            }
15118                        }
15119                    };
15120
15121                    dlg.finished(true);
15122                    return Ok(response);
15123                }
15124            }
15125        }
15126    }
15127
15128    /// Required. The project and location from which the AddressGroups should be listed, specified in the format `projects/*/locations/{location}`.
15129    ///
15130    /// Sets the *parent* path property to the given value.
15131    ///
15132    /// Even though the property as already been set when instantiating this call,
15133    /// we provide this method for API completeness.
15134    pub fn parent(mut self, new_value: &str) -> ProjectLocationAddressGroupListCall<'a, C> {
15135        self._parent = new_value.to_string();
15136        self
15137    }
15138    /// The value returned by the last `ListAddressGroupsResponse` Indicates that this is a continuation of a prior `ListAddressGroups` call, and that the system should return the next page of data.
15139    ///
15140    /// Sets the *page token* query property to the given value.
15141    pub fn page_token(mut self, new_value: &str) -> ProjectLocationAddressGroupListCall<'a, C> {
15142        self._page_token = Some(new_value.to_string());
15143        self
15144    }
15145    /// Maximum number of AddressGroups to return per call.
15146    ///
15147    /// Sets the *page size* query property to the given value.
15148    pub fn page_size(mut self, new_value: i32) -> ProjectLocationAddressGroupListCall<'a, C> {
15149        self._page_size = Some(new_value);
15150        self
15151    }
15152    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15153    /// while executing the actual API request.
15154    ///
15155    /// ````text
15156    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15157    /// ````
15158    ///
15159    /// Sets the *delegate* property to the given value.
15160    pub fn delegate(
15161        mut self,
15162        new_value: &'a mut dyn common::Delegate,
15163    ) -> ProjectLocationAddressGroupListCall<'a, C> {
15164        self._delegate = Some(new_value);
15165        self
15166    }
15167
15168    /// Set any additional parameter of the query string used in the request.
15169    /// It should be used to set parameters which are not yet available through their own
15170    /// setters.
15171    ///
15172    /// Please note that this method must not be used to set any of the known parameters
15173    /// which have their own setter method. If done anyway, the request will fail.
15174    ///
15175    /// # Additional Parameters
15176    ///
15177    /// * *$.xgafv* (query-string) - V1 error format.
15178    /// * *access_token* (query-string) - OAuth access token.
15179    /// * *alt* (query-string) - Data format for response.
15180    /// * *callback* (query-string) - JSONP
15181    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15182    /// * *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.
15183    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15184    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15185    /// * *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.
15186    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15187    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15188    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupListCall<'a, C>
15189    where
15190        T: AsRef<str>,
15191    {
15192        self._additional_params
15193            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15194        self
15195    }
15196
15197    /// Identifies the authorization scope for the method you are building.
15198    ///
15199    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15200    /// [`Scope::CloudPlatform`].
15201    ///
15202    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15203    /// tokens for more than one scope.
15204    ///
15205    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15206    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15207    /// sufficient, a read-write scope will do as well.
15208    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupListCall<'a, C>
15209    where
15210        St: AsRef<str>,
15211    {
15212        self._scopes.insert(String::from(scope.as_ref()));
15213        self
15214    }
15215    /// Identifies the authorization scope(s) for the method you are building.
15216    ///
15217    /// See [`Self::add_scope()`] for details.
15218    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupListCall<'a, C>
15219    where
15220        I: IntoIterator<Item = St>,
15221        St: AsRef<str>,
15222    {
15223        self._scopes
15224            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15225        self
15226    }
15227
15228    /// Removes all scopes, and no default scope will be used either.
15229    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15230    /// for details).
15231    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupListCall<'a, C> {
15232        self._scopes.clear();
15233        self
15234    }
15235}
15236
15237/// Lists references of an address group.
15238///
15239/// A builder for the *locations.addressGroups.listReferences* method supported by a *project* resource.
15240/// It is not used directly, but through a [`ProjectMethods`] instance.
15241///
15242/// # Example
15243///
15244/// Instantiate a resource method builder
15245///
15246/// ```test_harness,no_run
15247/// # extern crate hyper;
15248/// # extern crate hyper_rustls;
15249/// # extern crate google_networksecurity1 as networksecurity1;
15250/// # async fn dox() {
15251/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15252///
15253/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15255/// #     secret,
15256/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15257/// # ).build().await.unwrap();
15258///
15259/// # let client = hyper_util::client::legacy::Client::builder(
15260/// #     hyper_util::rt::TokioExecutor::new()
15261/// # )
15262/// # .build(
15263/// #     hyper_rustls::HttpsConnectorBuilder::new()
15264/// #         .with_native_roots()
15265/// #         .unwrap()
15266/// #         .https_or_http()
15267/// #         .enable_http1()
15268/// #         .build()
15269/// # );
15270/// # let mut hub = NetworkSecurity::new(client, auth);
15271/// // You can configure optional parameters by calling the respective setters at will, and
15272/// // execute the final call using `doit()`.
15273/// // Values shown here are possibly random and not representative !
15274/// let result = hub.projects().locations_address_groups_list_references("addressGroup")
15275///              .page_token("voluptua.")
15276///              .page_size(-72)
15277///              .doit().await;
15278/// # }
15279/// ```
15280pub struct ProjectLocationAddressGroupListReferenceCall<'a, C>
15281where
15282    C: 'a,
15283{
15284    hub: &'a NetworkSecurity<C>,
15285    _address_group: String,
15286    _page_token: Option<String>,
15287    _page_size: Option<i32>,
15288    _delegate: Option<&'a mut dyn common::Delegate>,
15289    _additional_params: HashMap<String, String>,
15290    _scopes: BTreeSet<String>,
15291}
15292
15293impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupListReferenceCall<'a, C> {}
15294
15295impl<'a, C> ProjectLocationAddressGroupListReferenceCall<'a, C>
15296where
15297    C: common::Connector,
15298{
15299    /// Perform the operation you have build so far.
15300    pub async fn doit(
15301        mut self,
15302    ) -> common::Result<(common::Response, ListAddressGroupReferencesResponse)> {
15303        use std::borrow::Cow;
15304        use std::io::{Read, Seek};
15305
15306        use common::{url::Params, ToParts};
15307        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15308
15309        let mut dd = common::DefaultDelegate;
15310        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15311        dlg.begin(common::MethodInfo {
15312            id: "networksecurity.projects.locations.addressGroups.listReferences",
15313            http_method: hyper::Method::GET,
15314        });
15315
15316        for &field in ["alt", "addressGroup", "pageToken", "pageSize"].iter() {
15317            if self._additional_params.contains_key(field) {
15318                dlg.finished(false);
15319                return Err(common::Error::FieldClash(field));
15320            }
15321        }
15322
15323        let mut params = Params::with_capacity(5 + self._additional_params.len());
15324        params.push("addressGroup", self._address_group);
15325        if let Some(value) = self._page_token.as_ref() {
15326            params.push("pageToken", value);
15327        }
15328        if let Some(value) = self._page_size.as_ref() {
15329            params.push("pageSize", value.to_string());
15330        }
15331
15332        params.extend(self._additional_params.iter());
15333
15334        params.push("alt", "json");
15335        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:listReferences";
15336        if self._scopes.is_empty() {
15337            self._scopes
15338                .insert(Scope::CloudPlatform.as_ref().to_string());
15339        }
15340
15341        #[allow(clippy::single_element_loop)]
15342        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
15343            url = params.uri_replacement(url, param_name, find_this, true);
15344        }
15345        {
15346            let to_remove = ["addressGroup"];
15347            params.remove_params(&to_remove);
15348        }
15349
15350        let url = params.parse_with_url(&url);
15351
15352        loop {
15353            let token = match self
15354                .hub
15355                .auth
15356                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15357                .await
15358            {
15359                Ok(token) => token,
15360                Err(e) => match dlg.token(e) {
15361                    Ok(token) => token,
15362                    Err(e) => {
15363                        dlg.finished(false);
15364                        return Err(common::Error::MissingToken(e));
15365                    }
15366                },
15367            };
15368            let mut req_result = {
15369                let client = &self.hub.client;
15370                dlg.pre_request();
15371                let mut req_builder = hyper::Request::builder()
15372                    .method(hyper::Method::GET)
15373                    .uri(url.as_str())
15374                    .header(USER_AGENT, self.hub._user_agent.clone());
15375
15376                if let Some(token) = token.as_ref() {
15377                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15378                }
15379
15380                let request = req_builder
15381                    .header(CONTENT_LENGTH, 0_u64)
15382                    .body(common::to_body::<String>(None));
15383
15384                client.request(request.unwrap()).await
15385            };
15386
15387            match req_result {
15388                Err(err) => {
15389                    if let common::Retry::After(d) = dlg.http_error(&err) {
15390                        sleep(d).await;
15391                        continue;
15392                    }
15393                    dlg.finished(false);
15394                    return Err(common::Error::HttpError(err));
15395                }
15396                Ok(res) => {
15397                    let (mut parts, body) = res.into_parts();
15398                    let mut body = common::Body::new(body);
15399                    if !parts.status.is_success() {
15400                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15401                        let error = serde_json::from_str(&common::to_string(&bytes));
15402                        let response = common::to_response(parts, bytes.into());
15403
15404                        if let common::Retry::After(d) =
15405                            dlg.http_failure(&response, error.as_ref().ok())
15406                        {
15407                            sleep(d).await;
15408                            continue;
15409                        }
15410
15411                        dlg.finished(false);
15412
15413                        return Err(match error {
15414                            Ok(value) => common::Error::BadRequest(value),
15415                            _ => common::Error::Failure(response),
15416                        });
15417                    }
15418                    let response = {
15419                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15420                        let encoded = common::to_string(&bytes);
15421                        match serde_json::from_str(&encoded) {
15422                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15423                            Err(error) => {
15424                                dlg.response_json_decode_error(&encoded, &error);
15425                                return Err(common::Error::JsonDecodeError(
15426                                    encoded.to_string(),
15427                                    error,
15428                                ));
15429                            }
15430                        }
15431                    };
15432
15433                    dlg.finished(true);
15434                    return Ok(response);
15435                }
15436            }
15437        }
15438    }
15439
15440    /// Required. A name of the AddressGroup to clone items to. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
15441    ///
15442    /// Sets the *address group* path property to the given value.
15443    ///
15444    /// Even though the property as already been set when instantiating this call,
15445    /// we provide this method for API completeness.
15446    pub fn address_group(
15447        mut self,
15448        new_value: &str,
15449    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C> {
15450        self._address_group = new_value.to_string();
15451        self
15452    }
15453    /// The next_page_token value returned from a previous List request, if any.
15454    ///
15455    /// Sets the *page token* query property to the given value.
15456    pub fn page_token(
15457        mut self,
15458        new_value: &str,
15459    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C> {
15460        self._page_token = Some(new_value.to_string());
15461        self
15462    }
15463    /// The maximum number of references to return. If unspecified, server will pick an appropriate default. Server may return fewer items than requested. A caller should only rely on response's next_page_token to determine if there are more AddressGroupUsers left to be queried.
15464    ///
15465    /// Sets the *page size* query property to the given value.
15466    pub fn page_size(
15467        mut self,
15468        new_value: i32,
15469    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C> {
15470        self._page_size = Some(new_value);
15471        self
15472    }
15473    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15474    /// while executing the actual API request.
15475    ///
15476    /// ````text
15477    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15478    /// ````
15479    ///
15480    /// Sets the *delegate* property to the given value.
15481    pub fn delegate(
15482        mut self,
15483        new_value: &'a mut dyn common::Delegate,
15484    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C> {
15485        self._delegate = Some(new_value);
15486        self
15487    }
15488
15489    /// Set any additional parameter of the query string used in the request.
15490    /// It should be used to set parameters which are not yet available through their own
15491    /// setters.
15492    ///
15493    /// Please note that this method must not be used to set any of the known parameters
15494    /// which have their own setter method. If done anyway, the request will fail.
15495    ///
15496    /// # Additional Parameters
15497    ///
15498    /// * *$.xgafv* (query-string) - V1 error format.
15499    /// * *access_token* (query-string) - OAuth access token.
15500    /// * *alt* (query-string) - Data format for response.
15501    /// * *callback* (query-string) - JSONP
15502    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15503    /// * *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.
15504    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15505    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15506    /// * *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.
15507    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15508    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15509    pub fn param<T>(
15510        mut self,
15511        name: T,
15512        value: T,
15513    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C>
15514    where
15515        T: AsRef<str>,
15516    {
15517        self._additional_params
15518            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15519        self
15520    }
15521
15522    /// Identifies the authorization scope for the method you are building.
15523    ///
15524    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15525    /// [`Scope::CloudPlatform`].
15526    ///
15527    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15528    /// tokens for more than one scope.
15529    ///
15530    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15531    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15532    /// sufficient, a read-write scope will do as well.
15533    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupListReferenceCall<'a, C>
15534    where
15535        St: AsRef<str>,
15536    {
15537        self._scopes.insert(String::from(scope.as_ref()));
15538        self
15539    }
15540    /// Identifies the authorization scope(s) for the method you are building.
15541    ///
15542    /// See [`Self::add_scope()`] for details.
15543    pub fn add_scopes<I, St>(
15544        mut self,
15545        scopes: I,
15546    ) -> ProjectLocationAddressGroupListReferenceCall<'a, C>
15547    where
15548        I: IntoIterator<Item = St>,
15549        St: AsRef<str>,
15550    {
15551        self._scopes
15552            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15553        self
15554    }
15555
15556    /// Removes all scopes, and no default scope will be used either.
15557    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15558    /// for details).
15559    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupListReferenceCall<'a, C> {
15560        self._scopes.clear();
15561        self
15562    }
15563}
15564
15565/// Updates the parameters of a single address group.
15566///
15567/// A builder for the *locations.addressGroups.patch* method supported by a *project* resource.
15568/// It is not used directly, but through a [`ProjectMethods`] instance.
15569///
15570/// # Example
15571///
15572/// Instantiate a resource method builder
15573///
15574/// ```test_harness,no_run
15575/// # extern crate hyper;
15576/// # extern crate hyper_rustls;
15577/// # extern crate google_networksecurity1 as networksecurity1;
15578/// use networksecurity1::api::AddressGroup;
15579/// # async fn dox() {
15580/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15581///
15582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15584/// #     secret,
15585/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15586/// # ).build().await.unwrap();
15587///
15588/// # let client = hyper_util::client::legacy::Client::builder(
15589/// #     hyper_util::rt::TokioExecutor::new()
15590/// # )
15591/// # .build(
15592/// #     hyper_rustls::HttpsConnectorBuilder::new()
15593/// #         .with_native_roots()
15594/// #         .unwrap()
15595/// #         .https_or_http()
15596/// #         .enable_http1()
15597/// #         .build()
15598/// # );
15599/// # let mut hub = NetworkSecurity::new(client, auth);
15600/// // As the method needs a request, you would usually fill it with the desired information
15601/// // into the respective structure. Some of the parts shown here might not be applicable !
15602/// // Values shown here are possibly random and not representative !
15603/// let mut req = AddressGroup::default();
15604///
15605/// // You can configure optional parameters by calling the respective setters at will, and
15606/// // execute the final call using `doit()`.
15607/// // Values shown here are possibly random and not representative !
15608/// let result = hub.projects().locations_address_groups_patch(req, "name")
15609///              .update_mask(FieldMask::new::<&str>(&[]))
15610///              .request_id("consetetur")
15611///              .doit().await;
15612/// # }
15613/// ```
15614pub struct ProjectLocationAddressGroupPatchCall<'a, C>
15615where
15616    C: 'a,
15617{
15618    hub: &'a NetworkSecurity<C>,
15619    _request: AddressGroup,
15620    _name: String,
15621    _update_mask: Option<common::FieldMask>,
15622    _request_id: Option<String>,
15623    _delegate: Option<&'a mut dyn common::Delegate>,
15624    _additional_params: HashMap<String, String>,
15625    _scopes: BTreeSet<String>,
15626}
15627
15628impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupPatchCall<'a, C> {}
15629
15630impl<'a, C> ProjectLocationAddressGroupPatchCall<'a, C>
15631where
15632    C: common::Connector,
15633{
15634    /// Perform the operation you have build so far.
15635    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15636        use std::borrow::Cow;
15637        use std::io::{Read, Seek};
15638
15639        use common::{url::Params, ToParts};
15640        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15641
15642        let mut dd = common::DefaultDelegate;
15643        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15644        dlg.begin(common::MethodInfo {
15645            id: "networksecurity.projects.locations.addressGroups.patch",
15646            http_method: hyper::Method::PATCH,
15647        });
15648
15649        for &field in ["alt", "name", "updateMask", "requestId"].iter() {
15650            if self._additional_params.contains_key(field) {
15651                dlg.finished(false);
15652                return Err(common::Error::FieldClash(field));
15653            }
15654        }
15655
15656        let mut params = Params::with_capacity(6 + self._additional_params.len());
15657        params.push("name", self._name);
15658        if let Some(value) = self._update_mask.as_ref() {
15659            params.push("updateMask", value.to_string());
15660        }
15661        if let Some(value) = self._request_id.as_ref() {
15662            params.push("requestId", value);
15663        }
15664
15665        params.extend(self._additional_params.iter());
15666
15667        params.push("alt", "json");
15668        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15669        if self._scopes.is_empty() {
15670            self._scopes
15671                .insert(Scope::CloudPlatform.as_ref().to_string());
15672        }
15673
15674        #[allow(clippy::single_element_loop)]
15675        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15676            url = params.uri_replacement(url, param_name, find_this, true);
15677        }
15678        {
15679            let to_remove = ["name"];
15680            params.remove_params(&to_remove);
15681        }
15682
15683        let url = params.parse_with_url(&url);
15684
15685        let mut json_mime_type = mime::APPLICATION_JSON;
15686        let mut request_value_reader = {
15687            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15688            common::remove_json_null_values(&mut value);
15689            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15690            serde_json::to_writer(&mut dst, &value).unwrap();
15691            dst
15692        };
15693        let request_size = request_value_reader
15694            .seek(std::io::SeekFrom::End(0))
15695            .unwrap();
15696        request_value_reader
15697            .seek(std::io::SeekFrom::Start(0))
15698            .unwrap();
15699
15700        loop {
15701            let token = match self
15702                .hub
15703                .auth
15704                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15705                .await
15706            {
15707                Ok(token) => token,
15708                Err(e) => match dlg.token(e) {
15709                    Ok(token) => token,
15710                    Err(e) => {
15711                        dlg.finished(false);
15712                        return Err(common::Error::MissingToken(e));
15713                    }
15714                },
15715            };
15716            request_value_reader
15717                .seek(std::io::SeekFrom::Start(0))
15718                .unwrap();
15719            let mut req_result = {
15720                let client = &self.hub.client;
15721                dlg.pre_request();
15722                let mut req_builder = hyper::Request::builder()
15723                    .method(hyper::Method::PATCH)
15724                    .uri(url.as_str())
15725                    .header(USER_AGENT, self.hub._user_agent.clone());
15726
15727                if let Some(token) = token.as_ref() {
15728                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15729                }
15730
15731                let request = req_builder
15732                    .header(CONTENT_TYPE, json_mime_type.to_string())
15733                    .header(CONTENT_LENGTH, request_size as u64)
15734                    .body(common::to_body(
15735                        request_value_reader.get_ref().clone().into(),
15736                    ));
15737
15738                client.request(request.unwrap()).await
15739            };
15740
15741            match req_result {
15742                Err(err) => {
15743                    if let common::Retry::After(d) = dlg.http_error(&err) {
15744                        sleep(d).await;
15745                        continue;
15746                    }
15747                    dlg.finished(false);
15748                    return Err(common::Error::HttpError(err));
15749                }
15750                Ok(res) => {
15751                    let (mut parts, body) = res.into_parts();
15752                    let mut body = common::Body::new(body);
15753                    if !parts.status.is_success() {
15754                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15755                        let error = serde_json::from_str(&common::to_string(&bytes));
15756                        let response = common::to_response(parts, bytes.into());
15757
15758                        if let common::Retry::After(d) =
15759                            dlg.http_failure(&response, error.as_ref().ok())
15760                        {
15761                            sleep(d).await;
15762                            continue;
15763                        }
15764
15765                        dlg.finished(false);
15766
15767                        return Err(match error {
15768                            Ok(value) => common::Error::BadRequest(value),
15769                            _ => common::Error::Failure(response),
15770                        });
15771                    }
15772                    let response = {
15773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15774                        let encoded = common::to_string(&bytes);
15775                        match serde_json::from_str(&encoded) {
15776                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15777                            Err(error) => {
15778                                dlg.response_json_decode_error(&encoded, &error);
15779                                return Err(common::Error::JsonDecodeError(
15780                                    encoded.to_string(),
15781                                    error,
15782                                ));
15783                            }
15784                        }
15785                    };
15786
15787                    dlg.finished(true);
15788                    return Ok(response);
15789                }
15790            }
15791        }
15792    }
15793
15794    ///
15795    /// Sets the *request* property to the given value.
15796    ///
15797    /// Even though the property as already been set when instantiating this call,
15798    /// we provide this method for API completeness.
15799    pub fn request(
15800        mut self,
15801        new_value: AddressGroup,
15802    ) -> ProjectLocationAddressGroupPatchCall<'a, C> {
15803        self._request = new_value;
15804        self
15805    }
15806    /// Required. Name of the AddressGroup resource. It matches pattern `projects/*/locations/{location}/addressGroups/`.
15807    ///
15808    /// Sets the *name* path property to the given value.
15809    ///
15810    /// Even though the property as already been set when instantiating this call,
15811    /// we provide this method for API completeness.
15812    pub fn name(mut self, new_value: &str) -> ProjectLocationAddressGroupPatchCall<'a, C> {
15813        self._name = new_value.to_string();
15814        self
15815    }
15816    /// Optional. Field mask is used to specify the fields to be overwritten in the AddressGroup 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.
15817    ///
15818    /// Sets the *update mask* query property to the given value.
15819    pub fn update_mask(
15820        mut self,
15821        new_value: common::FieldMask,
15822    ) -> ProjectLocationAddressGroupPatchCall<'a, C> {
15823        self._update_mask = Some(new_value);
15824        self
15825    }
15826    /// Optional. 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).
15827    ///
15828    /// Sets the *request id* query property to the given value.
15829    pub fn request_id(mut self, new_value: &str) -> ProjectLocationAddressGroupPatchCall<'a, C> {
15830        self._request_id = Some(new_value.to_string());
15831        self
15832    }
15833    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15834    /// while executing the actual API request.
15835    ///
15836    /// ````text
15837    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15838    /// ````
15839    ///
15840    /// Sets the *delegate* property to the given value.
15841    pub fn delegate(
15842        mut self,
15843        new_value: &'a mut dyn common::Delegate,
15844    ) -> ProjectLocationAddressGroupPatchCall<'a, C> {
15845        self._delegate = Some(new_value);
15846        self
15847    }
15848
15849    /// Set any additional parameter of the query string used in the request.
15850    /// It should be used to set parameters which are not yet available through their own
15851    /// setters.
15852    ///
15853    /// Please note that this method must not be used to set any of the known parameters
15854    /// which have their own setter method. If done anyway, the request will fail.
15855    ///
15856    /// # Additional Parameters
15857    ///
15858    /// * *$.xgafv* (query-string) - V1 error format.
15859    /// * *access_token* (query-string) - OAuth access token.
15860    /// * *alt* (query-string) - Data format for response.
15861    /// * *callback* (query-string) - JSONP
15862    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15863    /// * *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.
15864    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15865    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15866    /// * *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.
15867    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15868    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15869    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupPatchCall<'a, C>
15870    where
15871        T: AsRef<str>,
15872    {
15873        self._additional_params
15874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15875        self
15876    }
15877
15878    /// Identifies the authorization scope for the method you are building.
15879    ///
15880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15881    /// [`Scope::CloudPlatform`].
15882    ///
15883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15884    /// tokens for more than one scope.
15885    ///
15886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15888    /// sufficient, a read-write scope will do as well.
15889    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupPatchCall<'a, C>
15890    where
15891        St: AsRef<str>,
15892    {
15893        self._scopes.insert(String::from(scope.as_ref()));
15894        self
15895    }
15896    /// Identifies the authorization scope(s) for the method you are building.
15897    ///
15898    /// See [`Self::add_scope()`] for details.
15899    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAddressGroupPatchCall<'a, C>
15900    where
15901        I: IntoIterator<Item = St>,
15902        St: AsRef<str>,
15903    {
15904        self._scopes
15905            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15906        self
15907    }
15908
15909    /// Removes all scopes, and no default scope will be used either.
15910    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15911    /// for details).
15912    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupPatchCall<'a, C> {
15913        self._scopes.clear();
15914        self
15915    }
15916}
15917
15918/// Removes items from an address group.
15919///
15920/// A builder for the *locations.addressGroups.removeItems* method supported by a *project* resource.
15921/// It is not used directly, but through a [`ProjectMethods`] instance.
15922///
15923/// # Example
15924///
15925/// Instantiate a resource method builder
15926///
15927/// ```test_harness,no_run
15928/// # extern crate hyper;
15929/// # extern crate hyper_rustls;
15930/// # extern crate google_networksecurity1 as networksecurity1;
15931/// use networksecurity1::api::RemoveAddressGroupItemsRequest;
15932/// # async fn dox() {
15933/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15934///
15935/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15936/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15937/// #     secret,
15938/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15939/// # ).build().await.unwrap();
15940///
15941/// # let client = hyper_util::client::legacy::Client::builder(
15942/// #     hyper_util::rt::TokioExecutor::new()
15943/// # )
15944/// # .build(
15945/// #     hyper_rustls::HttpsConnectorBuilder::new()
15946/// #         .with_native_roots()
15947/// #         .unwrap()
15948/// #         .https_or_http()
15949/// #         .enable_http1()
15950/// #         .build()
15951/// # );
15952/// # let mut hub = NetworkSecurity::new(client, auth);
15953/// // As the method needs a request, you would usually fill it with the desired information
15954/// // into the respective structure. Some of the parts shown here might not be applicable !
15955/// // Values shown here are possibly random and not representative !
15956/// let mut req = RemoveAddressGroupItemsRequest::default();
15957///
15958/// // You can configure optional parameters by calling the respective setters at will, and
15959/// // execute the final call using `doit()`.
15960/// // Values shown here are possibly random and not representative !
15961/// let result = hub.projects().locations_address_groups_remove_items(req, "addressGroup")
15962///              .doit().await;
15963/// # }
15964/// ```
15965pub struct ProjectLocationAddressGroupRemoveItemCall<'a, C>
15966where
15967    C: 'a,
15968{
15969    hub: &'a NetworkSecurity<C>,
15970    _request: RemoveAddressGroupItemsRequest,
15971    _address_group: String,
15972    _delegate: Option<&'a mut dyn common::Delegate>,
15973    _additional_params: HashMap<String, String>,
15974    _scopes: BTreeSet<String>,
15975}
15976
15977impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupRemoveItemCall<'a, C> {}
15978
15979impl<'a, C> ProjectLocationAddressGroupRemoveItemCall<'a, C>
15980where
15981    C: common::Connector,
15982{
15983    /// Perform the operation you have build so far.
15984    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15985        use std::borrow::Cow;
15986        use std::io::{Read, Seek};
15987
15988        use common::{url::Params, ToParts};
15989        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15990
15991        let mut dd = common::DefaultDelegate;
15992        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15993        dlg.begin(common::MethodInfo {
15994            id: "networksecurity.projects.locations.addressGroups.removeItems",
15995            http_method: hyper::Method::POST,
15996        });
15997
15998        for &field in ["alt", "addressGroup"].iter() {
15999            if self._additional_params.contains_key(field) {
16000                dlg.finished(false);
16001                return Err(common::Error::FieldClash(field));
16002            }
16003        }
16004
16005        let mut params = Params::with_capacity(4 + self._additional_params.len());
16006        params.push("addressGroup", self._address_group);
16007
16008        params.extend(self._additional_params.iter());
16009
16010        params.push("alt", "json");
16011        let mut url = self.hub._base_url.clone() + "v1/{+addressGroup}:removeItems";
16012        if self._scopes.is_empty() {
16013            self._scopes
16014                .insert(Scope::CloudPlatform.as_ref().to_string());
16015        }
16016
16017        #[allow(clippy::single_element_loop)]
16018        for &(find_this, param_name) in [("{+addressGroup}", "addressGroup")].iter() {
16019            url = params.uri_replacement(url, param_name, find_this, true);
16020        }
16021        {
16022            let to_remove = ["addressGroup"];
16023            params.remove_params(&to_remove);
16024        }
16025
16026        let url = params.parse_with_url(&url);
16027
16028        let mut json_mime_type = mime::APPLICATION_JSON;
16029        let mut request_value_reader = {
16030            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16031            common::remove_json_null_values(&mut value);
16032            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16033            serde_json::to_writer(&mut dst, &value).unwrap();
16034            dst
16035        };
16036        let request_size = request_value_reader
16037            .seek(std::io::SeekFrom::End(0))
16038            .unwrap();
16039        request_value_reader
16040            .seek(std::io::SeekFrom::Start(0))
16041            .unwrap();
16042
16043        loop {
16044            let token = match self
16045                .hub
16046                .auth
16047                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16048                .await
16049            {
16050                Ok(token) => token,
16051                Err(e) => match dlg.token(e) {
16052                    Ok(token) => token,
16053                    Err(e) => {
16054                        dlg.finished(false);
16055                        return Err(common::Error::MissingToken(e));
16056                    }
16057                },
16058            };
16059            request_value_reader
16060                .seek(std::io::SeekFrom::Start(0))
16061                .unwrap();
16062            let mut req_result = {
16063                let client = &self.hub.client;
16064                dlg.pre_request();
16065                let mut req_builder = hyper::Request::builder()
16066                    .method(hyper::Method::POST)
16067                    .uri(url.as_str())
16068                    .header(USER_AGENT, self.hub._user_agent.clone());
16069
16070                if let Some(token) = token.as_ref() {
16071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16072                }
16073
16074                let request = req_builder
16075                    .header(CONTENT_TYPE, json_mime_type.to_string())
16076                    .header(CONTENT_LENGTH, request_size as u64)
16077                    .body(common::to_body(
16078                        request_value_reader.get_ref().clone().into(),
16079                    ));
16080
16081                client.request(request.unwrap()).await
16082            };
16083
16084            match req_result {
16085                Err(err) => {
16086                    if let common::Retry::After(d) = dlg.http_error(&err) {
16087                        sleep(d).await;
16088                        continue;
16089                    }
16090                    dlg.finished(false);
16091                    return Err(common::Error::HttpError(err));
16092                }
16093                Ok(res) => {
16094                    let (mut parts, body) = res.into_parts();
16095                    let mut body = common::Body::new(body);
16096                    if !parts.status.is_success() {
16097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16098                        let error = serde_json::from_str(&common::to_string(&bytes));
16099                        let response = common::to_response(parts, bytes.into());
16100
16101                        if let common::Retry::After(d) =
16102                            dlg.http_failure(&response, error.as_ref().ok())
16103                        {
16104                            sleep(d).await;
16105                            continue;
16106                        }
16107
16108                        dlg.finished(false);
16109
16110                        return Err(match error {
16111                            Ok(value) => common::Error::BadRequest(value),
16112                            _ => common::Error::Failure(response),
16113                        });
16114                    }
16115                    let response = {
16116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16117                        let encoded = common::to_string(&bytes);
16118                        match serde_json::from_str(&encoded) {
16119                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16120                            Err(error) => {
16121                                dlg.response_json_decode_error(&encoded, &error);
16122                                return Err(common::Error::JsonDecodeError(
16123                                    encoded.to_string(),
16124                                    error,
16125                                ));
16126                            }
16127                        }
16128                    };
16129
16130                    dlg.finished(true);
16131                    return Ok(response);
16132                }
16133            }
16134        }
16135    }
16136
16137    ///
16138    /// Sets the *request* property to the given value.
16139    ///
16140    /// Even though the property as already been set when instantiating this call,
16141    /// we provide this method for API completeness.
16142    pub fn request(
16143        mut self,
16144        new_value: RemoveAddressGroupItemsRequest,
16145    ) -> ProjectLocationAddressGroupRemoveItemCall<'a, C> {
16146        self._request = new_value;
16147        self
16148    }
16149    /// Required. A name of the AddressGroup to remove items from. Must be in the format `projects|organization/*/locations/{location}/addressGroups/*`.
16150    ///
16151    /// Sets the *address group* path property to the given value.
16152    ///
16153    /// Even though the property as already been set when instantiating this call,
16154    /// we provide this method for API completeness.
16155    pub fn address_group(
16156        mut self,
16157        new_value: &str,
16158    ) -> ProjectLocationAddressGroupRemoveItemCall<'a, C> {
16159        self._address_group = new_value.to_string();
16160        self
16161    }
16162    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16163    /// while executing the actual API request.
16164    ///
16165    /// ````text
16166    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16167    /// ````
16168    ///
16169    /// Sets the *delegate* property to the given value.
16170    pub fn delegate(
16171        mut self,
16172        new_value: &'a mut dyn common::Delegate,
16173    ) -> ProjectLocationAddressGroupRemoveItemCall<'a, C> {
16174        self._delegate = Some(new_value);
16175        self
16176    }
16177
16178    /// Set any additional parameter of the query string used in the request.
16179    /// It should be used to set parameters which are not yet available through their own
16180    /// setters.
16181    ///
16182    /// Please note that this method must not be used to set any of the known parameters
16183    /// which have their own setter method. If done anyway, the request will fail.
16184    ///
16185    /// # Additional Parameters
16186    ///
16187    /// * *$.xgafv* (query-string) - V1 error format.
16188    /// * *access_token* (query-string) - OAuth access token.
16189    /// * *alt* (query-string) - Data format for response.
16190    /// * *callback* (query-string) - JSONP
16191    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16192    /// * *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.
16193    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16194    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16195    /// * *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.
16196    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16197    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16198    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAddressGroupRemoveItemCall<'a, C>
16199    where
16200        T: AsRef<str>,
16201    {
16202        self._additional_params
16203            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16204        self
16205    }
16206
16207    /// Identifies the authorization scope for the method you are building.
16208    ///
16209    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16210    /// [`Scope::CloudPlatform`].
16211    ///
16212    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16213    /// tokens for more than one scope.
16214    ///
16215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16217    /// sufficient, a read-write scope will do as well.
16218    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupRemoveItemCall<'a, C>
16219    where
16220        St: AsRef<str>,
16221    {
16222        self._scopes.insert(String::from(scope.as_ref()));
16223        self
16224    }
16225    /// Identifies the authorization scope(s) for the method you are building.
16226    ///
16227    /// See [`Self::add_scope()`] for details.
16228    pub fn add_scopes<I, St>(
16229        mut self,
16230        scopes: I,
16231    ) -> ProjectLocationAddressGroupRemoveItemCall<'a, C>
16232    where
16233        I: IntoIterator<Item = St>,
16234        St: AsRef<str>,
16235    {
16236        self._scopes
16237            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16238        self
16239    }
16240
16241    /// Removes all scopes, and no default scope will be used either.
16242    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16243    /// for details).
16244    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupRemoveItemCall<'a, C> {
16245        self._scopes.clear();
16246        self
16247    }
16248}
16249
16250/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
16251///
16252/// A builder for the *locations.addressGroups.setIamPolicy* method supported by a *project* resource.
16253/// It is not used directly, but through a [`ProjectMethods`] instance.
16254///
16255/// # Example
16256///
16257/// Instantiate a resource method builder
16258///
16259/// ```test_harness,no_run
16260/// # extern crate hyper;
16261/// # extern crate hyper_rustls;
16262/// # extern crate google_networksecurity1 as networksecurity1;
16263/// use networksecurity1::api::GoogleIamV1SetIamPolicyRequest;
16264/// # async fn dox() {
16265/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16266///
16267/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16268/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16269/// #     secret,
16270/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16271/// # ).build().await.unwrap();
16272///
16273/// # let client = hyper_util::client::legacy::Client::builder(
16274/// #     hyper_util::rt::TokioExecutor::new()
16275/// # )
16276/// # .build(
16277/// #     hyper_rustls::HttpsConnectorBuilder::new()
16278/// #         .with_native_roots()
16279/// #         .unwrap()
16280/// #         .https_or_http()
16281/// #         .enable_http1()
16282/// #         .build()
16283/// # );
16284/// # let mut hub = NetworkSecurity::new(client, auth);
16285/// // As the method needs a request, you would usually fill it with the desired information
16286/// // into the respective structure. Some of the parts shown here might not be applicable !
16287/// // Values shown here are possibly random and not representative !
16288/// let mut req = GoogleIamV1SetIamPolicyRequest::default();
16289///
16290/// // You can configure optional parameters by calling the respective setters at will, and
16291/// // execute the final call using `doit()`.
16292/// // Values shown here are possibly random and not representative !
16293/// let result = hub.projects().locations_address_groups_set_iam_policy(req, "resource")
16294///              .doit().await;
16295/// # }
16296/// ```
16297pub struct ProjectLocationAddressGroupSetIamPolicyCall<'a, C>
16298where
16299    C: 'a,
16300{
16301    hub: &'a NetworkSecurity<C>,
16302    _request: GoogleIamV1SetIamPolicyRequest,
16303    _resource: String,
16304    _delegate: Option<&'a mut dyn common::Delegate>,
16305    _additional_params: HashMap<String, String>,
16306    _scopes: BTreeSet<String>,
16307}
16308
16309impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupSetIamPolicyCall<'a, C> {}
16310
16311impl<'a, C> ProjectLocationAddressGroupSetIamPolicyCall<'a, C>
16312where
16313    C: common::Connector,
16314{
16315    /// Perform the operation you have build so far.
16316    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
16317        use std::borrow::Cow;
16318        use std::io::{Read, Seek};
16319
16320        use common::{url::Params, ToParts};
16321        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16322
16323        let mut dd = common::DefaultDelegate;
16324        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16325        dlg.begin(common::MethodInfo {
16326            id: "networksecurity.projects.locations.addressGroups.setIamPolicy",
16327            http_method: hyper::Method::POST,
16328        });
16329
16330        for &field in ["alt", "resource"].iter() {
16331            if self._additional_params.contains_key(field) {
16332                dlg.finished(false);
16333                return Err(common::Error::FieldClash(field));
16334            }
16335        }
16336
16337        let mut params = Params::with_capacity(4 + self._additional_params.len());
16338        params.push("resource", self._resource);
16339
16340        params.extend(self._additional_params.iter());
16341
16342        params.push("alt", "json");
16343        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
16344        if self._scopes.is_empty() {
16345            self._scopes
16346                .insert(Scope::CloudPlatform.as_ref().to_string());
16347        }
16348
16349        #[allow(clippy::single_element_loop)]
16350        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
16351            url = params.uri_replacement(url, param_name, find_this, true);
16352        }
16353        {
16354            let to_remove = ["resource"];
16355            params.remove_params(&to_remove);
16356        }
16357
16358        let url = params.parse_with_url(&url);
16359
16360        let mut json_mime_type = mime::APPLICATION_JSON;
16361        let mut request_value_reader = {
16362            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16363            common::remove_json_null_values(&mut value);
16364            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16365            serde_json::to_writer(&mut dst, &value).unwrap();
16366            dst
16367        };
16368        let request_size = request_value_reader
16369            .seek(std::io::SeekFrom::End(0))
16370            .unwrap();
16371        request_value_reader
16372            .seek(std::io::SeekFrom::Start(0))
16373            .unwrap();
16374
16375        loop {
16376            let token = match self
16377                .hub
16378                .auth
16379                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16380                .await
16381            {
16382                Ok(token) => token,
16383                Err(e) => match dlg.token(e) {
16384                    Ok(token) => token,
16385                    Err(e) => {
16386                        dlg.finished(false);
16387                        return Err(common::Error::MissingToken(e));
16388                    }
16389                },
16390            };
16391            request_value_reader
16392                .seek(std::io::SeekFrom::Start(0))
16393                .unwrap();
16394            let mut req_result = {
16395                let client = &self.hub.client;
16396                dlg.pre_request();
16397                let mut req_builder = hyper::Request::builder()
16398                    .method(hyper::Method::POST)
16399                    .uri(url.as_str())
16400                    .header(USER_AGENT, self.hub._user_agent.clone());
16401
16402                if let Some(token) = token.as_ref() {
16403                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16404                }
16405
16406                let request = req_builder
16407                    .header(CONTENT_TYPE, json_mime_type.to_string())
16408                    .header(CONTENT_LENGTH, request_size as u64)
16409                    .body(common::to_body(
16410                        request_value_reader.get_ref().clone().into(),
16411                    ));
16412
16413                client.request(request.unwrap()).await
16414            };
16415
16416            match req_result {
16417                Err(err) => {
16418                    if let common::Retry::After(d) = dlg.http_error(&err) {
16419                        sleep(d).await;
16420                        continue;
16421                    }
16422                    dlg.finished(false);
16423                    return Err(common::Error::HttpError(err));
16424                }
16425                Ok(res) => {
16426                    let (mut parts, body) = res.into_parts();
16427                    let mut body = common::Body::new(body);
16428                    if !parts.status.is_success() {
16429                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16430                        let error = serde_json::from_str(&common::to_string(&bytes));
16431                        let response = common::to_response(parts, bytes.into());
16432
16433                        if let common::Retry::After(d) =
16434                            dlg.http_failure(&response, error.as_ref().ok())
16435                        {
16436                            sleep(d).await;
16437                            continue;
16438                        }
16439
16440                        dlg.finished(false);
16441
16442                        return Err(match error {
16443                            Ok(value) => common::Error::BadRequest(value),
16444                            _ => common::Error::Failure(response),
16445                        });
16446                    }
16447                    let response = {
16448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16449                        let encoded = common::to_string(&bytes);
16450                        match serde_json::from_str(&encoded) {
16451                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16452                            Err(error) => {
16453                                dlg.response_json_decode_error(&encoded, &error);
16454                                return Err(common::Error::JsonDecodeError(
16455                                    encoded.to_string(),
16456                                    error,
16457                                ));
16458                            }
16459                        }
16460                    };
16461
16462                    dlg.finished(true);
16463                    return Ok(response);
16464                }
16465            }
16466        }
16467    }
16468
16469    ///
16470    /// Sets the *request* property to the given value.
16471    ///
16472    /// Even though the property as already been set when instantiating this call,
16473    /// we provide this method for API completeness.
16474    pub fn request(
16475        mut self,
16476        new_value: GoogleIamV1SetIamPolicyRequest,
16477    ) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C> {
16478        self._request = new_value;
16479        self
16480    }
16481    /// 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.
16482    ///
16483    /// Sets the *resource* path property to the given value.
16484    ///
16485    /// Even though the property as already been set when instantiating this call,
16486    /// we provide this method for API completeness.
16487    pub fn resource(
16488        mut self,
16489        new_value: &str,
16490    ) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C> {
16491        self._resource = new_value.to_string();
16492        self
16493    }
16494    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16495    /// while executing the actual API request.
16496    ///
16497    /// ````text
16498    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16499    /// ````
16500    ///
16501    /// Sets the *delegate* property to the given value.
16502    pub fn delegate(
16503        mut self,
16504        new_value: &'a mut dyn common::Delegate,
16505    ) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C> {
16506        self._delegate = Some(new_value);
16507        self
16508    }
16509
16510    /// Set any additional parameter of the query string used in the request.
16511    /// It should be used to set parameters which are not yet available through their own
16512    /// setters.
16513    ///
16514    /// Please note that this method must not be used to set any of the known parameters
16515    /// which have their own setter method. If done anyway, the request will fail.
16516    ///
16517    /// # Additional Parameters
16518    ///
16519    /// * *$.xgafv* (query-string) - V1 error format.
16520    /// * *access_token* (query-string) - OAuth access token.
16521    /// * *alt* (query-string) - Data format for response.
16522    /// * *callback* (query-string) - JSONP
16523    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16524    /// * *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.
16525    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16526    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16527    /// * *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.
16528    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16529    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16530    pub fn param<T>(
16531        mut self,
16532        name: T,
16533        value: T,
16534    ) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C>
16535    where
16536        T: AsRef<str>,
16537    {
16538        self._additional_params
16539            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16540        self
16541    }
16542
16543    /// Identifies the authorization scope for the method you are building.
16544    ///
16545    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16546    /// [`Scope::CloudPlatform`].
16547    ///
16548    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16549    /// tokens for more than one scope.
16550    ///
16551    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16552    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16553    /// sufficient, a read-write scope will do as well.
16554    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C>
16555    where
16556        St: AsRef<str>,
16557    {
16558        self._scopes.insert(String::from(scope.as_ref()));
16559        self
16560    }
16561    /// Identifies the authorization scope(s) for the method you are building.
16562    ///
16563    /// See [`Self::add_scope()`] for details.
16564    pub fn add_scopes<I, St>(
16565        mut self,
16566        scopes: I,
16567    ) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C>
16568    where
16569        I: IntoIterator<Item = St>,
16570        St: AsRef<str>,
16571    {
16572        self._scopes
16573            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16574        self
16575    }
16576
16577    /// Removes all scopes, and no default scope will be used either.
16578    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16579    /// for details).
16580    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupSetIamPolicyCall<'a, C> {
16581        self._scopes.clear();
16582        self
16583    }
16584}
16585
16586/// 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.
16587///
16588/// A builder for the *locations.addressGroups.testIamPermissions* method supported by a *project* resource.
16589/// It is not used directly, but through a [`ProjectMethods`] instance.
16590///
16591/// # Example
16592///
16593/// Instantiate a resource method builder
16594///
16595/// ```test_harness,no_run
16596/// # extern crate hyper;
16597/// # extern crate hyper_rustls;
16598/// # extern crate google_networksecurity1 as networksecurity1;
16599/// use networksecurity1::api::GoogleIamV1TestIamPermissionsRequest;
16600/// # async fn dox() {
16601/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16602///
16603/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16605/// #     secret,
16606/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16607/// # ).build().await.unwrap();
16608///
16609/// # let client = hyper_util::client::legacy::Client::builder(
16610/// #     hyper_util::rt::TokioExecutor::new()
16611/// # )
16612/// # .build(
16613/// #     hyper_rustls::HttpsConnectorBuilder::new()
16614/// #         .with_native_roots()
16615/// #         .unwrap()
16616/// #         .https_or_http()
16617/// #         .enable_http1()
16618/// #         .build()
16619/// # );
16620/// # let mut hub = NetworkSecurity::new(client, auth);
16621/// // As the method needs a request, you would usually fill it with the desired information
16622/// // into the respective structure. Some of the parts shown here might not be applicable !
16623/// // Values shown here are possibly random and not representative !
16624/// let mut req = GoogleIamV1TestIamPermissionsRequest::default();
16625///
16626/// // You can configure optional parameters by calling the respective setters at will, and
16627/// // execute the final call using `doit()`.
16628/// // Values shown here are possibly random and not representative !
16629/// let result = hub.projects().locations_address_groups_test_iam_permissions(req, "resource")
16630///              .doit().await;
16631/// # }
16632/// ```
16633pub struct ProjectLocationAddressGroupTestIamPermissionCall<'a, C>
16634where
16635    C: 'a,
16636{
16637    hub: &'a NetworkSecurity<C>,
16638    _request: GoogleIamV1TestIamPermissionsRequest,
16639    _resource: String,
16640    _delegate: Option<&'a mut dyn common::Delegate>,
16641    _additional_params: HashMap<String, String>,
16642    _scopes: BTreeSet<String>,
16643}
16644
16645impl<'a, C> common::CallBuilder for ProjectLocationAddressGroupTestIamPermissionCall<'a, C> {}
16646
16647impl<'a, C> ProjectLocationAddressGroupTestIamPermissionCall<'a, C>
16648where
16649    C: common::Connector,
16650{
16651    /// Perform the operation you have build so far.
16652    pub async fn doit(
16653        mut self,
16654    ) -> common::Result<(common::Response, GoogleIamV1TestIamPermissionsResponse)> {
16655        use std::borrow::Cow;
16656        use std::io::{Read, Seek};
16657
16658        use common::{url::Params, ToParts};
16659        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16660
16661        let mut dd = common::DefaultDelegate;
16662        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16663        dlg.begin(common::MethodInfo {
16664            id: "networksecurity.projects.locations.addressGroups.testIamPermissions",
16665            http_method: hyper::Method::POST,
16666        });
16667
16668        for &field in ["alt", "resource"].iter() {
16669            if self._additional_params.contains_key(field) {
16670                dlg.finished(false);
16671                return Err(common::Error::FieldClash(field));
16672            }
16673        }
16674
16675        let mut params = Params::with_capacity(4 + self._additional_params.len());
16676        params.push("resource", self._resource);
16677
16678        params.extend(self._additional_params.iter());
16679
16680        params.push("alt", "json");
16681        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
16682        if self._scopes.is_empty() {
16683            self._scopes
16684                .insert(Scope::CloudPlatform.as_ref().to_string());
16685        }
16686
16687        #[allow(clippy::single_element_loop)]
16688        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
16689            url = params.uri_replacement(url, param_name, find_this, true);
16690        }
16691        {
16692            let to_remove = ["resource"];
16693            params.remove_params(&to_remove);
16694        }
16695
16696        let url = params.parse_with_url(&url);
16697
16698        let mut json_mime_type = mime::APPLICATION_JSON;
16699        let mut request_value_reader = {
16700            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16701            common::remove_json_null_values(&mut value);
16702            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16703            serde_json::to_writer(&mut dst, &value).unwrap();
16704            dst
16705        };
16706        let request_size = request_value_reader
16707            .seek(std::io::SeekFrom::End(0))
16708            .unwrap();
16709        request_value_reader
16710            .seek(std::io::SeekFrom::Start(0))
16711            .unwrap();
16712
16713        loop {
16714            let token = match self
16715                .hub
16716                .auth
16717                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16718                .await
16719            {
16720                Ok(token) => token,
16721                Err(e) => match dlg.token(e) {
16722                    Ok(token) => token,
16723                    Err(e) => {
16724                        dlg.finished(false);
16725                        return Err(common::Error::MissingToken(e));
16726                    }
16727                },
16728            };
16729            request_value_reader
16730                .seek(std::io::SeekFrom::Start(0))
16731                .unwrap();
16732            let mut req_result = {
16733                let client = &self.hub.client;
16734                dlg.pre_request();
16735                let mut req_builder = hyper::Request::builder()
16736                    .method(hyper::Method::POST)
16737                    .uri(url.as_str())
16738                    .header(USER_AGENT, self.hub._user_agent.clone());
16739
16740                if let Some(token) = token.as_ref() {
16741                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16742                }
16743
16744                let request = req_builder
16745                    .header(CONTENT_TYPE, json_mime_type.to_string())
16746                    .header(CONTENT_LENGTH, request_size as u64)
16747                    .body(common::to_body(
16748                        request_value_reader.get_ref().clone().into(),
16749                    ));
16750
16751                client.request(request.unwrap()).await
16752            };
16753
16754            match req_result {
16755                Err(err) => {
16756                    if let common::Retry::After(d) = dlg.http_error(&err) {
16757                        sleep(d).await;
16758                        continue;
16759                    }
16760                    dlg.finished(false);
16761                    return Err(common::Error::HttpError(err));
16762                }
16763                Ok(res) => {
16764                    let (mut parts, body) = res.into_parts();
16765                    let mut body = common::Body::new(body);
16766                    if !parts.status.is_success() {
16767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16768                        let error = serde_json::from_str(&common::to_string(&bytes));
16769                        let response = common::to_response(parts, bytes.into());
16770
16771                        if let common::Retry::After(d) =
16772                            dlg.http_failure(&response, error.as_ref().ok())
16773                        {
16774                            sleep(d).await;
16775                            continue;
16776                        }
16777
16778                        dlg.finished(false);
16779
16780                        return Err(match error {
16781                            Ok(value) => common::Error::BadRequest(value),
16782                            _ => common::Error::Failure(response),
16783                        });
16784                    }
16785                    let response = {
16786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16787                        let encoded = common::to_string(&bytes);
16788                        match serde_json::from_str(&encoded) {
16789                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16790                            Err(error) => {
16791                                dlg.response_json_decode_error(&encoded, &error);
16792                                return Err(common::Error::JsonDecodeError(
16793                                    encoded.to_string(),
16794                                    error,
16795                                ));
16796                            }
16797                        }
16798                    };
16799
16800                    dlg.finished(true);
16801                    return Ok(response);
16802                }
16803            }
16804        }
16805    }
16806
16807    ///
16808    /// Sets the *request* property to the given value.
16809    ///
16810    /// Even though the property as already been set when instantiating this call,
16811    /// we provide this method for API completeness.
16812    pub fn request(
16813        mut self,
16814        new_value: GoogleIamV1TestIamPermissionsRequest,
16815    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C> {
16816        self._request = new_value;
16817        self
16818    }
16819    /// 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.
16820    ///
16821    /// Sets the *resource* path property to the given value.
16822    ///
16823    /// Even though the property as already been set when instantiating this call,
16824    /// we provide this method for API completeness.
16825    pub fn resource(
16826        mut self,
16827        new_value: &str,
16828    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C> {
16829        self._resource = new_value.to_string();
16830        self
16831    }
16832    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16833    /// while executing the actual API request.
16834    ///
16835    /// ````text
16836    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16837    /// ````
16838    ///
16839    /// Sets the *delegate* property to the given value.
16840    pub fn delegate(
16841        mut self,
16842        new_value: &'a mut dyn common::Delegate,
16843    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C> {
16844        self._delegate = Some(new_value);
16845        self
16846    }
16847
16848    /// Set any additional parameter of the query string used in the request.
16849    /// It should be used to set parameters which are not yet available through their own
16850    /// setters.
16851    ///
16852    /// Please note that this method must not be used to set any of the known parameters
16853    /// which have their own setter method. If done anyway, the request will fail.
16854    ///
16855    /// # Additional Parameters
16856    ///
16857    /// * *$.xgafv* (query-string) - V1 error format.
16858    /// * *access_token* (query-string) - OAuth access token.
16859    /// * *alt* (query-string) - Data format for response.
16860    /// * *callback* (query-string) - JSONP
16861    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16862    /// * *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.
16863    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16864    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16865    /// * *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.
16866    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16867    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16868    pub fn param<T>(
16869        mut self,
16870        name: T,
16871        value: T,
16872    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C>
16873    where
16874        T: AsRef<str>,
16875    {
16876        self._additional_params
16877            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16878        self
16879    }
16880
16881    /// Identifies the authorization scope for the method you are building.
16882    ///
16883    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16884    /// [`Scope::CloudPlatform`].
16885    ///
16886    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16887    /// tokens for more than one scope.
16888    ///
16889    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16890    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16891    /// sufficient, a read-write scope will do as well.
16892    pub fn add_scope<St>(
16893        mut self,
16894        scope: St,
16895    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C>
16896    where
16897        St: AsRef<str>,
16898    {
16899        self._scopes.insert(String::from(scope.as_ref()));
16900        self
16901    }
16902    /// Identifies the authorization scope(s) for the method you are building.
16903    ///
16904    /// See [`Self::add_scope()`] for details.
16905    pub fn add_scopes<I, St>(
16906        mut self,
16907        scopes: I,
16908    ) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C>
16909    where
16910        I: IntoIterator<Item = St>,
16911        St: AsRef<str>,
16912    {
16913        self._scopes
16914            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16915        self
16916    }
16917
16918    /// Removes all scopes, and no default scope will be used either.
16919    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16920    /// for details).
16921    pub fn clear_scopes(mut self) -> ProjectLocationAddressGroupTestIamPermissionCall<'a, C> {
16922        self._scopes.clear();
16923        self
16924    }
16925}
16926
16927/// Creates a new AuthorizationPolicy in a given project and location.
16928///
16929/// A builder for the *locations.authorizationPolicies.create* method supported by a *project* resource.
16930/// It is not used directly, but through a [`ProjectMethods`] instance.
16931///
16932/// # Example
16933///
16934/// Instantiate a resource method builder
16935///
16936/// ```test_harness,no_run
16937/// # extern crate hyper;
16938/// # extern crate hyper_rustls;
16939/// # extern crate google_networksecurity1 as networksecurity1;
16940/// use networksecurity1::api::AuthorizationPolicy;
16941/// # async fn dox() {
16942/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16943///
16944/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16945/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16946/// #     secret,
16947/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16948/// # ).build().await.unwrap();
16949///
16950/// # let client = hyper_util::client::legacy::Client::builder(
16951/// #     hyper_util::rt::TokioExecutor::new()
16952/// # )
16953/// # .build(
16954/// #     hyper_rustls::HttpsConnectorBuilder::new()
16955/// #         .with_native_roots()
16956/// #         .unwrap()
16957/// #         .https_or_http()
16958/// #         .enable_http1()
16959/// #         .build()
16960/// # );
16961/// # let mut hub = NetworkSecurity::new(client, auth);
16962/// // As the method needs a request, you would usually fill it with the desired information
16963/// // into the respective structure. Some of the parts shown here might not be applicable !
16964/// // Values shown here are possibly random and not representative !
16965/// let mut req = AuthorizationPolicy::default();
16966///
16967/// // You can configure optional parameters by calling the respective setters at will, and
16968/// // execute the final call using `doit()`.
16969/// // Values shown here are possibly random and not representative !
16970/// let result = hub.projects().locations_authorization_policies_create(req, "parent")
16971///              .authorization_policy_id("gubergren")
16972///              .doit().await;
16973/// # }
16974/// ```
16975pub struct ProjectLocationAuthorizationPolicyCreateCall<'a, C>
16976where
16977    C: 'a,
16978{
16979    hub: &'a NetworkSecurity<C>,
16980    _request: AuthorizationPolicy,
16981    _parent: String,
16982    _authorization_policy_id: Option<String>,
16983    _delegate: Option<&'a mut dyn common::Delegate>,
16984    _additional_params: HashMap<String, String>,
16985    _scopes: BTreeSet<String>,
16986}
16987
16988impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyCreateCall<'a, C> {}
16989
16990impl<'a, C> ProjectLocationAuthorizationPolicyCreateCall<'a, C>
16991where
16992    C: common::Connector,
16993{
16994    /// Perform the operation you have build so far.
16995    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16996        use std::borrow::Cow;
16997        use std::io::{Read, Seek};
16998
16999        use common::{url::Params, ToParts};
17000        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17001
17002        let mut dd = common::DefaultDelegate;
17003        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17004        dlg.begin(common::MethodInfo {
17005            id: "networksecurity.projects.locations.authorizationPolicies.create",
17006            http_method: hyper::Method::POST,
17007        });
17008
17009        for &field in ["alt", "parent", "authorizationPolicyId"].iter() {
17010            if self._additional_params.contains_key(field) {
17011                dlg.finished(false);
17012                return Err(common::Error::FieldClash(field));
17013            }
17014        }
17015
17016        let mut params = Params::with_capacity(5 + self._additional_params.len());
17017        params.push("parent", self._parent);
17018        if let Some(value) = self._authorization_policy_id.as_ref() {
17019            params.push("authorizationPolicyId", value);
17020        }
17021
17022        params.extend(self._additional_params.iter());
17023
17024        params.push("alt", "json");
17025        let mut url = self.hub._base_url.clone() + "v1/{+parent}/authorizationPolicies";
17026        if self._scopes.is_empty() {
17027            self._scopes
17028                .insert(Scope::CloudPlatform.as_ref().to_string());
17029        }
17030
17031        #[allow(clippy::single_element_loop)]
17032        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17033            url = params.uri_replacement(url, param_name, find_this, true);
17034        }
17035        {
17036            let to_remove = ["parent"];
17037            params.remove_params(&to_remove);
17038        }
17039
17040        let url = params.parse_with_url(&url);
17041
17042        let mut json_mime_type = mime::APPLICATION_JSON;
17043        let mut request_value_reader = {
17044            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17045            common::remove_json_null_values(&mut value);
17046            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17047            serde_json::to_writer(&mut dst, &value).unwrap();
17048            dst
17049        };
17050        let request_size = request_value_reader
17051            .seek(std::io::SeekFrom::End(0))
17052            .unwrap();
17053        request_value_reader
17054            .seek(std::io::SeekFrom::Start(0))
17055            .unwrap();
17056
17057        loop {
17058            let token = match self
17059                .hub
17060                .auth
17061                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17062                .await
17063            {
17064                Ok(token) => token,
17065                Err(e) => match dlg.token(e) {
17066                    Ok(token) => token,
17067                    Err(e) => {
17068                        dlg.finished(false);
17069                        return Err(common::Error::MissingToken(e));
17070                    }
17071                },
17072            };
17073            request_value_reader
17074                .seek(std::io::SeekFrom::Start(0))
17075                .unwrap();
17076            let mut req_result = {
17077                let client = &self.hub.client;
17078                dlg.pre_request();
17079                let mut req_builder = hyper::Request::builder()
17080                    .method(hyper::Method::POST)
17081                    .uri(url.as_str())
17082                    .header(USER_AGENT, self.hub._user_agent.clone());
17083
17084                if let Some(token) = token.as_ref() {
17085                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17086                }
17087
17088                let request = req_builder
17089                    .header(CONTENT_TYPE, json_mime_type.to_string())
17090                    .header(CONTENT_LENGTH, request_size as u64)
17091                    .body(common::to_body(
17092                        request_value_reader.get_ref().clone().into(),
17093                    ));
17094
17095                client.request(request.unwrap()).await
17096            };
17097
17098            match req_result {
17099                Err(err) => {
17100                    if let common::Retry::After(d) = dlg.http_error(&err) {
17101                        sleep(d).await;
17102                        continue;
17103                    }
17104                    dlg.finished(false);
17105                    return Err(common::Error::HttpError(err));
17106                }
17107                Ok(res) => {
17108                    let (mut parts, body) = res.into_parts();
17109                    let mut body = common::Body::new(body);
17110                    if !parts.status.is_success() {
17111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17112                        let error = serde_json::from_str(&common::to_string(&bytes));
17113                        let response = common::to_response(parts, bytes.into());
17114
17115                        if let common::Retry::After(d) =
17116                            dlg.http_failure(&response, error.as_ref().ok())
17117                        {
17118                            sleep(d).await;
17119                            continue;
17120                        }
17121
17122                        dlg.finished(false);
17123
17124                        return Err(match error {
17125                            Ok(value) => common::Error::BadRequest(value),
17126                            _ => common::Error::Failure(response),
17127                        });
17128                    }
17129                    let response = {
17130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17131                        let encoded = common::to_string(&bytes);
17132                        match serde_json::from_str(&encoded) {
17133                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17134                            Err(error) => {
17135                                dlg.response_json_decode_error(&encoded, &error);
17136                                return Err(common::Error::JsonDecodeError(
17137                                    encoded.to_string(),
17138                                    error,
17139                                ));
17140                            }
17141                        }
17142                    };
17143
17144                    dlg.finished(true);
17145                    return Ok(response);
17146                }
17147            }
17148        }
17149    }
17150
17151    ///
17152    /// Sets the *request* property to the given value.
17153    ///
17154    /// Even though the property as already been set when instantiating this call,
17155    /// we provide this method for API completeness.
17156    pub fn request(
17157        mut self,
17158        new_value: AuthorizationPolicy,
17159    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C> {
17160        self._request = new_value;
17161        self
17162    }
17163    /// Required. The parent resource of the AuthorizationPolicy. Must be in the format `projects/{project}/locations/{location}`.
17164    ///
17165    /// Sets the *parent* path property to the given value.
17166    ///
17167    /// Even though the property as already been set when instantiating this call,
17168    /// we provide this method for API completeness.
17169    pub fn parent(
17170        mut self,
17171        new_value: &str,
17172    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C> {
17173        self._parent = new_value.to_string();
17174        self
17175    }
17176    /// Required. Short name of the AuthorizationPolicy resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "authz_policy".
17177    ///
17178    /// Sets the *authorization policy id* query property to the given value.
17179    pub fn authorization_policy_id(
17180        mut self,
17181        new_value: &str,
17182    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C> {
17183        self._authorization_policy_id = Some(new_value.to_string());
17184        self
17185    }
17186    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17187    /// while executing the actual API request.
17188    ///
17189    /// ````text
17190    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17191    /// ````
17192    ///
17193    /// Sets the *delegate* property to the given value.
17194    pub fn delegate(
17195        mut self,
17196        new_value: &'a mut dyn common::Delegate,
17197    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C> {
17198        self._delegate = Some(new_value);
17199        self
17200    }
17201
17202    /// Set any additional parameter of the query string used in the request.
17203    /// It should be used to set parameters which are not yet available through their own
17204    /// setters.
17205    ///
17206    /// Please note that this method must not be used to set any of the known parameters
17207    /// which have their own setter method. If done anyway, the request will fail.
17208    ///
17209    /// # Additional Parameters
17210    ///
17211    /// * *$.xgafv* (query-string) - V1 error format.
17212    /// * *access_token* (query-string) - OAuth access token.
17213    /// * *alt* (query-string) - Data format for response.
17214    /// * *callback* (query-string) - JSONP
17215    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17216    /// * *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.
17217    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17218    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17219    /// * *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.
17220    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17221    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17222    pub fn param<T>(
17223        mut self,
17224        name: T,
17225        value: T,
17226    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C>
17227    where
17228        T: AsRef<str>,
17229    {
17230        self._additional_params
17231            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17232        self
17233    }
17234
17235    /// Identifies the authorization scope for the method you are building.
17236    ///
17237    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17238    /// [`Scope::CloudPlatform`].
17239    ///
17240    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17241    /// tokens for more than one scope.
17242    ///
17243    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17244    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17245    /// sufficient, a read-write scope will do as well.
17246    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C>
17247    where
17248        St: AsRef<str>,
17249    {
17250        self._scopes.insert(String::from(scope.as_ref()));
17251        self
17252    }
17253    /// Identifies the authorization scope(s) for the method you are building.
17254    ///
17255    /// See [`Self::add_scope()`] for details.
17256    pub fn add_scopes<I, St>(
17257        mut self,
17258        scopes: I,
17259    ) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C>
17260    where
17261        I: IntoIterator<Item = St>,
17262        St: AsRef<str>,
17263    {
17264        self._scopes
17265            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17266        self
17267    }
17268
17269    /// Removes all scopes, and no default scope will be used either.
17270    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17271    /// for details).
17272    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicyCreateCall<'a, C> {
17273        self._scopes.clear();
17274        self
17275    }
17276}
17277
17278/// Deletes a single AuthorizationPolicy.
17279///
17280/// A builder for the *locations.authorizationPolicies.delete* method supported by a *project* resource.
17281/// It is not used directly, but through a [`ProjectMethods`] instance.
17282///
17283/// # Example
17284///
17285/// Instantiate a resource method builder
17286///
17287/// ```test_harness,no_run
17288/// # extern crate hyper;
17289/// # extern crate hyper_rustls;
17290/// # extern crate google_networksecurity1 as networksecurity1;
17291/// # async fn dox() {
17292/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17293///
17294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17295/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17296/// #     secret,
17297/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17298/// # ).build().await.unwrap();
17299///
17300/// # let client = hyper_util::client::legacy::Client::builder(
17301/// #     hyper_util::rt::TokioExecutor::new()
17302/// # )
17303/// # .build(
17304/// #     hyper_rustls::HttpsConnectorBuilder::new()
17305/// #         .with_native_roots()
17306/// #         .unwrap()
17307/// #         .https_or_http()
17308/// #         .enable_http1()
17309/// #         .build()
17310/// # );
17311/// # let mut hub = NetworkSecurity::new(client, auth);
17312/// // You can configure optional parameters by calling the respective setters at will, and
17313/// // execute the final call using `doit()`.
17314/// // Values shown here are possibly random and not representative !
17315/// let result = hub.projects().locations_authorization_policies_delete("name")
17316///              .doit().await;
17317/// # }
17318/// ```
17319pub struct ProjectLocationAuthorizationPolicyDeleteCall<'a, C>
17320where
17321    C: 'a,
17322{
17323    hub: &'a NetworkSecurity<C>,
17324    _name: String,
17325    _delegate: Option<&'a mut dyn common::Delegate>,
17326    _additional_params: HashMap<String, String>,
17327    _scopes: BTreeSet<String>,
17328}
17329
17330impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyDeleteCall<'a, C> {}
17331
17332impl<'a, C> ProjectLocationAuthorizationPolicyDeleteCall<'a, C>
17333where
17334    C: common::Connector,
17335{
17336    /// Perform the operation you have build so far.
17337    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17338        use std::borrow::Cow;
17339        use std::io::{Read, Seek};
17340
17341        use common::{url::Params, ToParts};
17342        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17343
17344        let mut dd = common::DefaultDelegate;
17345        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17346        dlg.begin(common::MethodInfo {
17347            id: "networksecurity.projects.locations.authorizationPolicies.delete",
17348            http_method: hyper::Method::DELETE,
17349        });
17350
17351        for &field in ["alt", "name"].iter() {
17352            if self._additional_params.contains_key(field) {
17353                dlg.finished(false);
17354                return Err(common::Error::FieldClash(field));
17355            }
17356        }
17357
17358        let mut params = Params::with_capacity(3 + self._additional_params.len());
17359        params.push("name", self._name);
17360
17361        params.extend(self._additional_params.iter());
17362
17363        params.push("alt", "json");
17364        let mut url = self.hub._base_url.clone() + "v1/{+name}";
17365        if self._scopes.is_empty() {
17366            self._scopes
17367                .insert(Scope::CloudPlatform.as_ref().to_string());
17368        }
17369
17370        #[allow(clippy::single_element_loop)]
17371        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17372            url = params.uri_replacement(url, param_name, find_this, true);
17373        }
17374        {
17375            let to_remove = ["name"];
17376            params.remove_params(&to_remove);
17377        }
17378
17379        let url = params.parse_with_url(&url);
17380
17381        loop {
17382            let token = match self
17383                .hub
17384                .auth
17385                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17386                .await
17387            {
17388                Ok(token) => token,
17389                Err(e) => match dlg.token(e) {
17390                    Ok(token) => token,
17391                    Err(e) => {
17392                        dlg.finished(false);
17393                        return Err(common::Error::MissingToken(e));
17394                    }
17395                },
17396            };
17397            let mut req_result = {
17398                let client = &self.hub.client;
17399                dlg.pre_request();
17400                let mut req_builder = hyper::Request::builder()
17401                    .method(hyper::Method::DELETE)
17402                    .uri(url.as_str())
17403                    .header(USER_AGENT, self.hub._user_agent.clone());
17404
17405                if let Some(token) = token.as_ref() {
17406                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17407                }
17408
17409                let request = req_builder
17410                    .header(CONTENT_LENGTH, 0_u64)
17411                    .body(common::to_body::<String>(None));
17412
17413                client.request(request.unwrap()).await
17414            };
17415
17416            match req_result {
17417                Err(err) => {
17418                    if let common::Retry::After(d) = dlg.http_error(&err) {
17419                        sleep(d).await;
17420                        continue;
17421                    }
17422                    dlg.finished(false);
17423                    return Err(common::Error::HttpError(err));
17424                }
17425                Ok(res) => {
17426                    let (mut parts, body) = res.into_parts();
17427                    let mut body = common::Body::new(body);
17428                    if !parts.status.is_success() {
17429                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17430                        let error = serde_json::from_str(&common::to_string(&bytes));
17431                        let response = common::to_response(parts, bytes.into());
17432
17433                        if let common::Retry::After(d) =
17434                            dlg.http_failure(&response, error.as_ref().ok())
17435                        {
17436                            sleep(d).await;
17437                            continue;
17438                        }
17439
17440                        dlg.finished(false);
17441
17442                        return Err(match error {
17443                            Ok(value) => common::Error::BadRequest(value),
17444                            _ => common::Error::Failure(response),
17445                        });
17446                    }
17447                    let response = {
17448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17449                        let encoded = common::to_string(&bytes);
17450                        match serde_json::from_str(&encoded) {
17451                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17452                            Err(error) => {
17453                                dlg.response_json_decode_error(&encoded, &error);
17454                                return Err(common::Error::JsonDecodeError(
17455                                    encoded.to_string(),
17456                                    error,
17457                                ));
17458                            }
17459                        }
17460                    };
17461
17462                    dlg.finished(true);
17463                    return Ok(response);
17464                }
17465            }
17466        }
17467    }
17468
17469    /// Required. A name of the AuthorizationPolicy to delete. Must be in the format `projects/{project}/locations/{location}/authorizationPolicies/*`.
17470    ///
17471    /// Sets the *name* path property to the given value.
17472    ///
17473    /// Even though the property as already been set when instantiating this call,
17474    /// we provide this method for API completeness.
17475    pub fn name(mut self, new_value: &str) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C> {
17476        self._name = new_value.to_string();
17477        self
17478    }
17479    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17480    /// while executing the actual API request.
17481    ///
17482    /// ````text
17483    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17484    /// ````
17485    ///
17486    /// Sets the *delegate* property to the given value.
17487    pub fn delegate(
17488        mut self,
17489        new_value: &'a mut dyn common::Delegate,
17490    ) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C> {
17491        self._delegate = Some(new_value);
17492        self
17493    }
17494
17495    /// Set any additional parameter of the query string used in the request.
17496    /// It should be used to set parameters which are not yet available through their own
17497    /// setters.
17498    ///
17499    /// Please note that this method must not be used to set any of the known parameters
17500    /// which have their own setter method. If done anyway, the request will fail.
17501    ///
17502    /// # Additional Parameters
17503    ///
17504    /// * *$.xgafv* (query-string) - V1 error format.
17505    /// * *access_token* (query-string) - OAuth access token.
17506    /// * *alt* (query-string) - Data format for response.
17507    /// * *callback* (query-string) - JSONP
17508    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17509    /// * *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.
17510    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17511    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17512    /// * *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.
17513    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17514    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17515    pub fn param<T>(
17516        mut self,
17517        name: T,
17518        value: T,
17519    ) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C>
17520    where
17521        T: AsRef<str>,
17522    {
17523        self._additional_params
17524            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17525        self
17526    }
17527
17528    /// Identifies the authorization scope for the method you are building.
17529    ///
17530    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17531    /// [`Scope::CloudPlatform`].
17532    ///
17533    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17534    /// tokens for more than one scope.
17535    ///
17536    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17537    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17538    /// sufficient, a read-write scope will do as well.
17539    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C>
17540    where
17541        St: AsRef<str>,
17542    {
17543        self._scopes.insert(String::from(scope.as_ref()));
17544        self
17545    }
17546    /// Identifies the authorization scope(s) for the method you are building.
17547    ///
17548    /// See [`Self::add_scope()`] for details.
17549    pub fn add_scopes<I, St>(
17550        mut self,
17551        scopes: I,
17552    ) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C>
17553    where
17554        I: IntoIterator<Item = St>,
17555        St: AsRef<str>,
17556    {
17557        self._scopes
17558            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17559        self
17560    }
17561
17562    /// Removes all scopes, and no default scope will be used either.
17563    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17564    /// for details).
17565    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicyDeleteCall<'a, C> {
17566        self._scopes.clear();
17567        self
17568    }
17569}
17570
17571/// Gets details of a single AuthorizationPolicy.
17572///
17573/// A builder for the *locations.authorizationPolicies.get* method supported by a *project* resource.
17574/// It is not used directly, but through a [`ProjectMethods`] instance.
17575///
17576/// # Example
17577///
17578/// Instantiate a resource method builder
17579///
17580/// ```test_harness,no_run
17581/// # extern crate hyper;
17582/// # extern crate hyper_rustls;
17583/// # extern crate google_networksecurity1 as networksecurity1;
17584/// # async fn dox() {
17585/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17586///
17587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17589/// #     secret,
17590/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17591/// # ).build().await.unwrap();
17592///
17593/// # let client = hyper_util::client::legacy::Client::builder(
17594/// #     hyper_util::rt::TokioExecutor::new()
17595/// # )
17596/// # .build(
17597/// #     hyper_rustls::HttpsConnectorBuilder::new()
17598/// #         .with_native_roots()
17599/// #         .unwrap()
17600/// #         .https_or_http()
17601/// #         .enable_http1()
17602/// #         .build()
17603/// # );
17604/// # let mut hub = NetworkSecurity::new(client, auth);
17605/// // You can configure optional parameters by calling the respective setters at will, and
17606/// // execute the final call using `doit()`.
17607/// // Values shown here are possibly random and not representative !
17608/// let result = hub.projects().locations_authorization_policies_get("name")
17609///              .doit().await;
17610/// # }
17611/// ```
17612pub struct ProjectLocationAuthorizationPolicyGetCall<'a, C>
17613where
17614    C: 'a,
17615{
17616    hub: &'a NetworkSecurity<C>,
17617    _name: String,
17618    _delegate: Option<&'a mut dyn common::Delegate>,
17619    _additional_params: HashMap<String, String>,
17620    _scopes: BTreeSet<String>,
17621}
17622
17623impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyGetCall<'a, C> {}
17624
17625impl<'a, C> ProjectLocationAuthorizationPolicyGetCall<'a, C>
17626where
17627    C: common::Connector,
17628{
17629    /// Perform the operation you have build so far.
17630    pub async fn doit(mut self) -> common::Result<(common::Response, AuthorizationPolicy)> {
17631        use std::borrow::Cow;
17632        use std::io::{Read, Seek};
17633
17634        use common::{url::Params, ToParts};
17635        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17636
17637        let mut dd = common::DefaultDelegate;
17638        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17639        dlg.begin(common::MethodInfo {
17640            id: "networksecurity.projects.locations.authorizationPolicies.get",
17641            http_method: hyper::Method::GET,
17642        });
17643
17644        for &field in ["alt", "name"].iter() {
17645            if self._additional_params.contains_key(field) {
17646                dlg.finished(false);
17647                return Err(common::Error::FieldClash(field));
17648            }
17649        }
17650
17651        let mut params = Params::with_capacity(3 + self._additional_params.len());
17652        params.push("name", self._name);
17653
17654        params.extend(self._additional_params.iter());
17655
17656        params.push("alt", "json");
17657        let mut url = self.hub._base_url.clone() + "v1/{+name}";
17658        if self._scopes.is_empty() {
17659            self._scopes
17660                .insert(Scope::CloudPlatform.as_ref().to_string());
17661        }
17662
17663        #[allow(clippy::single_element_loop)]
17664        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17665            url = params.uri_replacement(url, param_name, find_this, true);
17666        }
17667        {
17668            let to_remove = ["name"];
17669            params.remove_params(&to_remove);
17670        }
17671
17672        let url = params.parse_with_url(&url);
17673
17674        loop {
17675            let token = match self
17676                .hub
17677                .auth
17678                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17679                .await
17680            {
17681                Ok(token) => token,
17682                Err(e) => match dlg.token(e) {
17683                    Ok(token) => token,
17684                    Err(e) => {
17685                        dlg.finished(false);
17686                        return Err(common::Error::MissingToken(e));
17687                    }
17688                },
17689            };
17690            let mut req_result = {
17691                let client = &self.hub.client;
17692                dlg.pre_request();
17693                let mut req_builder = hyper::Request::builder()
17694                    .method(hyper::Method::GET)
17695                    .uri(url.as_str())
17696                    .header(USER_AGENT, self.hub._user_agent.clone());
17697
17698                if let Some(token) = token.as_ref() {
17699                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17700                }
17701
17702                let request = req_builder
17703                    .header(CONTENT_LENGTH, 0_u64)
17704                    .body(common::to_body::<String>(None));
17705
17706                client.request(request.unwrap()).await
17707            };
17708
17709            match req_result {
17710                Err(err) => {
17711                    if let common::Retry::After(d) = dlg.http_error(&err) {
17712                        sleep(d).await;
17713                        continue;
17714                    }
17715                    dlg.finished(false);
17716                    return Err(common::Error::HttpError(err));
17717                }
17718                Ok(res) => {
17719                    let (mut parts, body) = res.into_parts();
17720                    let mut body = common::Body::new(body);
17721                    if !parts.status.is_success() {
17722                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17723                        let error = serde_json::from_str(&common::to_string(&bytes));
17724                        let response = common::to_response(parts, bytes.into());
17725
17726                        if let common::Retry::After(d) =
17727                            dlg.http_failure(&response, error.as_ref().ok())
17728                        {
17729                            sleep(d).await;
17730                            continue;
17731                        }
17732
17733                        dlg.finished(false);
17734
17735                        return Err(match error {
17736                            Ok(value) => common::Error::BadRequest(value),
17737                            _ => common::Error::Failure(response),
17738                        });
17739                    }
17740                    let response = {
17741                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17742                        let encoded = common::to_string(&bytes);
17743                        match serde_json::from_str(&encoded) {
17744                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17745                            Err(error) => {
17746                                dlg.response_json_decode_error(&encoded, &error);
17747                                return Err(common::Error::JsonDecodeError(
17748                                    encoded.to_string(),
17749                                    error,
17750                                ));
17751                            }
17752                        }
17753                    };
17754
17755                    dlg.finished(true);
17756                    return Ok(response);
17757                }
17758            }
17759        }
17760    }
17761
17762    /// Required. A name of the AuthorizationPolicy to get. Must be in the format `projects/{project}/locations/{location}/authorizationPolicies/*`.
17763    ///
17764    /// Sets the *name* path property to the given value.
17765    ///
17766    /// Even though the property as already been set when instantiating this call,
17767    /// we provide this method for API completeness.
17768    pub fn name(mut self, new_value: &str) -> ProjectLocationAuthorizationPolicyGetCall<'a, C> {
17769        self._name = new_value.to_string();
17770        self
17771    }
17772    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17773    /// while executing the actual API request.
17774    ///
17775    /// ````text
17776    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17777    /// ````
17778    ///
17779    /// Sets the *delegate* property to the given value.
17780    pub fn delegate(
17781        mut self,
17782        new_value: &'a mut dyn common::Delegate,
17783    ) -> ProjectLocationAuthorizationPolicyGetCall<'a, C> {
17784        self._delegate = Some(new_value);
17785        self
17786    }
17787
17788    /// Set any additional parameter of the query string used in the request.
17789    /// It should be used to set parameters which are not yet available through their own
17790    /// setters.
17791    ///
17792    /// Please note that this method must not be used to set any of the known parameters
17793    /// which have their own setter method. If done anyway, the request will fail.
17794    ///
17795    /// # Additional Parameters
17796    ///
17797    /// * *$.xgafv* (query-string) - V1 error format.
17798    /// * *access_token* (query-string) - OAuth access token.
17799    /// * *alt* (query-string) - Data format for response.
17800    /// * *callback* (query-string) - JSONP
17801    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17802    /// * *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.
17803    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17804    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17805    /// * *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.
17806    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17807    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17808    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAuthorizationPolicyGetCall<'a, C>
17809    where
17810        T: AsRef<str>,
17811    {
17812        self._additional_params
17813            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17814        self
17815    }
17816
17817    /// Identifies the authorization scope for the method you are building.
17818    ///
17819    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17820    /// [`Scope::CloudPlatform`].
17821    ///
17822    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17823    /// tokens for more than one scope.
17824    ///
17825    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17826    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17827    /// sufficient, a read-write scope will do as well.
17828    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthorizationPolicyGetCall<'a, C>
17829    where
17830        St: AsRef<str>,
17831    {
17832        self._scopes.insert(String::from(scope.as_ref()));
17833        self
17834    }
17835    /// Identifies the authorization scope(s) for the method you are building.
17836    ///
17837    /// See [`Self::add_scope()`] for details.
17838    pub fn add_scopes<I, St>(
17839        mut self,
17840        scopes: I,
17841    ) -> ProjectLocationAuthorizationPolicyGetCall<'a, C>
17842    where
17843        I: IntoIterator<Item = St>,
17844        St: AsRef<str>,
17845    {
17846        self._scopes
17847            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17848        self
17849    }
17850
17851    /// Removes all scopes, and no default scope will be used either.
17852    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17853    /// for details).
17854    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicyGetCall<'a, C> {
17855        self._scopes.clear();
17856        self
17857    }
17858}
17859
17860/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
17861///
17862/// A builder for the *locations.authorizationPolicies.getIamPolicy* method supported by a *project* resource.
17863/// It is not used directly, but through a [`ProjectMethods`] instance.
17864///
17865/// # Example
17866///
17867/// Instantiate a resource method builder
17868///
17869/// ```test_harness,no_run
17870/// # extern crate hyper;
17871/// # extern crate hyper_rustls;
17872/// # extern crate google_networksecurity1 as networksecurity1;
17873/// # async fn dox() {
17874/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17875///
17876/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17877/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17878/// #     secret,
17879/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17880/// # ).build().await.unwrap();
17881///
17882/// # let client = hyper_util::client::legacy::Client::builder(
17883/// #     hyper_util::rt::TokioExecutor::new()
17884/// # )
17885/// # .build(
17886/// #     hyper_rustls::HttpsConnectorBuilder::new()
17887/// #         .with_native_roots()
17888/// #         .unwrap()
17889/// #         .https_or_http()
17890/// #         .enable_http1()
17891/// #         .build()
17892/// # );
17893/// # let mut hub = NetworkSecurity::new(client, auth);
17894/// // You can configure optional parameters by calling the respective setters at will, and
17895/// // execute the final call using `doit()`.
17896/// // Values shown here are possibly random and not representative !
17897/// let result = hub.projects().locations_authorization_policies_get_iam_policy("resource")
17898///              .options_requested_policy_version(-34)
17899///              .doit().await;
17900/// # }
17901/// ```
17902pub struct ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C>
17903where
17904    C: 'a,
17905{
17906    hub: &'a NetworkSecurity<C>,
17907    _resource: String,
17908    _options_requested_policy_version: Option<i32>,
17909    _delegate: Option<&'a mut dyn common::Delegate>,
17910    _additional_params: HashMap<String, String>,
17911    _scopes: BTreeSet<String>,
17912}
17913
17914impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C> {}
17915
17916impl<'a, C> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C>
17917where
17918    C: common::Connector,
17919{
17920    /// Perform the operation you have build so far.
17921    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
17922        use std::borrow::Cow;
17923        use std::io::{Read, Seek};
17924
17925        use common::{url::Params, ToParts};
17926        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17927
17928        let mut dd = common::DefaultDelegate;
17929        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17930        dlg.begin(common::MethodInfo {
17931            id: "networksecurity.projects.locations.authorizationPolicies.getIamPolicy",
17932            http_method: hyper::Method::GET,
17933        });
17934
17935        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
17936            if self._additional_params.contains_key(field) {
17937                dlg.finished(false);
17938                return Err(common::Error::FieldClash(field));
17939            }
17940        }
17941
17942        let mut params = Params::with_capacity(4 + self._additional_params.len());
17943        params.push("resource", self._resource);
17944        if let Some(value) = self._options_requested_policy_version.as_ref() {
17945            params.push("options.requestedPolicyVersion", value.to_string());
17946        }
17947
17948        params.extend(self._additional_params.iter());
17949
17950        params.push("alt", "json");
17951        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
17952        if self._scopes.is_empty() {
17953            self._scopes
17954                .insert(Scope::CloudPlatform.as_ref().to_string());
17955        }
17956
17957        #[allow(clippy::single_element_loop)]
17958        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17959            url = params.uri_replacement(url, param_name, find_this, true);
17960        }
17961        {
17962            let to_remove = ["resource"];
17963            params.remove_params(&to_remove);
17964        }
17965
17966        let url = params.parse_with_url(&url);
17967
17968        loop {
17969            let token = match self
17970                .hub
17971                .auth
17972                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17973                .await
17974            {
17975                Ok(token) => token,
17976                Err(e) => match dlg.token(e) {
17977                    Ok(token) => token,
17978                    Err(e) => {
17979                        dlg.finished(false);
17980                        return Err(common::Error::MissingToken(e));
17981                    }
17982                },
17983            };
17984            let mut req_result = {
17985                let client = &self.hub.client;
17986                dlg.pre_request();
17987                let mut req_builder = hyper::Request::builder()
17988                    .method(hyper::Method::GET)
17989                    .uri(url.as_str())
17990                    .header(USER_AGENT, self.hub._user_agent.clone());
17991
17992                if let Some(token) = token.as_ref() {
17993                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17994                }
17995
17996                let request = req_builder
17997                    .header(CONTENT_LENGTH, 0_u64)
17998                    .body(common::to_body::<String>(None));
17999
18000                client.request(request.unwrap()).await
18001            };
18002
18003            match req_result {
18004                Err(err) => {
18005                    if let common::Retry::After(d) = dlg.http_error(&err) {
18006                        sleep(d).await;
18007                        continue;
18008                    }
18009                    dlg.finished(false);
18010                    return Err(common::Error::HttpError(err));
18011                }
18012                Ok(res) => {
18013                    let (mut parts, body) = res.into_parts();
18014                    let mut body = common::Body::new(body);
18015                    if !parts.status.is_success() {
18016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18017                        let error = serde_json::from_str(&common::to_string(&bytes));
18018                        let response = common::to_response(parts, bytes.into());
18019
18020                        if let common::Retry::After(d) =
18021                            dlg.http_failure(&response, error.as_ref().ok())
18022                        {
18023                            sleep(d).await;
18024                            continue;
18025                        }
18026
18027                        dlg.finished(false);
18028
18029                        return Err(match error {
18030                            Ok(value) => common::Error::BadRequest(value),
18031                            _ => common::Error::Failure(response),
18032                        });
18033                    }
18034                    let response = {
18035                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18036                        let encoded = common::to_string(&bytes);
18037                        match serde_json::from_str(&encoded) {
18038                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18039                            Err(error) => {
18040                                dlg.response_json_decode_error(&encoded, &error);
18041                                return Err(common::Error::JsonDecodeError(
18042                                    encoded.to_string(),
18043                                    error,
18044                                ));
18045                            }
18046                        }
18047                    };
18048
18049                    dlg.finished(true);
18050                    return Ok(response);
18051                }
18052            }
18053        }
18054    }
18055
18056    /// 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.
18057    ///
18058    /// Sets the *resource* path property to the given value.
18059    ///
18060    /// Even though the property as already been set when instantiating this call,
18061    /// we provide this method for API completeness.
18062    pub fn resource(
18063        mut self,
18064        new_value: &str,
18065    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C> {
18066        self._resource = new_value.to_string();
18067        self
18068    }
18069    /// 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).
18070    ///
18071    /// Sets the *options.requested policy version* query property to the given value.
18072    pub fn options_requested_policy_version(
18073        mut self,
18074        new_value: i32,
18075    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C> {
18076        self._options_requested_policy_version = Some(new_value);
18077        self
18078    }
18079    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18080    /// while executing the actual API request.
18081    ///
18082    /// ````text
18083    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18084    /// ````
18085    ///
18086    /// Sets the *delegate* property to the given value.
18087    pub fn delegate(
18088        mut self,
18089        new_value: &'a mut dyn common::Delegate,
18090    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C> {
18091        self._delegate = Some(new_value);
18092        self
18093    }
18094
18095    /// Set any additional parameter of the query string used in the request.
18096    /// It should be used to set parameters which are not yet available through their own
18097    /// setters.
18098    ///
18099    /// Please note that this method must not be used to set any of the known parameters
18100    /// which have their own setter method. If done anyway, the request will fail.
18101    ///
18102    /// # Additional Parameters
18103    ///
18104    /// * *$.xgafv* (query-string) - V1 error format.
18105    /// * *access_token* (query-string) - OAuth access token.
18106    /// * *alt* (query-string) - Data format for response.
18107    /// * *callback* (query-string) - JSONP
18108    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18109    /// * *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.
18110    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18111    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18112    /// * *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.
18113    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18114    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18115    pub fn param<T>(
18116        mut self,
18117        name: T,
18118        value: T,
18119    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C>
18120    where
18121        T: AsRef<str>,
18122    {
18123        self._additional_params
18124            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18125        self
18126    }
18127
18128    /// Identifies the authorization scope for the method you are building.
18129    ///
18130    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18131    /// [`Scope::CloudPlatform`].
18132    ///
18133    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18134    /// tokens for more than one scope.
18135    ///
18136    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18137    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18138    /// sufficient, a read-write scope will do as well.
18139    pub fn add_scope<St>(
18140        mut self,
18141        scope: St,
18142    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C>
18143    where
18144        St: AsRef<str>,
18145    {
18146        self._scopes.insert(String::from(scope.as_ref()));
18147        self
18148    }
18149    /// Identifies the authorization scope(s) for the method you are building.
18150    ///
18151    /// See [`Self::add_scope()`] for details.
18152    pub fn add_scopes<I, St>(
18153        mut self,
18154        scopes: I,
18155    ) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C>
18156    where
18157        I: IntoIterator<Item = St>,
18158        St: AsRef<str>,
18159    {
18160        self._scopes
18161            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18162        self
18163    }
18164
18165    /// Removes all scopes, and no default scope will be used either.
18166    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18167    /// for details).
18168    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicyGetIamPolicyCall<'a, C> {
18169        self._scopes.clear();
18170        self
18171    }
18172}
18173
18174/// Lists AuthorizationPolicies in a given project and location.
18175///
18176/// A builder for the *locations.authorizationPolicies.list* method supported by a *project* resource.
18177/// It is not used directly, but through a [`ProjectMethods`] instance.
18178///
18179/// # Example
18180///
18181/// Instantiate a resource method builder
18182///
18183/// ```test_harness,no_run
18184/// # extern crate hyper;
18185/// # extern crate hyper_rustls;
18186/// # extern crate google_networksecurity1 as networksecurity1;
18187/// # async fn dox() {
18188/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18189///
18190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18191/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18192/// #     secret,
18193/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18194/// # ).build().await.unwrap();
18195///
18196/// # let client = hyper_util::client::legacy::Client::builder(
18197/// #     hyper_util::rt::TokioExecutor::new()
18198/// # )
18199/// # .build(
18200/// #     hyper_rustls::HttpsConnectorBuilder::new()
18201/// #         .with_native_roots()
18202/// #         .unwrap()
18203/// #         .https_or_http()
18204/// #         .enable_http1()
18205/// #         .build()
18206/// # );
18207/// # let mut hub = NetworkSecurity::new(client, auth);
18208/// // You can configure optional parameters by calling the respective setters at will, and
18209/// // execute the final call using `doit()`.
18210/// // Values shown here are possibly random and not representative !
18211/// let result = hub.projects().locations_authorization_policies_list("parent")
18212///              .page_token("dolore")
18213///              .page_size(-78)
18214///              .doit().await;
18215/// # }
18216/// ```
18217pub struct ProjectLocationAuthorizationPolicyListCall<'a, C>
18218where
18219    C: 'a,
18220{
18221    hub: &'a NetworkSecurity<C>,
18222    _parent: String,
18223    _page_token: Option<String>,
18224    _page_size: Option<i32>,
18225    _delegate: Option<&'a mut dyn common::Delegate>,
18226    _additional_params: HashMap<String, String>,
18227    _scopes: BTreeSet<String>,
18228}
18229
18230impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyListCall<'a, C> {}
18231
18232impl<'a, C> ProjectLocationAuthorizationPolicyListCall<'a, C>
18233where
18234    C: common::Connector,
18235{
18236    /// Perform the operation you have build so far.
18237    pub async fn doit(
18238        mut self,
18239    ) -> common::Result<(common::Response, ListAuthorizationPoliciesResponse)> {
18240        use std::borrow::Cow;
18241        use std::io::{Read, Seek};
18242
18243        use common::{url::Params, ToParts};
18244        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18245
18246        let mut dd = common::DefaultDelegate;
18247        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18248        dlg.begin(common::MethodInfo {
18249            id: "networksecurity.projects.locations.authorizationPolicies.list",
18250            http_method: hyper::Method::GET,
18251        });
18252
18253        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
18254            if self._additional_params.contains_key(field) {
18255                dlg.finished(false);
18256                return Err(common::Error::FieldClash(field));
18257            }
18258        }
18259
18260        let mut params = Params::with_capacity(5 + self._additional_params.len());
18261        params.push("parent", self._parent);
18262        if let Some(value) = self._page_token.as_ref() {
18263            params.push("pageToken", value);
18264        }
18265        if let Some(value) = self._page_size.as_ref() {
18266            params.push("pageSize", value.to_string());
18267        }
18268
18269        params.extend(self._additional_params.iter());
18270
18271        params.push("alt", "json");
18272        let mut url = self.hub._base_url.clone() + "v1/{+parent}/authorizationPolicies";
18273        if self._scopes.is_empty() {
18274            self._scopes
18275                .insert(Scope::CloudPlatform.as_ref().to_string());
18276        }
18277
18278        #[allow(clippy::single_element_loop)]
18279        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18280            url = params.uri_replacement(url, param_name, find_this, true);
18281        }
18282        {
18283            let to_remove = ["parent"];
18284            params.remove_params(&to_remove);
18285        }
18286
18287        let url = params.parse_with_url(&url);
18288
18289        loop {
18290            let token = match self
18291                .hub
18292                .auth
18293                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18294                .await
18295            {
18296                Ok(token) => token,
18297                Err(e) => match dlg.token(e) {
18298                    Ok(token) => token,
18299                    Err(e) => {
18300                        dlg.finished(false);
18301                        return Err(common::Error::MissingToken(e));
18302                    }
18303                },
18304            };
18305            let mut req_result = {
18306                let client = &self.hub.client;
18307                dlg.pre_request();
18308                let mut req_builder = hyper::Request::builder()
18309                    .method(hyper::Method::GET)
18310                    .uri(url.as_str())
18311                    .header(USER_AGENT, self.hub._user_agent.clone());
18312
18313                if let Some(token) = token.as_ref() {
18314                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18315                }
18316
18317                let request = req_builder
18318                    .header(CONTENT_LENGTH, 0_u64)
18319                    .body(common::to_body::<String>(None));
18320
18321                client.request(request.unwrap()).await
18322            };
18323
18324            match req_result {
18325                Err(err) => {
18326                    if let common::Retry::After(d) = dlg.http_error(&err) {
18327                        sleep(d).await;
18328                        continue;
18329                    }
18330                    dlg.finished(false);
18331                    return Err(common::Error::HttpError(err));
18332                }
18333                Ok(res) => {
18334                    let (mut parts, body) = res.into_parts();
18335                    let mut body = common::Body::new(body);
18336                    if !parts.status.is_success() {
18337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18338                        let error = serde_json::from_str(&common::to_string(&bytes));
18339                        let response = common::to_response(parts, bytes.into());
18340
18341                        if let common::Retry::After(d) =
18342                            dlg.http_failure(&response, error.as_ref().ok())
18343                        {
18344                            sleep(d).await;
18345                            continue;
18346                        }
18347
18348                        dlg.finished(false);
18349
18350                        return Err(match error {
18351                            Ok(value) => common::Error::BadRequest(value),
18352                            _ => common::Error::Failure(response),
18353                        });
18354                    }
18355                    let response = {
18356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18357                        let encoded = common::to_string(&bytes);
18358                        match serde_json::from_str(&encoded) {
18359                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18360                            Err(error) => {
18361                                dlg.response_json_decode_error(&encoded, &error);
18362                                return Err(common::Error::JsonDecodeError(
18363                                    encoded.to_string(),
18364                                    error,
18365                                ));
18366                            }
18367                        }
18368                    };
18369
18370                    dlg.finished(true);
18371                    return Ok(response);
18372                }
18373            }
18374        }
18375    }
18376
18377    /// Required. The project and location from which the AuthorizationPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
18378    ///
18379    /// Sets the *parent* path property to the given value.
18380    ///
18381    /// Even though the property as already been set when instantiating this call,
18382    /// we provide this method for API completeness.
18383    pub fn parent(mut self, new_value: &str) -> ProjectLocationAuthorizationPolicyListCall<'a, C> {
18384        self._parent = new_value.to_string();
18385        self
18386    }
18387    /// The value returned by the last `ListAuthorizationPoliciesResponse` Indicates that this is a continuation of a prior `ListAuthorizationPolicies` call, and that the system should return the next page of data.
18388    ///
18389    /// Sets the *page token* query property to the given value.
18390    pub fn page_token(
18391        mut self,
18392        new_value: &str,
18393    ) -> ProjectLocationAuthorizationPolicyListCall<'a, C> {
18394        self._page_token = Some(new_value.to_string());
18395        self
18396    }
18397    /// Maximum number of AuthorizationPolicies to return per call.
18398    ///
18399    /// Sets the *page size* query property to the given value.
18400    pub fn page_size(
18401        mut self,
18402        new_value: i32,
18403    ) -> ProjectLocationAuthorizationPolicyListCall<'a, C> {
18404        self._page_size = Some(new_value);
18405        self
18406    }
18407    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18408    /// while executing the actual API request.
18409    ///
18410    /// ````text
18411    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18412    /// ````
18413    ///
18414    /// Sets the *delegate* property to the given value.
18415    pub fn delegate(
18416        mut self,
18417        new_value: &'a mut dyn common::Delegate,
18418    ) -> ProjectLocationAuthorizationPolicyListCall<'a, C> {
18419        self._delegate = Some(new_value);
18420        self
18421    }
18422
18423    /// Set any additional parameter of the query string used in the request.
18424    /// It should be used to set parameters which are not yet available through their own
18425    /// setters.
18426    ///
18427    /// Please note that this method must not be used to set any of the known parameters
18428    /// which have their own setter method. If done anyway, the request will fail.
18429    ///
18430    /// # Additional Parameters
18431    ///
18432    /// * *$.xgafv* (query-string) - V1 error format.
18433    /// * *access_token* (query-string) - OAuth access token.
18434    /// * *alt* (query-string) - Data format for response.
18435    /// * *callback* (query-string) - JSONP
18436    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18437    /// * *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.
18438    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18439    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18440    /// * *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.
18441    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18442    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18443    pub fn param<T>(
18444        mut self,
18445        name: T,
18446        value: T,
18447    ) -> ProjectLocationAuthorizationPolicyListCall<'a, C>
18448    where
18449        T: AsRef<str>,
18450    {
18451        self._additional_params
18452            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18453        self
18454    }
18455
18456    /// Identifies the authorization scope for the method you are building.
18457    ///
18458    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18459    /// [`Scope::CloudPlatform`].
18460    ///
18461    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18462    /// tokens for more than one scope.
18463    ///
18464    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18465    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18466    /// sufficient, a read-write scope will do as well.
18467    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthorizationPolicyListCall<'a, C>
18468    where
18469        St: AsRef<str>,
18470    {
18471        self._scopes.insert(String::from(scope.as_ref()));
18472        self
18473    }
18474    /// Identifies the authorization scope(s) for the method you are building.
18475    ///
18476    /// See [`Self::add_scope()`] for details.
18477    pub fn add_scopes<I, St>(
18478        mut self,
18479        scopes: I,
18480    ) -> ProjectLocationAuthorizationPolicyListCall<'a, C>
18481    where
18482        I: IntoIterator<Item = St>,
18483        St: AsRef<str>,
18484    {
18485        self._scopes
18486            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18487        self
18488    }
18489
18490    /// Removes all scopes, and no default scope will be used either.
18491    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18492    /// for details).
18493    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicyListCall<'a, C> {
18494        self._scopes.clear();
18495        self
18496    }
18497}
18498
18499/// Updates the parameters of a single AuthorizationPolicy.
18500///
18501/// A builder for the *locations.authorizationPolicies.patch* method supported by a *project* resource.
18502/// It is not used directly, but through a [`ProjectMethods`] instance.
18503///
18504/// # Example
18505///
18506/// Instantiate a resource method builder
18507///
18508/// ```test_harness,no_run
18509/// # extern crate hyper;
18510/// # extern crate hyper_rustls;
18511/// # extern crate google_networksecurity1 as networksecurity1;
18512/// use networksecurity1::api::AuthorizationPolicy;
18513/// # async fn dox() {
18514/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18515///
18516/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18517/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18518/// #     secret,
18519/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18520/// # ).build().await.unwrap();
18521///
18522/// # let client = hyper_util::client::legacy::Client::builder(
18523/// #     hyper_util::rt::TokioExecutor::new()
18524/// # )
18525/// # .build(
18526/// #     hyper_rustls::HttpsConnectorBuilder::new()
18527/// #         .with_native_roots()
18528/// #         .unwrap()
18529/// #         .https_or_http()
18530/// #         .enable_http1()
18531/// #         .build()
18532/// # );
18533/// # let mut hub = NetworkSecurity::new(client, auth);
18534/// // As the method needs a request, you would usually fill it with the desired information
18535/// // into the respective structure. Some of the parts shown here might not be applicable !
18536/// // Values shown here are possibly random and not representative !
18537/// let mut req = AuthorizationPolicy::default();
18538///
18539/// // You can configure optional parameters by calling the respective setters at will, and
18540/// // execute the final call using `doit()`.
18541/// // Values shown here are possibly random and not representative !
18542/// let result = hub.projects().locations_authorization_policies_patch(req, "name")
18543///              .update_mask(FieldMask::new::<&str>(&[]))
18544///              .doit().await;
18545/// # }
18546/// ```
18547pub struct ProjectLocationAuthorizationPolicyPatchCall<'a, C>
18548where
18549    C: 'a,
18550{
18551    hub: &'a NetworkSecurity<C>,
18552    _request: AuthorizationPolicy,
18553    _name: String,
18554    _update_mask: Option<common::FieldMask>,
18555    _delegate: Option<&'a mut dyn common::Delegate>,
18556    _additional_params: HashMap<String, String>,
18557    _scopes: BTreeSet<String>,
18558}
18559
18560impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyPatchCall<'a, C> {}
18561
18562impl<'a, C> ProjectLocationAuthorizationPolicyPatchCall<'a, C>
18563where
18564    C: common::Connector,
18565{
18566    /// Perform the operation you have build so far.
18567    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18568        use std::borrow::Cow;
18569        use std::io::{Read, Seek};
18570
18571        use common::{url::Params, ToParts};
18572        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18573
18574        let mut dd = common::DefaultDelegate;
18575        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18576        dlg.begin(common::MethodInfo {
18577            id: "networksecurity.projects.locations.authorizationPolicies.patch",
18578            http_method: hyper::Method::PATCH,
18579        });
18580
18581        for &field in ["alt", "name", "updateMask"].iter() {
18582            if self._additional_params.contains_key(field) {
18583                dlg.finished(false);
18584                return Err(common::Error::FieldClash(field));
18585            }
18586        }
18587
18588        let mut params = Params::with_capacity(5 + self._additional_params.len());
18589        params.push("name", self._name);
18590        if let Some(value) = self._update_mask.as_ref() {
18591            params.push("updateMask", value.to_string());
18592        }
18593
18594        params.extend(self._additional_params.iter());
18595
18596        params.push("alt", "json");
18597        let mut url = self.hub._base_url.clone() + "v1/{+name}";
18598        if self._scopes.is_empty() {
18599            self._scopes
18600                .insert(Scope::CloudPlatform.as_ref().to_string());
18601        }
18602
18603        #[allow(clippy::single_element_loop)]
18604        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18605            url = params.uri_replacement(url, param_name, find_this, true);
18606        }
18607        {
18608            let to_remove = ["name"];
18609            params.remove_params(&to_remove);
18610        }
18611
18612        let url = params.parse_with_url(&url);
18613
18614        let mut json_mime_type = mime::APPLICATION_JSON;
18615        let mut request_value_reader = {
18616            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18617            common::remove_json_null_values(&mut value);
18618            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18619            serde_json::to_writer(&mut dst, &value).unwrap();
18620            dst
18621        };
18622        let request_size = request_value_reader
18623            .seek(std::io::SeekFrom::End(0))
18624            .unwrap();
18625        request_value_reader
18626            .seek(std::io::SeekFrom::Start(0))
18627            .unwrap();
18628
18629        loop {
18630            let token = match self
18631                .hub
18632                .auth
18633                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18634                .await
18635            {
18636                Ok(token) => token,
18637                Err(e) => match dlg.token(e) {
18638                    Ok(token) => token,
18639                    Err(e) => {
18640                        dlg.finished(false);
18641                        return Err(common::Error::MissingToken(e));
18642                    }
18643                },
18644            };
18645            request_value_reader
18646                .seek(std::io::SeekFrom::Start(0))
18647                .unwrap();
18648            let mut req_result = {
18649                let client = &self.hub.client;
18650                dlg.pre_request();
18651                let mut req_builder = hyper::Request::builder()
18652                    .method(hyper::Method::PATCH)
18653                    .uri(url.as_str())
18654                    .header(USER_AGENT, self.hub._user_agent.clone());
18655
18656                if let Some(token) = token.as_ref() {
18657                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18658                }
18659
18660                let request = req_builder
18661                    .header(CONTENT_TYPE, json_mime_type.to_string())
18662                    .header(CONTENT_LENGTH, request_size as u64)
18663                    .body(common::to_body(
18664                        request_value_reader.get_ref().clone().into(),
18665                    ));
18666
18667                client.request(request.unwrap()).await
18668            };
18669
18670            match req_result {
18671                Err(err) => {
18672                    if let common::Retry::After(d) = dlg.http_error(&err) {
18673                        sleep(d).await;
18674                        continue;
18675                    }
18676                    dlg.finished(false);
18677                    return Err(common::Error::HttpError(err));
18678                }
18679                Ok(res) => {
18680                    let (mut parts, body) = res.into_parts();
18681                    let mut body = common::Body::new(body);
18682                    if !parts.status.is_success() {
18683                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18684                        let error = serde_json::from_str(&common::to_string(&bytes));
18685                        let response = common::to_response(parts, bytes.into());
18686
18687                        if let common::Retry::After(d) =
18688                            dlg.http_failure(&response, error.as_ref().ok())
18689                        {
18690                            sleep(d).await;
18691                            continue;
18692                        }
18693
18694                        dlg.finished(false);
18695
18696                        return Err(match error {
18697                            Ok(value) => common::Error::BadRequest(value),
18698                            _ => common::Error::Failure(response),
18699                        });
18700                    }
18701                    let response = {
18702                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18703                        let encoded = common::to_string(&bytes);
18704                        match serde_json::from_str(&encoded) {
18705                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18706                            Err(error) => {
18707                                dlg.response_json_decode_error(&encoded, &error);
18708                                return Err(common::Error::JsonDecodeError(
18709                                    encoded.to_string(),
18710                                    error,
18711                                ));
18712                            }
18713                        }
18714                    };
18715
18716                    dlg.finished(true);
18717                    return Ok(response);
18718                }
18719            }
18720        }
18721    }
18722
18723    ///
18724    /// Sets the *request* property to the given value.
18725    ///
18726    /// Even though the property as already been set when instantiating this call,
18727    /// we provide this method for API completeness.
18728    pub fn request(
18729        mut self,
18730        new_value: AuthorizationPolicy,
18731    ) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C> {
18732        self._request = new_value;
18733        self
18734    }
18735    /// Required. Name of the AuthorizationPolicy resource. It matches pattern `projects/{project}/locations/{location}/authorizationPolicies/`.
18736    ///
18737    /// Sets the *name* path property to the given value.
18738    ///
18739    /// Even though the property as already been set when instantiating this call,
18740    /// we provide this method for API completeness.
18741    pub fn name(mut self, new_value: &str) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C> {
18742        self._name = new_value.to_string();
18743        self
18744    }
18745    /// Optional. Field mask is used to specify the fields to be overwritten in the AuthorizationPolicy 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.
18746    ///
18747    /// Sets the *update mask* query property to the given value.
18748    pub fn update_mask(
18749        mut self,
18750        new_value: common::FieldMask,
18751    ) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C> {
18752        self._update_mask = Some(new_value);
18753        self
18754    }
18755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18756    /// while executing the actual API request.
18757    ///
18758    /// ````text
18759    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18760    /// ````
18761    ///
18762    /// Sets the *delegate* property to the given value.
18763    pub fn delegate(
18764        mut self,
18765        new_value: &'a mut dyn common::Delegate,
18766    ) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C> {
18767        self._delegate = Some(new_value);
18768        self
18769    }
18770
18771    /// Set any additional parameter of the query string used in the request.
18772    /// It should be used to set parameters which are not yet available through their own
18773    /// setters.
18774    ///
18775    /// Please note that this method must not be used to set any of the known parameters
18776    /// which have their own setter method. If done anyway, the request will fail.
18777    ///
18778    /// # Additional Parameters
18779    ///
18780    /// * *$.xgafv* (query-string) - V1 error format.
18781    /// * *access_token* (query-string) - OAuth access token.
18782    /// * *alt* (query-string) - Data format for response.
18783    /// * *callback* (query-string) - JSONP
18784    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18785    /// * *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.
18786    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18787    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18788    /// * *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.
18789    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18790    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18791    pub fn param<T>(
18792        mut self,
18793        name: T,
18794        value: T,
18795    ) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C>
18796    where
18797        T: AsRef<str>,
18798    {
18799        self._additional_params
18800            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18801        self
18802    }
18803
18804    /// Identifies the authorization scope for the method you are building.
18805    ///
18806    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18807    /// [`Scope::CloudPlatform`].
18808    ///
18809    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18810    /// tokens for more than one scope.
18811    ///
18812    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18813    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18814    /// sufficient, a read-write scope will do as well.
18815    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C>
18816    where
18817        St: AsRef<str>,
18818    {
18819        self._scopes.insert(String::from(scope.as_ref()));
18820        self
18821    }
18822    /// Identifies the authorization scope(s) for the method you are building.
18823    ///
18824    /// See [`Self::add_scope()`] for details.
18825    pub fn add_scopes<I, St>(
18826        mut self,
18827        scopes: I,
18828    ) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C>
18829    where
18830        I: IntoIterator<Item = St>,
18831        St: AsRef<str>,
18832    {
18833        self._scopes
18834            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18835        self
18836    }
18837
18838    /// Removes all scopes, and no default scope will be used either.
18839    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18840    /// for details).
18841    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicyPatchCall<'a, C> {
18842        self._scopes.clear();
18843        self
18844    }
18845}
18846
18847/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
18848///
18849/// A builder for the *locations.authorizationPolicies.setIamPolicy* method supported by a *project* resource.
18850/// It is not used directly, but through a [`ProjectMethods`] instance.
18851///
18852/// # Example
18853///
18854/// Instantiate a resource method builder
18855///
18856/// ```test_harness,no_run
18857/// # extern crate hyper;
18858/// # extern crate hyper_rustls;
18859/// # extern crate google_networksecurity1 as networksecurity1;
18860/// use networksecurity1::api::GoogleIamV1SetIamPolicyRequest;
18861/// # async fn dox() {
18862/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18863///
18864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18866/// #     secret,
18867/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18868/// # ).build().await.unwrap();
18869///
18870/// # let client = hyper_util::client::legacy::Client::builder(
18871/// #     hyper_util::rt::TokioExecutor::new()
18872/// # )
18873/// # .build(
18874/// #     hyper_rustls::HttpsConnectorBuilder::new()
18875/// #         .with_native_roots()
18876/// #         .unwrap()
18877/// #         .https_or_http()
18878/// #         .enable_http1()
18879/// #         .build()
18880/// # );
18881/// # let mut hub = NetworkSecurity::new(client, auth);
18882/// // As the method needs a request, you would usually fill it with the desired information
18883/// // into the respective structure. Some of the parts shown here might not be applicable !
18884/// // Values shown here are possibly random and not representative !
18885/// let mut req = GoogleIamV1SetIamPolicyRequest::default();
18886///
18887/// // You can configure optional parameters by calling the respective setters at will, and
18888/// // execute the final call using `doit()`.
18889/// // Values shown here are possibly random and not representative !
18890/// let result = hub.projects().locations_authorization_policies_set_iam_policy(req, "resource")
18891///              .doit().await;
18892/// # }
18893/// ```
18894pub struct ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C>
18895where
18896    C: 'a,
18897{
18898    hub: &'a NetworkSecurity<C>,
18899    _request: GoogleIamV1SetIamPolicyRequest,
18900    _resource: String,
18901    _delegate: Option<&'a mut dyn common::Delegate>,
18902    _additional_params: HashMap<String, String>,
18903    _scopes: BTreeSet<String>,
18904}
18905
18906impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C> {}
18907
18908impl<'a, C> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C>
18909where
18910    C: common::Connector,
18911{
18912    /// Perform the operation you have build so far.
18913    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
18914        use std::borrow::Cow;
18915        use std::io::{Read, Seek};
18916
18917        use common::{url::Params, ToParts};
18918        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18919
18920        let mut dd = common::DefaultDelegate;
18921        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18922        dlg.begin(common::MethodInfo {
18923            id: "networksecurity.projects.locations.authorizationPolicies.setIamPolicy",
18924            http_method: hyper::Method::POST,
18925        });
18926
18927        for &field in ["alt", "resource"].iter() {
18928            if self._additional_params.contains_key(field) {
18929                dlg.finished(false);
18930                return Err(common::Error::FieldClash(field));
18931            }
18932        }
18933
18934        let mut params = Params::with_capacity(4 + self._additional_params.len());
18935        params.push("resource", self._resource);
18936
18937        params.extend(self._additional_params.iter());
18938
18939        params.push("alt", "json");
18940        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
18941        if self._scopes.is_empty() {
18942            self._scopes
18943                .insert(Scope::CloudPlatform.as_ref().to_string());
18944        }
18945
18946        #[allow(clippy::single_element_loop)]
18947        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
18948            url = params.uri_replacement(url, param_name, find_this, true);
18949        }
18950        {
18951            let to_remove = ["resource"];
18952            params.remove_params(&to_remove);
18953        }
18954
18955        let url = params.parse_with_url(&url);
18956
18957        let mut json_mime_type = mime::APPLICATION_JSON;
18958        let mut request_value_reader = {
18959            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18960            common::remove_json_null_values(&mut value);
18961            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18962            serde_json::to_writer(&mut dst, &value).unwrap();
18963            dst
18964        };
18965        let request_size = request_value_reader
18966            .seek(std::io::SeekFrom::End(0))
18967            .unwrap();
18968        request_value_reader
18969            .seek(std::io::SeekFrom::Start(0))
18970            .unwrap();
18971
18972        loop {
18973            let token = match self
18974                .hub
18975                .auth
18976                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18977                .await
18978            {
18979                Ok(token) => token,
18980                Err(e) => match dlg.token(e) {
18981                    Ok(token) => token,
18982                    Err(e) => {
18983                        dlg.finished(false);
18984                        return Err(common::Error::MissingToken(e));
18985                    }
18986                },
18987            };
18988            request_value_reader
18989                .seek(std::io::SeekFrom::Start(0))
18990                .unwrap();
18991            let mut req_result = {
18992                let client = &self.hub.client;
18993                dlg.pre_request();
18994                let mut req_builder = hyper::Request::builder()
18995                    .method(hyper::Method::POST)
18996                    .uri(url.as_str())
18997                    .header(USER_AGENT, self.hub._user_agent.clone());
18998
18999                if let Some(token) = token.as_ref() {
19000                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19001                }
19002
19003                let request = req_builder
19004                    .header(CONTENT_TYPE, json_mime_type.to_string())
19005                    .header(CONTENT_LENGTH, request_size as u64)
19006                    .body(common::to_body(
19007                        request_value_reader.get_ref().clone().into(),
19008                    ));
19009
19010                client.request(request.unwrap()).await
19011            };
19012
19013            match req_result {
19014                Err(err) => {
19015                    if let common::Retry::After(d) = dlg.http_error(&err) {
19016                        sleep(d).await;
19017                        continue;
19018                    }
19019                    dlg.finished(false);
19020                    return Err(common::Error::HttpError(err));
19021                }
19022                Ok(res) => {
19023                    let (mut parts, body) = res.into_parts();
19024                    let mut body = common::Body::new(body);
19025                    if !parts.status.is_success() {
19026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19027                        let error = serde_json::from_str(&common::to_string(&bytes));
19028                        let response = common::to_response(parts, bytes.into());
19029
19030                        if let common::Retry::After(d) =
19031                            dlg.http_failure(&response, error.as_ref().ok())
19032                        {
19033                            sleep(d).await;
19034                            continue;
19035                        }
19036
19037                        dlg.finished(false);
19038
19039                        return Err(match error {
19040                            Ok(value) => common::Error::BadRequest(value),
19041                            _ => common::Error::Failure(response),
19042                        });
19043                    }
19044                    let response = {
19045                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19046                        let encoded = common::to_string(&bytes);
19047                        match serde_json::from_str(&encoded) {
19048                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19049                            Err(error) => {
19050                                dlg.response_json_decode_error(&encoded, &error);
19051                                return Err(common::Error::JsonDecodeError(
19052                                    encoded.to_string(),
19053                                    error,
19054                                ));
19055                            }
19056                        }
19057                    };
19058
19059                    dlg.finished(true);
19060                    return Ok(response);
19061                }
19062            }
19063        }
19064    }
19065
19066    ///
19067    /// Sets the *request* property to the given value.
19068    ///
19069    /// Even though the property as already been set when instantiating this call,
19070    /// we provide this method for API completeness.
19071    pub fn request(
19072        mut self,
19073        new_value: GoogleIamV1SetIamPolicyRequest,
19074    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C> {
19075        self._request = new_value;
19076        self
19077    }
19078    /// 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.
19079    ///
19080    /// Sets the *resource* path property to the given value.
19081    ///
19082    /// Even though the property as already been set when instantiating this call,
19083    /// we provide this method for API completeness.
19084    pub fn resource(
19085        mut self,
19086        new_value: &str,
19087    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C> {
19088        self._resource = new_value.to_string();
19089        self
19090    }
19091    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19092    /// while executing the actual API request.
19093    ///
19094    /// ````text
19095    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19096    /// ````
19097    ///
19098    /// Sets the *delegate* property to the given value.
19099    pub fn delegate(
19100        mut self,
19101        new_value: &'a mut dyn common::Delegate,
19102    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C> {
19103        self._delegate = Some(new_value);
19104        self
19105    }
19106
19107    /// Set any additional parameter of the query string used in the request.
19108    /// It should be used to set parameters which are not yet available through their own
19109    /// setters.
19110    ///
19111    /// Please note that this method must not be used to set any of the known parameters
19112    /// which have their own setter method. If done anyway, the request will fail.
19113    ///
19114    /// # Additional Parameters
19115    ///
19116    /// * *$.xgafv* (query-string) - V1 error format.
19117    /// * *access_token* (query-string) - OAuth access token.
19118    /// * *alt* (query-string) - Data format for response.
19119    /// * *callback* (query-string) - JSONP
19120    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19121    /// * *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.
19122    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19123    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19124    /// * *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.
19125    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19126    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19127    pub fn param<T>(
19128        mut self,
19129        name: T,
19130        value: T,
19131    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C>
19132    where
19133        T: AsRef<str>,
19134    {
19135        self._additional_params
19136            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19137        self
19138    }
19139
19140    /// Identifies the authorization scope for the method you are building.
19141    ///
19142    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19143    /// [`Scope::CloudPlatform`].
19144    ///
19145    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19146    /// tokens for more than one scope.
19147    ///
19148    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19149    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19150    /// sufficient, a read-write scope will do as well.
19151    pub fn add_scope<St>(
19152        mut self,
19153        scope: St,
19154    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C>
19155    where
19156        St: AsRef<str>,
19157    {
19158        self._scopes.insert(String::from(scope.as_ref()));
19159        self
19160    }
19161    /// Identifies the authorization scope(s) for the method you are building.
19162    ///
19163    /// See [`Self::add_scope()`] for details.
19164    pub fn add_scopes<I, St>(
19165        mut self,
19166        scopes: I,
19167    ) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C>
19168    where
19169        I: IntoIterator<Item = St>,
19170        St: AsRef<str>,
19171    {
19172        self._scopes
19173            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19174        self
19175    }
19176
19177    /// Removes all scopes, and no default scope will be used either.
19178    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19179    /// for details).
19180    pub fn clear_scopes(mut self) -> ProjectLocationAuthorizationPolicySetIamPolicyCall<'a, C> {
19181        self._scopes.clear();
19182        self
19183    }
19184}
19185
19186/// 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.
19187///
19188/// A builder for the *locations.authorizationPolicies.testIamPermissions* method supported by a *project* resource.
19189/// It is not used directly, but through a [`ProjectMethods`] instance.
19190///
19191/// # Example
19192///
19193/// Instantiate a resource method builder
19194///
19195/// ```test_harness,no_run
19196/// # extern crate hyper;
19197/// # extern crate hyper_rustls;
19198/// # extern crate google_networksecurity1 as networksecurity1;
19199/// use networksecurity1::api::GoogleIamV1TestIamPermissionsRequest;
19200/// # async fn dox() {
19201/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19202///
19203/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19204/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19205/// #     secret,
19206/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19207/// # ).build().await.unwrap();
19208///
19209/// # let client = hyper_util::client::legacy::Client::builder(
19210/// #     hyper_util::rt::TokioExecutor::new()
19211/// # )
19212/// # .build(
19213/// #     hyper_rustls::HttpsConnectorBuilder::new()
19214/// #         .with_native_roots()
19215/// #         .unwrap()
19216/// #         .https_or_http()
19217/// #         .enable_http1()
19218/// #         .build()
19219/// # );
19220/// # let mut hub = NetworkSecurity::new(client, auth);
19221/// // As the method needs a request, you would usually fill it with the desired information
19222/// // into the respective structure. Some of the parts shown here might not be applicable !
19223/// // Values shown here are possibly random and not representative !
19224/// let mut req = GoogleIamV1TestIamPermissionsRequest::default();
19225///
19226/// // You can configure optional parameters by calling the respective setters at will, and
19227/// // execute the final call using `doit()`.
19228/// // Values shown here are possibly random and not representative !
19229/// let result = hub.projects().locations_authorization_policies_test_iam_permissions(req, "resource")
19230///              .doit().await;
19231/// # }
19232/// ```
19233pub struct ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C>
19234where
19235    C: 'a,
19236{
19237    hub: &'a NetworkSecurity<C>,
19238    _request: GoogleIamV1TestIamPermissionsRequest,
19239    _resource: String,
19240    _delegate: Option<&'a mut dyn common::Delegate>,
19241    _additional_params: HashMap<String, String>,
19242    _scopes: BTreeSet<String>,
19243}
19244
19245impl<'a, C> common::CallBuilder for ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C> {}
19246
19247impl<'a, C> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C>
19248where
19249    C: common::Connector,
19250{
19251    /// Perform the operation you have build so far.
19252    pub async fn doit(
19253        mut self,
19254    ) -> common::Result<(common::Response, GoogleIamV1TestIamPermissionsResponse)> {
19255        use std::borrow::Cow;
19256        use std::io::{Read, Seek};
19257
19258        use common::{url::Params, ToParts};
19259        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19260
19261        let mut dd = common::DefaultDelegate;
19262        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19263        dlg.begin(common::MethodInfo {
19264            id: "networksecurity.projects.locations.authorizationPolicies.testIamPermissions",
19265            http_method: hyper::Method::POST,
19266        });
19267
19268        for &field in ["alt", "resource"].iter() {
19269            if self._additional_params.contains_key(field) {
19270                dlg.finished(false);
19271                return Err(common::Error::FieldClash(field));
19272            }
19273        }
19274
19275        let mut params = Params::with_capacity(4 + self._additional_params.len());
19276        params.push("resource", self._resource);
19277
19278        params.extend(self._additional_params.iter());
19279
19280        params.push("alt", "json");
19281        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
19282        if self._scopes.is_empty() {
19283            self._scopes
19284                .insert(Scope::CloudPlatform.as_ref().to_string());
19285        }
19286
19287        #[allow(clippy::single_element_loop)]
19288        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
19289            url = params.uri_replacement(url, param_name, find_this, true);
19290        }
19291        {
19292            let to_remove = ["resource"];
19293            params.remove_params(&to_remove);
19294        }
19295
19296        let url = params.parse_with_url(&url);
19297
19298        let mut json_mime_type = mime::APPLICATION_JSON;
19299        let mut request_value_reader = {
19300            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19301            common::remove_json_null_values(&mut value);
19302            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19303            serde_json::to_writer(&mut dst, &value).unwrap();
19304            dst
19305        };
19306        let request_size = request_value_reader
19307            .seek(std::io::SeekFrom::End(0))
19308            .unwrap();
19309        request_value_reader
19310            .seek(std::io::SeekFrom::Start(0))
19311            .unwrap();
19312
19313        loop {
19314            let token = match self
19315                .hub
19316                .auth
19317                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19318                .await
19319            {
19320                Ok(token) => token,
19321                Err(e) => match dlg.token(e) {
19322                    Ok(token) => token,
19323                    Err(e) => {
19324                        dlg.finished(false);
19325                        return Err(common::Error::MissingToken(e));
19326                    }
19327                },
19328            };
19329            request_value_reader
19330                .seek(std::io::SeekFrom::Start(0))
19331                .unwrap();
19332            let mut req_result = {
19333                let client = &self.hub.client;
19334                dlg.pre_request();
19335                let mut req_builder = hyper::Request::builder()
19336                    .method(hyper::Method::POST)
19337                    .uri(url.as_str())
19338                    .header(USER_AGENT, self.hub._user_agent.clone());
19339
19340                if let Some(token) = token.as_ref() {
19341                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19342                }
19343
19344                let request = req_builder
19345                    .header(CONTENT_TYPE, json_mime_type.to_string())
19346                    .header(CONTENT_LENGTH, request_size as u64)
19347                    .body(common::to_body(
19348                        request_value_reader.get_ref().clone().into(),
19349                    ));
19350
19351                client.request(request.unwrap()).await
19352            };
19353
19354            match req_result {
19355                Err(err) => {
19356                    if let common::Retry::After(d) = dlg.http_error(&err) {
19357                        sleep(d).await;
19358                        continue;
19359                    }
19360                    dlg.finished(false);
19361                    return Err(common::Error::HttpError(err));
19362                }
19363                Ok(res) => {
19364                    let (mut parts, body) = res.into_parts();
19365                    let mut body = common::Body::new(body);
19366                    if !parts.status.is_success() {
19367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19368                        let error = serde_json::from_str(&common::to_string(&bytes));
19369                        let response = common::to_response(parts, bytes.into());
19370
19371                        if let common::Retry::After(d) =
19372                            dlg.http_failure(&response, error.as_ref().ok())
19373                        {
19374                            sleep(d).await;
19375                            continue;
19376                        }
19377
19378                        dlg.finished(false);
19379
19380                        return Err(match error {
19381                            Ok(value) => common::Error::BadRequest(value),
19382                            _ => common::Error::Failure(response),
19383                        });
19384                    }
19385                    let response = {
19386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19387                        let encoded = common::to_string(&bytes);
19388                        match serde_json::from_str(&encoded) {
19389                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19390                            Err(error) => {
19391                                dlg.response_json_decode_error(&encoded, &error);
19392                                return Err(common::Error::JsonDecodeError(
19393                                    encoded.to_string(),
19394                                    error,
19395                                ));
19396                            }
19397                        }
19398                    };
19399
19400                    dlg.finished(true);
19401                    return Ok(response);
19402                }
19403            }
19404        }
19405    }
19406
19407    ///
19408    /// Sets the *request* property to the given value.
19409    ///
19410    /// Even though the property as already been set when instantiating this call,
19411    /// we provide this method for API completeness.
19412    pub fn request(
19413        mut self,
19414        new_value: GoogleIamV1TestIamPermissionsRequest,
19415    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C> {
19416        self._request = new_value;
19417        self
19418    }
19419    /// 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.
19420    ///
19421    /// Sets the *resource* path property to the given value.
19422    ///
19423    /// Even though the property as already been set when instantiating this call,
19424    /// we provide this method for API completeness.
19425    pub fn resource(
19426        mut self,
19427        new_value: &str,
19428    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C> {
19429        self._resource = new_value.to_string();
19430        self
19431    }
19432    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19433    /// while executing the actual API request.
19434    ///
19435    /// ````text
19436    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19437    /// ````
19438    ///
19439    /// Sets the *delegate* property to the given value.
19440    pub fn delegate(
19441        mut self,
19442        new_value: &'a mut dyn common::Delegate,
19443    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C> {
19444        self._delegate = Some(new_value);
19445        self
19446    }
19447
19448    /// Set any additional parameter of the query string used in the request.
19449    /// It should be used to set parameters which are not yet available through their own
19450    /// setters.
19451    ///
19452    /// Please note that this method must not be used to set any of the known parameters
19453    /// which have their own setter method. If done anyway, the request will fail.
19454    ///
19455    /// # Additional Parameters
19456    ///
19457    /// * *$.xgafv* (query-string) - V1 error format.
19458    /// * *access_token* (query-string) - OAuth access token.
19459    /// * *alt* (query-string) - Data format for response.
19460    /// * *callback* (query-string) - JSONP
19461    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19462    /// * *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.
19463    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19464    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19465    /// * *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.
19466    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19467    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19468    pub fn param<T>(
19469        mut self,
19470        name: T,
19471        value: T,
19472    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C>
19473    where
19474        T: AsRef<str>,
19475    {
19476        self._additional_params
19477            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19478        self
19479    }
19480
19481    /// Identifies the authorization scope for the method you are building.
19482    ///
19483    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19484    /// [`Scope::CloudPlatform`].
19485    ///
19486    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19487    /// tokens for more than one scope.
19488    ///
19489    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19490    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19491    /// sufficient, a read-write scope will do as well.
19492    pub fn add_scope<St>(
19493        mut self,
19494        scope: St,
19495    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C>
19496    where
19497        St: AsRef<str>,
19498    {
19499        self._scopes.insert(String::from(scope.as_ref()));
19500        self
19501    }
19502    /// Identifies the authorization scope(s) for the method you are building.
19503    ///
19504    /// See [`Self::add_scope()`] for details.
19505    pub fn add_scopes<I, St>(
19506        mut self,
19507        scopes: I,
19508    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C>
19509    where
19510        I: IntoIterator<Item = St>,
19511        St: AsRef<str>,
19512    {
19513        self._scopes
19514            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19515        self
19516    }
19517
19518    /// Removes all scopes, and no default scope will be used either.
19519    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19520    /// for details).
19521    pub fn clear_scopes(
19522        mut self,
19523    ) -> ProjectLocationAuthorizationPolicyTestIamPermissionCall<'a, C> {
19524        self._scopes.clear();
19525        self
19526    }
19527}
19528
19529/// Creates a new ClientTlsPolicy in a given project and location.
19530///
19531/// A builder for the *locations.clientTlsPolicies.create* method supported by a *project* resource.
19532/// It is not used directly, but through a [`ProjectMethods`] instance.
19533///
19534/// # Example
19535///
19536/// Instantiate a resource method builder
19537///
19538/// ```test_harness,no_run
19539/// # extern crate hyper;
19540/// # extern crate hyper_rustls;
19541/// # extern crate google_networksecurity1 as networksecurity1;
19542/// use networksecurity1::api::ClientTlsPolicy;
19543/// # async fn dox() {
19544/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19545///
19546/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19547/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19548/// #     secret,
19549/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19550/// # ).build().await.unwrap();
19551///
19552/// # let client = hyper_util::client::legacy::Client::builder(
19553/// #     hyper_util::rt::TokioExecutor::new()
19554/// # )
19555/// # .build(
19556/// #     hyper_rustls::HttpsConnectorBuilder::new()
19557/// #         .with_native_roots()
19558/// #         .unwrap()
19559/// #         .https_or_http()
19560/// #         .enable_http1()
19561/// #         .build()
19562/// # );
19563/// # let mut hub = NetworkSecurity::new(client, auth);
19564/// // As the method needs a request, you would usually fill it with the desired information
19565/// // into the respective structure. Some of the parts shown here might not be applicable !
19566/// // Values shown here are possibly random and not representative !
19567/// let mut req = ClientTlsPolicy::default();
19568///
19569/// // You can configure optional parameters by calling the respective setters at will, and
19570/// // execute the final call using `doit()`.
19571/// // Values shown here are possibly random and not representative !
19572/// let result = hub.projects().locations_client_tls_policies_create(req, "parent")
19573///              .client_tls_policy_id("invidunt")
19574///              .doit().await;
19575/// # }
19576/// ```
19577pub struct ProjectLocationClientTlsPolicyCreateCall<'a, C>
19578where
19579    C: 'a,
19580{
19581    hub: &'a NetworkSecurity<C>,
19582    _request: ClientTlsPolicy,
19583    _parent: String,
19584    _client_tls_policy_id: Option<String>,
19585    _delegate: Option<&'a mut dyn common::Delegate>,
19586    _additional_params: HashMap<String, String>,
19587    _scopes: BTreeSet<String>,
19588}
19589
19590impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyCreateCall<'a, C> {}
19591
19592impl<'a, C> ProjectLocationClientTlsPolicyCreateCall<'a, C>
19593where
19594    C: common::Connector,
19595{
19596    /// Perform the operation you have build so far.
19597    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19598        use std::borrow::Cow;
19599        use std::io::{Read, Seek};
19600
19601        use common::{url::Params, ToParts};
19602        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19603
19604        let mut dd = common::DefaultDelegate;
19605        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19606        dlg.begin(common::MethodInfo {
19607            id: "networksecurity.projects.locations.clientTlsPolicies.create",
19608            http_method: hyper::Method::POST,
19609        });
19610
19611        for &field in ["alt", "parent", "clientTlsPolicyId"].iter() {
19612            if self._additional_params.contains_key(field) {
19613                dlg.finished(false);
19614                return Err(common::Error::FieldClash(field));
19615            }
19616        }
19617
19618        let mut params = Params::with_capacity(5 + self._additional_params.len());
19619        params.push("parent", self._parent);
19620        if let Some(value) = self._client_tls_policy_id.as_ref() {
19621            params.push("clientTlsPolicyId", value);
19622        }
19623
19624        params.extend(self._additional_params.iter());
19625
19626        params.push("alt", "json");
19627        let mut url = self.hub._base_url.clone() + "v1/{+parent}/clientTlsPolicies";
19628        if self._scopes.is_empty() {
19629            self._scopes
19630                .insert(Scope::CloudPlatform.as_ref().to_string());
19631        }
19632
19633        #[allow(clippy::single_element_loop)]
19634        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19635            url = params.uri_replacement(url, param_name, find_this, true);
19636        }
19637        {
19638            let to_remove = ["parent"];
19639            params.remove_params(&to_remove);
19640        }
19641
19642        let url = params.parse_with_url(&url);
19643
19644        let mut json_mime_type = mime::APPLICATION_JSON;
19645        let mut request_value_reader = {
19646            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19647            common::remove_json_null_values(&mut value);
19648            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19649            serde_json::to_writer(&mut dst, &value).unwrap();
19650            dst
19651        };
19652        let request_size = request_value_reader
19653            .seek(std::io::SeekFrom::End(0))
19654            .unwrap();
19655        request_value_reader
19656            .seek(std::io::SeekFrom::Start(0))
19657            .unwrap();
19658
19659        loop {
19660            let token = match self
19661                .hub
19662                .auth
19663                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19664                .await
19665            {
19666                Ok(token) => token,
19667                Err(e) => match dlg.token(e) {
19668                    Ok(token) => token,
19669                    Err(e) => {
19670                        dlg.finished(false);
19671                        return Err(common::Error::MissingToken(e));
19672                    }
19673                },
19674            };
19675            request_value_reader
19676                .seek(std::io::SeekFrom::Start(0))
19677                .unwrap();
19678            let mut req_result = {
19679                let client = &self.hub.client;
19680                dlg.pre_request();
19681                let mut req_builder = hyper::Request::builder()
19682                    .method(hyper::Method::POST)
19683                    .uri(url.as_str())
19684                    .header(USER_AGENT, self.hub._user_agent.clone());
19685
19686                if let Some(token) = token.as_ref() {
19687                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19688                }
19689
19690                let request = req_builder
19691                    .header(CONTENT_TYPE, json_mime_type.to_string())
19692                    .header(CONTENT_LENGTH, request_size as u64)
19693                    .body(common::to_body(
19694                        request_value_reader.get_ref().clone().into(),
19695                    ));
19696
19697                client.request(request.unwrap()).await
19698            };
19699
19700            match req_result {
19701                Err(err) => {
19702                    if let common::Retry::After(d) = dlg.http_error(&err) {
19703                        sleep(d).await;
19704                        continue;
19705                    }
19706                    dlg.finished(false);
19707                    return Err(common::Error::HttpError(err));
19708                }
19709                Ok(res) => {
19710                    let (mut parts, body) = res.into_parts();
19711                    let mut body = common::Body::new(body);
19712                    if !parts.status.is_success() {
19713                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19714                        let error = serde_json::from_str(&common::to_string(&bytes));
19715                        let response = common::to_response(parts, bytes.into());
19716
19717                        if let common::Retry::After(d) =
19718                            dlg.http_failure(&response, error.as_ref().ok())
19719                        {
19720                            sleep(d).await;
19721                            continue;
19722                        }
19723
19724                        dlg.finished(false);
19725
19726                        return Err(match error {
19727                            Ok(value) => common::Error::BadRequest(value),
19728                            _ => common::Error::Failure(response),
19729                        });
19730                    }
19731                    let response = {
19732                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19733                        let encoded = common::to_string(&bytes);
19734                        match serde_json::from_str(&encoded) {
19735                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19736                            Err(error) => {
19737                                dlg.response_json_decode_error(&encoded, &error);
19738                                return Err(common::Error::JsonDecodeError(
19739                                    encoded.to_string(),
19740                                    error,
19741                                ));
19742                            }
19743                        }
19744                    };
19745
19746                    dlg.finished(true);
19747                    return Ok(response);
19748                }
19749            }
19750        }
19751    }
19752
19753    ///
19754    /// Sets the *request* property to the given value.
19755    ///
19756    /// Even though the property as already been set when instantiating this call,
19757    /// we provide this method for API completeness.
19758    pub fn request(
19759        mut self,
19760        new_value: ClientTlsPolicy,
19761    ) -> ProjectLocationClientTlsPolicyCreateCall<'a, C> {
19762        self._request = new_value;
19763        self
19764    }
19765    /// Required. The parent resource of the ClientTlsPolicy. Must be in the format `projects/*/locations/{location}`.
19766    ///
19767    /// Sets the *parent* path property to the given value.
19768    ///
19769    /// Even though the property as already been set when instantiating this call,
19770    /// we provide this method for API completeness.
19771    pub fn parent(mut self, new_value: &str) -> ProjectLocationClientTlsPolicyCreateCall<'a, C> {
19772        self._parent = new_value.to_string();
19773        self
19774    }
19775    /// Required. Short name of the ClientTlsPolicy resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "client_mtls_policy".
19776    ///
19777    /// Sets the *client tls policy id* query property to the given value.
19778    pub fn client_tls_policy_id(
19779        mut self,
19780        new_value: &str,
19781    ) -> ProjectLocationClientTlsPolicyCreateCall<'a, C> {
19782        self._client_tls_policy_id = Some(new_value.to_string());
19783        self
19784    }
19785    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19786    /// while executing the actual API request.
19787    ///
19788    /// ````text
19789    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19790    /// ````
19791    ///
19792    /// Sets the *delegate* property to the given value.
19793    pub fn delegate(
19794        mut self,
19795        new_value: &'a mut dyn common::Delegate,
19796    ) -> ProjectLocationClientTlsPolicyCreateCall<'a, C> {
19797        self._delegate = Some(new_value);
19798        self
19799    }
19800
19801    /// Set any additional parameter of the query string used in the request.
19802    /// It should be used to set parameters which are not yet available through their own
19803    /// setters.
19804    ///
19805    /// Please note that this method must not be used to set any of the known parameters
19806    /// which have their own setter method. If done anyway, the request will fail.
19807    ///
19808    /// # Additional Parameters
19809    ///
19810    /// * *$.xgafv* (query-string) - V1 error format.
19811    /// * *access_token* (query-string) - OAuth access token.
19812    /// * *alt* (query-string) - Data format for response.
19813    /// * *callback* (query-string) - JSONP
19814    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19815    /// * *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.
19816    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19817    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19818    /// * *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.
19819    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19820    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19821    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClientTlsPolicyCreateCall<'a, C>
19822    where
19823        T: AsRef<str>,
19824    {
19825        self._additional_params
19826            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19827        self
19828    }
19829
19830    /// Identifies the authorization scope for the method you are building.
19831    ///
19832    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19833    /// [`Scope::CloudPlatform`].
19834    ///
19835    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19836    /// tokens for more than one scope.
19837    ///
19838    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19839    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19840    /// sufficient, a read-write scope will do as well.
19841    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClientTlsPolicyCreateCall<'a, C>
19842    where
19843        St: AsRef<str>,
19844    {
19845        self._scopes.insert(String::from(scope.as_ref()));
19846        self
19847    }
19848    /// Identifies the authorization scope(s) for the method you are building.
19849    ///
19850    /// See [`Self::add_scope()`] for details.
19851    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClientTlsPolicyCreateCall<'a, C>
19852    where
19853        I: IntoIterator<Item = St>,
19854        St: AsRef<str>,
19855    {
19856        self._scopes
19857            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19858        self
19859    }
19860
19861    /// Removes all scopes, and no default scope will be used either.
19862    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19863    /// for details).
19864    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyCreateCall<'a, C> {
19865        self._scopes.clear();
19866        self
19867    }
19868}
19869
19870/// Deletes a single ClientTlsPolicy.
19871///
19872/// A builder for the *locations.clientTlsPolicies.delete* method supported by a *project* resource.
19873/// It is not used directly, but through a [`ProjectMethods`] instance.
19874///
19875/// # Example
19876///
19877/// Instantiate a resource method builder
19878///
19879/// ```test_harness,no_run
19880/// # extern crate hyper;
19881/// # extern crate hyper_rustls;
19882/// # extern crate google_networksecurity1 as networksecurity1;
19883/// # async fn dox() {
19884/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19885///
19886/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19887/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19888/// #     secret,
19889/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19890/// # ).build().await.unwrap();
19891///
19892/// # let client = hyper_util::client::legacy::Client::builder(
19893/// #     hyper_util::rt::TokioExecutor::new()
19894/// # )
19895/// # .build(
19896/// #     hyper_rustls::HttpsConnectorBuilder::new()
19897/// #         .with_native_roots()
19898/// #         .unwrap()
19899/// #         .https_or_http()
19900/// #         .enable_http1()
19901/// #         .build()
19902/// # );
19903/// # let mut hub = NetworkSecurity::new(client, auth);
19904/// // You can configure optional parameters by calling the respective setters at will, and
19905/// // execute the final call using `doit()`.
19906/// // Values shown here are possibly random and not representative !
19907/// let result = hub.projects().locations_client_tls_policies_delete("name")
19908///              .doit().await;
19909/// # }
19910/// ```
19911pub struct ProjectLocationClientTlsPolicyDeleteCall<'a, C>
19912where
19913    C: 'a,
19914{
19915    hub: &'a NetworkSecurity<C>,
19916    _name: String,
19917    _delegate: Option<&'a mut dyn common::Delegate>,
19918    _additional_params: HashMap<String, String>,
19919    _scopes: BTreeSet<String>,
19920}
19921
19922impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyDeleteCall<'a, C> {}
19923
19924impl<'a, C> ProjectLocationClientTlsPolicyDeleteCall<'a, C>
19925where
19926    C: common::Connector,
19927{
19928    /// Perform the operation you have build so far.
19929    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19930        use std::borrow::Cow;
19931        use std::io::{Read, Seek};
19932
19933        use common::{url::Params, ToParts};
19934        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19935
19936        let mut dd = common::DefaultDelegate;
19937        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19938        dlg.begin(common::MethodInfo {
19939            id: "networksecurity.projects.locations.clientTlsPolicies.delete",
19940            http_method: hyper::Method::DELETE,
19941        });
19942
19943        for &field in ["alt", "name"].iter() {
19944            if self._additional_params.contains_key(field) {
19945                dlg.finished(false);
19946                return Err(common::Error::FieldClash(field));
19947            }
19948        }
19949
19950        let mut params = Params::with_capacity(3 + self._additional_params.len());
19951        params.push("name", self._name);
19952
19953        params.extend(self._additional_params.iter());
19954
19955        params.push("alt", "json");
19956        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19957        if self._scopes.is_empty() {
19958            self._scopes
19959                .insert(Scope::CloudPlatform.as_ref().to_string());
19960        }
19961
19962        #[allow(clippy::single_element_loop)]
19963        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19964            url = params.uri_replacement(url, param_name, find_this, true);
19965        }
19966        {
19967            let to_remove = ["name"];
19968            params.remove_params(&to_remove);
19969        }
19970
19971        let url = params.parse_with_url(&url);
19972
19973        loop {
19974            let token = match self
19975                .hub
19976                .auth
19977                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19978                .await
19979            {
19980                Ok(token) => token,
19981                Err(e) => match dlg.token(e) {
19982                    Ok(token) => token,
19983                    Err(e) => {
19984                        dlg.finished(false);
19985                        return Err(common::Error::MissingToken(e));
19986                    }
19987                },
19988            };
19989            let mut req_result = {
19990                let client = &self.hub.client;
19991                dlg.pre_request();
19992                let mut req_builder = hyper::Request::builder()
19993                    .method(hyper::Method::DELETE)
19994                    .uri(url.as_str())
19995                    .header(USER_AGENT, self.hub._user_agent.clone());
19996
19997                if let Some(token) = token.as_ref() {
19998                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19999                }
20000
20001                let request = req_builder
20002                    .header(CONTENT_LENGTH, 0_u64)
20003                    .body(common::to_body::<String>(None));
20004
20005                client.request(request.unwrap()).await
20006            };
20007
20008            match req_result {
20009                Err(err) => {
20010                    if let common::Retry::After(d) = dlg.http_error(&err) {
20011                        sleep(d).await;
20012                        continue;
20013                    }
20014                    dlg.finished(false);
20015                    return Err(common::Error::HttpError(err));
20016                }
20017                Ok(res) => {
20018                    let (mut parts, body) = res.into_parts();
20019                    let mut body = common::Body::new(body);
20020                    if !parts.status.is_success() {
20021                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20022                        let error = serde_json::from_str(&common::to_string(&bytes));
20023                        let response = common::to_response(parts, bytes.into());
20024
20025                        if let common::Retry::After(d) =
20026                            dlg.http_failure(&response, error.as_ref().ok())
20027                        {
20028                            sleep(d).await;
20029                            continue;
20030                        }
20031
20032                        dlg.finished(false);
20033
20034                        return Err(match error {
20035                            Ok(value) => common::Error::BadRequest(value),
20036                            _ => common::Error::Failure(response),
20037                        });
20038                    }
20039                    let response = {
20040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20041                        let encoded = common::to_string(&bytes);
20042                        match serde_json::from_str(&encoded) {
20043                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20044                            Err(error) => {
20045                                dlg.response_json_decode_error(&encoded, &error);
20046                                return Err(common::Error::JsonDecodeError(
20047                                    encoded.to_string(),
20048                                    error,
20049                                ));
20050                            }
20051                        }
20052                    };
20053
20054                    dlg.finished(true);
20055                    return Ok(response);
20056                }
20057            }
20058        }
20059    }
20060
20061    /// Required. A name of the ClientTlsPolicy to delete. Must be in the format `projects/*/locations/{location}/clientTlsPolicies/*`.
20062    ///
20063    /// Sets the *name* path property to the given value.
20064    ///
20065    /// Even though the property as already been set when instantiating this call,
20066    /// we provide this method for API completeness.
20067    pub fn name(mut self, new_value: &str) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C> {
20068        self._name = new_value.to_string();
20069        self
20070    }
20071    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20072    /// while executing the actual API request.
20073    ///
20074    /// ````text
20075    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20076    /// ````
20077    ///
20078    /// Sets the *delegate* property to the given value.
20079    pub fn delegate(
20080        mut self,
20081        new_value: &'a mut dyn common::Delegate,
20082    ) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C> {
20083        self._delegate = Some(new_value);
20084        self
20085    }
20086
20087    /// Set any additional parameter of the query string used in the request.
20088    /// It should be used to set parameters which are not yet available through their own
20089    /// setters.
20090    ///
20091    /// Please note that this method must not be used to set any of the known parameters
20092    /// which have their own setter method. If done anyway, the request will fail.
20093    ///
20094    /// # Additional Parameters
20095    ///
20096    /// * *$.xgafv* (query-string) - V1 error format.
20097    /// * *access_token* (query-string) - OAuth access token.
20098    /// * *alt* (query-string) - Data format for response.
20099    /// * *callback* (query-string) - JSONP
20100    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20101    /// * *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.
20102    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20103    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20104    /// * *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.
20105    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20106    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20107    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C>
20108    where
20109        T: AsRef<str>,
20110    {
20111        self._additional_params
20112            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20113        self
20114    }
20115
20116    /// Identifies the authorization scope for the method you are building.
20117    ///
20118    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20119    /// [`Scope::CloudPlatform`].
20120    ///
20121    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20122    /// tokens for more than one scope.
20123    ///
20124    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20125    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20126    /// sufficient, a read-write scope will do as well.
20127    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C>
20128    where
20129        St: AsRef<str>,
20130    {
20131        self._scopes.insert(String::from(scope.as_ref()));
20132        self
20133    }
20134    /// Identifies the authorization scope(s) for the method you are building.
20135    ///
20136    /// See [`Self::add_scope()`] for details.
20137    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C>
20138    where
20139        I: IntoIterator<Item = St>,
20140        St: AsRef<str>,
20141    {
20142        self._scopes
20143            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20144        self
20145    }
20146
20147    /// Removes all scopes, and no default scope will be used either.
20148    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20149    /// for details).
20150    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyDeleteCall<'a, C> {
20151        self._scopes.clear();
20152        self
20153    }
20154}
20155
20156/// Gets details of a single ClientTlsPolicy.
20157///
20158/// A builder for the *locations.clientTlsPolicies.get* method supported by a *project* resource.
20159/// It is not used directly, but through a [`ProjectMethods`] instance.
20160///
20161/// # Example
20162///
20163/// Instantiate a resource method builder
20164///
20165/// ```test_harness,no_run
20166/// # extern crate hyper;
20167/// # extern crate hyper_rustls;
20168/// # extern crate google_networksecurity1 as networksecurity1;
20169/// # async fn dox() {
20170/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20171///
20172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20173/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20174/// #     secret,
20175/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20176/// # ).build().await.unwrap();
20177///
20178/// # let client = hyper_util::client::legacy::Client::builder(
20179/// #     hyper_util::rt::TokioExecutor::new()
20180/// # )
20181/// # .build(
20182/// #     hyper_rustls::HttpsConnectorBuilder::new()
20183/// #         .with_native_roots()
20184/// #         .unwrap()
20185/// #         .https_or_http()
20186/// #         .enable_http1()
20187/// #         .build()
20188/// # );
20189/// # let mut hub = NetworkSecurity::new(client, auth);
20190/// // You can configure optional parameters by calling the respective setters at will, and
20191/// // execute the final call using `doit()`.
20192/// // Values shown here are possibly random and not representative !
20193/// let result = hub.projects().locations_client_tls_policies_get("name")
20194///              .doit().await;
20195/// # }
20196/// ```
20197pub struct ProjectLocationClientTlsPolicyGetCall<'a, C>
20198where
20199    C: 'a,
20200{
20201    hub: &'a NetworkSecurity<C>,
20202    _name: String,
20203    _delegate: Option<&'a mut dyn common::Delegate>,
20204    _additional_params: HashMap<String, String>,
20205    _scopes: BTreeSet<String>,
20206}
20207
20208impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyGetCall<'a, C> {}
20209
20210impl<'a, C> ProjectLocationClientTlsPolicyGetCall<'a, C>
20211where
20212    C: common::Connector,
20213{
20214    /// Perform the operation you have build so far.
20215    pub async fn doit(mut self) -> common::Result<(common::Response, ClientTlsPolicy)> {
20216        use std::borrow::Cow;
20217        use std::io::{Read, Seek};
20218
20219        use common::{url::Params, ToParts};
20220        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20221
20222        let mut dd = common::DefaultDelegate;
20223        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20224        dlg.begin(common::MethodInfo {
20225            id: "networksecurity.projects.locations.clientTlsPolicies.get",
20226            http_method: hyper::Method::GET,
20227        });
20228
20229        for &field in ["alt", "name"].iter() {
20230            if self._additional_params.contains_key(field) {
20231                dlg.finished(false);
20232                return Err(common::Error::FieldClash(field));
20233            }
20234        }
20235
20236        let mut params = Params::with_capacity(3 + self._additional_params.len());
20237        params.push("name", self._name);
20238
20239        params.extend(self._additional_params.iter());
20240
20241        params.push("alt", "json");
20242        let mut url = self.hub._base_url.clone() + "v1/{+name}";
20243        if self._scopes.is_empty() {
20244            self._scopes
20245                .insert(Scope::CloudPlatform.as_ref().to_string());
20246        }
20247
20248        #[allow(clippy::single_element_loop)]
20249        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20250            url = params.uri_replacement(url, param_name, find_this, true);
20251        }
20252        {
20253            let to_remove = ["name"];
20254            params.remove_params(&to_remove);
20255        }
20256
20257        let url = params.parse_with_url(&url);
20258
20259        loop {
20260            let token = match self
20261                .hub
20262                .auth
20263                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20264                .await
20265            {
20266                Ok(token) => token,
20267                Err(e) => match dlg.token(e) {
20268                    Ok(token) => token,
20269                    Err(e) => {
20270                        dlg.finished(false);
20271                        return Err(common::Error::MissingToken(e));
20272                    }
20273                },
20274            };
20275            let mut req_result = {
20276                let client = &self.hub.client;
20277                dlg.pre_request();
20278                let mut req_builder = hyper::Request::builder()
20279                    .method(hyper::Method::GET)
20280                    .uri(url.as_str())
20281                    .header(USER_AGENT, self.hub._user_agent.clone());
20282
20283                if let Some(token) = token.as_ref() {
20284                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20285                }
20286
20287                let request = req_builder
20288                    .header(CONTENT_LENGTH, 0_u64)
20289                    .body(common::to_body::<String>(None));
20290
20291                client.request(request.unwrap()).await
20292            };
20293
20294            match req_result {
20295                Err(err) => {
20296                    if let common::Retry::After(d) = dlg.http_error(&err) {
20297                        sleep(d).await;
20298                        continue;
20299                    }
20300                    dlg.finished(false);
20301                    return Err(common::Error::HttpError(err));
20302                }
20303                Ok(res) => {
20304                    let (mut parts, body) = res.into_parts();
20305                    let mut body = common::Body::new(body);
20306                    if !parts.status.is_success() {
20307                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20308                        let error = serde_json::from_str(&common::to_string(&bytes));
20309                        let response = common::to_response(parts, bytes.into());
20310
20311                        if let common::Retry::After(d) =
20312                            dlg.http_failure(&response, error.as_ref().ok())
20313                        {
20314                            sleep(d).await;
20315                            continue;
20316                        }
20317
20318                        dlg.finished(false);
20319
20320                        return Err(match error {
20321                            Ok(value) => common::Error::BadRequest(value),
20322                            _ => common::Error::Failure(response),
20323                        });
20324                    }
20325                    let response = {
20326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20327                        let encoded = common::to_string(&bytes);
20328                        match serde_json::from_str(&encoded) {
20329                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20330                            Err(error) => {
20331                                dlg.response_json_decode_error(&encoded, &error);
20332                                return Err(common::Error::JsonDecodeError(
20333                                    encoded.to_string(),
20334                                    error,
20335                                ));
20336                            }
20337                        }
20338                    };
20339
20340                    dlg.finished(true);
20341                    return Ok(response);
20342                }
20343            }
20344        }
20345    }
20346
20347    /// Required. A name of the ClientTlsPolicy to get. Must be in the format `projects/*/locations/{location}/clientTlsPolicies/*`.
20348    ///
20349    /// Sets the *name* path property to the given value.
20350    ///
20351    /// Even though the property as already been set when instantiating this call,
20352    /// we provide this method for API completeness.
20353    pub fn name(mut self, new_value: &str) -> ProjectLocationClientTlsPolicyGetCall<'a, C> {
20354        self._name = new_value.to_string();
20355        self
20356    }
20357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20358    /// while executing the actual API request.
20359    ///
20360    /// ````text
20361    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20362    /// ````
20363    ///
20364    /// Sets the *delegate* property to the given value.
20365    pub fn delegate(
20366        mut self,
20367        new_value: &'a mut dyn common::Delegate,
20368    ) -> ProjectLocationClientTlsPolicyGetCall<'a, C> {
20369        self._delegate = Some(new_value);
20370        self
20371    }
20372
20373    /// Set any additional parameter of the query string used in the request.
20374    /// It should be used to set parameters which are not yet available through their own
20375    /// setters.
20376    ///
20377    /// Please note that this method must not be used to set any of the known parameters
20378    /// which have their own setter method. If done anyway, the request will fail.
20379    ///
20380    /// # Additional Parameters
20381    ///
20382    /// * *$.xgafv* (query-string) - V1 error format.
20383    /// * *access_token* (query-string) - OAuth access token.
20384    /// * *alt* (query-string) - Data format for response.
20385    /// * *callback* (query-string) - JSONP
20386    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20387    /// * *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.
20388    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20389    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20390    /// * *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.
20391    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20392    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20393    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClientTlsPolicyGetCall<'a, C>
20394    where
20395        T: AsRef<str>,
20396    {
20397        self._additional_params
20398            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20399        self
20400    }
20401
20402    /// Identifies the authorization scope for the method you are building.
20403    ///
20404    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20405    /// [`Scope::CloudPlatform`].
20406    ///
20407    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20408    /// tokens for more than one scope.
20409    ///
20410    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20411    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20412    /// sufficient, a read-write scope will do as well.
20413    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClientTlsPolicyGetCall<'a, C>
20414    where
20415        St: AsRef<str>,
20416    {
20417        self._scopes.insert(String::from(scope.as_ref()));
20418        self
20419    }
20420    /// Identifies the authorization scope(s) for the method you are building.
20421    ///
20422    /// See [`Self::add_scope()`] for details.
20423    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClientTlsPolicyGetCall<'a, C>
20424    where
20425        I: IntoIterator<Item = St>,
20426        St: AsRef<str>,
20427    {
20428        self._scopes
20429            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20430        self
20431    }
20432
20433    /// Removes all scopes, and no default scope will be used either.
20434    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20435    /// for details).
20436    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyGetCall<'a, C> {
20437        self._scopes.clear();
20438        self
20439    }
20440}
20441
20442/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
20443///
20444/// A builder for the *locations.clientTlsPolicies.getIamPolicy* method supported by a *project* resource.
20445/// It is not used directly, but through a [`ProjectMethods`] instance.
20446///
20447/// # Example
20448///
20449/// Instantiate a resource method builder
20450///
20451/// ```test_harness,no_run
20452/// # extern crate hyper;
20453/// # extern crate hyper_rustls;
20454/// # extern crate google_networksecurity1 as networksecurity1;
20455/// # async fn dox() {
20456/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20457///
20458/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20459/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20460/// #     secret,
20461/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20462/// # ).build().await.unwrap();
20463///
20464/// # let client = hyper_util::client::legacy::Client::builder(
20465/// #     hyper_util::rt::TokioExecutor::new()
20466/// # )
20467/// # .build(
20468/// #     hyper_rustls::HttpsConnectorBuilder::new()
20469/// #         .with_native_roots()
20470/// #         .unwrap()
20471/// #         .https_or_http()
20472/// #         .enable_http1()
20473/// #         .build()
20474/// # );
20475/// # let mut hub = NetworkSecurity::new(client, auth);
20476/// // You can configure optional parameters by calling the respective setters at will, and
20477/// // execute the final call using `doit()`.
20478/// // Values shown here are possibly random and not representative !
20479/// let result = hub.projects().locations_client_tls_policies_get_iam_policy("resource")
20480///              .options_requested_policy_version(-43)
20481///              .doit().await;
20482/// # }
20483/// ```
20484pub struct ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C>
20485where
20486    C: 'a,
20487{
20488    hub: &'a NetworkSecurity<C>,
20489    _resource: String,
20490    _options_requested_policy_version: Option<i32>,
20491    _delegate: Option<&'a mut dyn common::Delegate>,
20492    _additional_params: HashMap<String, String>,
20493    _scopes: BTreeSet<String>,
20494}
20495
20496impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C> {}
20497
20498impl<'a, C> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C>
20499where
20500    C: common::Connector,
20501{
20502    /// Perform the operation you have build so far.
20503    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
20504        use std::borrow::Cow;
20505        use std::io::{Read, Seek};
20506
20507        use common::{url::Params, ToParts};
20508        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20509
20510        let mut dd = common::DefaultDelegate;
20511        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20512        dlg.begin(common::MethodInfo {
20513            id: "networksecurity.projects.locations.clientTlsPolicies.getIamPolicy",
20514            http_method: hyper::Method::GET,
20515        });
20516
20517        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
20518            if self._additional_params.contains_key(field) {
20519                dlg.finished(false);
20520                return Err(common::Error::FieldClash(field));
20521            }
20522        }
20523
20524        let mut params = Params::with_capacity(4 + self._additional_params.len());
20525        params.push("resource", self._resource);
20526        if let Some(value) = self._options_requested_policy_version.as_ref() {
20527            params.push("options.requestedPolicyVersion", value.to_string());
20528        }
20529
20530        params.extend(self._additional_params.iter());
20531
20532        params.push("alt", "json");
20533        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
20534        if self._scopes.is_empty() {
20535            self._scopes
20536                .insert(Scope::CloudPlatform.as_ref().to_string());
20537        }
20538
20539        #[allow(clippy::single_element_loop)]
20540        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
20541            url = params.uri_replacement(url, param_name, find_this, true);
20542        }
20543        {
20544            let to_remove = ["resource"];
20545            params.remove_params(&to_remove);
20546        }
20547
20548        let url = params.parse_with_url(&url);
20549
20550        loop {
20551            let token = match self
20552                .hub
20553                .auth
20554                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20555                .await
20556            {
20557                Ok(token) => token,
20558                Err(e) => match dlg.token(e) {
20559                    Ok(token) => token,
20560                    Err(e) => {
20561                        dlg.finished(false);
20562                        return Err(common::Error::MissingToken(e));
20563                    }
20564                },
20565            };
20566            let mut req_result = {
20567                let client = &self.hub.client;
20568                dlg.pre_request();
20569                let mut req_builder = hyper::Request::builder()
20570                    .method(hyper::Method::GET)
20571                    .uri(url.as_str())
20572                    .header(USER_AGENT, self.hub._user_agent.clone());
20573
20574                if let Some(token) = token.as_ref() {
20575                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20576                }
20577
20578                let request = req_builder
20579                    .header(CONTENT_LENGTH, 0_u64)
20580                    .body(common::to_body::<String>(None));
20581
20582                client.request(request.unwrap()).await
20583            };
20584
20585            match req_result {
20586                Err(err) => {
20587                    if let common::Retry::After(d) = dlg.http_error(&err) {
20588                        sleep(d).await;
20589                        continue;
20590                    }
20591                    dlg.finished(false);
20592                    return Err(common::Error::HttpError(err));
20593                }
20594                Ok(res) => {
20595                    let (mut parts, body) = res.into_parts();
20596                    let mut body = common::Body::new(body);
20597                    if !parts.status.is_success() {
20598                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20599                        let error = serde_json::from_str(&common::to_string(&bytes));
20600                        let response = common::to_response(parts, bytes.into());
20601
20602                        if let common::Retry::After(d) =
20603                            dlg.http_failure(&response, error.as_ref().ok())
20604                        {
20605                            sleep(d).await;
20606                            continue;
20607                        }
20608
20609                        dlg.finished(false);
20610
20611                        return Err(match error {
20612                            Ok(value) => common::Error::BadRequest(value),
20613                            _ => common::Error::Failure(response),
20614                        });
20615                    }
20616                    let response = {
20617                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20618                        let encoded = common::to_string(&bytes);
20619                        match serde_json::from_str(&encoded) {
20620                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20621                            Err(error) => {
20622                                dlg.response_json_decode_error(&encoded, &error);
20623                                return Err(common::Error::JsonDecodeError(
20624                                    encoded.to_string(),
20625                                    error,
20626                                ));
20627                            }
20628                        }
20629                    };
20630
20631                    dlg.finished(true);
20632                    return Ok(response);
20633                }
20634            }
20635        }
20636    }
20637
20638    /// 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.
20639    ///
20640    /// Sets the *resource* path property to the given value.
20641    ///
20642    /// Even though the property as already been set when instantiating this call,
20643    /// we provide this method for API completeness.
20644    pub fn resource(
20645        mut self,
20646        new_value: &str,
20647    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C> {
20648        self._resource = new_value.to_string();
20649        self
20650    }
20651    /// 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).
20652    ///
20653    /// Sets the *options.requested policy version* query property to the given value.
20654    pub fn options_requested_policy_version(
20655        mut self,
20656        new_value: i32,
20657    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C> {
20658        self._options_requested_policy_version = Some(new_value);
20659        self
20660    }
20661    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20662    /// while executing the actual API request.
20663    ///
20664    /// ````text
20665    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20666    /// ````
20667    ///
20668    /// Sets the *delegate* property to the given value.
20669    pub fn delegate(
20670        mut self,
20671        new_value: &'a mut dyn common::Delegate,
20672    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C> {
20673        self._delegate = Some(new_value);
20674        self
20675    }
20676
20677    /// Set any additional parameter of the query string used in the request.
20678    /// It should be used to set parameters which are not yet available through their own
20679    /// setters.
20680    ///
20681    /// Please note that this method must not be used to set any of the known parameters
20682    /// which have their own setter method. If done anyway, the request will fail.
20683    ///
20684    /// # Additional Parameters
20685    ///
20686    /// * *$.xgafv* (query-string) - V1 error format.
20687    /// * *access_token* (query-string) - OAuth access token.
20688    /// * *alt* (query-string) - Data format for response.
20689    /// * *callback* (query-string) - JSONP
20690    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20691    /// * *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.
20692    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20693    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20694    /// * *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.
20695    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20696    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20697    pub fn param<T>(
20698        mut self,
20699        name: T,
20700        value: T,
20701    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C>
20702    where
20703        T: AsRef<str>,
20704    {
20705        self._additional_params
20706            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20707        self
20708    }
20709
20710    /// Identifies the authorization scope for the method you are building.
20711    ///
20712    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20713    /// [`Scope::CloudPlatform`].
20714    ///
20715    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20716    /// tokens for more than one scope.
20717    ///
20718    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20719    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20720    /// sufficient, a read-write scope will do as well.
20721    pub fn add_scope<St>(
20722        mut self,
20723        scope: St,
20724    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C>
20725    where
20726        St: AsRef<str>,
20727    {
20728        self._scopes.insert(String::from(scope.as_ref()));
20729        self
20730    }
20731    /// Identifies the authorization scope(s) for the method you are building.
20732    ///
20733    /// See [`Self::add_scope()`] for details.
20734    pub fn add_scopes<I, St>(
20735        mut self,
20736        scopes: I,
20737    ) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C>
20738    where
20739        I: IntoIterator<Item = St>,
20740        St: AsRef<str>,
20741    {
20742        self._scopes
20743            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20744        self
20745    }
20746
20747    /// Removes all scopes, and no default scope will be used either.
20748    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20749    /// for details).
20750    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyGetIamPolicyCall<'a, C> {
20751        self._scopes.clear();
20752        self
20753    }
20754}
20755
20756/// Lists ClientTlsPolicies in a given project and location.
20757///
20758/// A builder for the *locations.clientTlsPolicies.list* method supported by a *project* resource.
20759/// It is not used directly, but through a [`ProjectMethods`] instance.
20760///
20761/// # Example
20762///
20763/// Instantiate a resource method builder
20764///
20765/// ```test_harness,no_run
20766/// # extern crate hyper;
20767/// # extern crate hyper_rustls;
20768/// # extern crate google_networksecurity1 as networksecurity1;
20769/// # async fn dox() {
20770/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20771///
20772/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20773/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20774/// #     secret,
20775/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20776/// # ).build().await.unwrap();
20777///
20778/// # let client = hyper_util::client::legacy::Client::builder(
20779/// #     hyper_util::rt::TokioExecutor::new()
20780/// # )
20781/// # .build(
20782/// #     hyper_rustls::HttpsConnectorBuilder::new()
20783/// #         .with_native_roots()
20784/// #         .unwrap()
20785/// #         .https_or_http()
20786/// #         .enable_http1()
20787/// #         .build()
20788/// # );
20789/// # let mut hub = NetworkSecurity::new(client, auth);
20790/// // You can configure optional parameters by calling the respective setters at will, and
20791/// // execute the final call using `doit()`.
20792/// // Values shown here are possibly random and not representative !
20793/// let result = hub.projects().locations_client_tls_policies_list("parent")
20794///              .page_token("et")
20795///              .page_size(-39)
20796///              .doit().await;
20797/// # }
20798/// ```
20799pub struct ProjectLocationClientTlsPolicyListCall<'a, C>
20800where
20801    C: 'a,
20802{
20803    hub: &'a NetworkSecurity<C>,
20804    _parent: String,
20805    _page_token: Option<String>,
20806    _page_size: Option<i32>,
20807    _delegate: Option<&'a mut dyn common::Delegate>,
20808    _additional_params: HashMap<String, String>,
20809    _scopes: BTreeSet<String>,
20810}
20811
20812impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyListCall<'a, C> {}
20813
20814impl<'a, C> ProjectLocationClientTlsPolicyListCall<'a, C>
20815where
20816    C: common::Connector,
20817{
20818    /// Perform the operation you have build so far.
20819    pub async fn doit(
20820        mut self,
20821    ) -> common::Result<(common::Response, ListClientTlsPoliciesResponse)> {
20822        use std::borrow::Cow;
20823        use std::io::{Read, Seek};
20824
20825        use common::{url::Params, ToParts};
20826        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20827
20828        let mut dd = common::DefaultDelegate;
20829        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20830        dlg.begin(common::MethodInfo {
20831            id: "networksecurity.projects.locations.clientTlsPolicies.list",
20832            http_method: hyper::Method::GET,
20833        });
20834
20835        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
20836            if self._additional_params.contains_key(field) {
20837                dlg.finished(false);
20838                return Err(common::Error::FieldClash(field));
20839            }
20840        }
20841
20842        let mut params = Params::with_capacity(5 + self._additional_params.len());
20843        params.push("parent", self._parent);
20844        if let Some(value) = self._page_token.as_ref() {
20845            params.push("pageToken", value);
20846        }
20847        if let Some(value) = self._page_size.as_ref() {
20848            params.push("pageSize", value.to_string());
20849        }
20850
20851        params.extend(self._additional_params.iter());
20852
20853        params.push("alt", "json");
20854        let mut url = self.hub._base_url.clone() + "v1/{+parent}/clientTlsPolicies";
20855        if self._scopes.is_empty() {
20856            self._scopes
20857                .insert(Scope::CloudPlatform.as_ref().to_string());
20858        }
20859
20860        #[allow(clippy::single_element_loop)]
20861        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20862            url = params.uri_replacement(url, param_name, find_this, true);
20863        }
20864        {
20865            let to_remove = ["parent"];
20866            params.remove_params(&to_remove);
20867        }
20868
20869        let url = params.parse_with_url(&url);
20870
20871        loop {
20872            let token = match self
20873                .hub
20874                .auth
20875                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20876                .await
20877            {
20878                Ok(token) => token,
20879                Err(e) => match dlg.token(e) {
20880                    Ok(token) => token,
20881                    Err(e) => {
20882                        dlg.finished(false);
20883                        return Err(common::Error::MissingToken(e));
20884                    }
20885                },
20886            };
20887            let mut req_result = {
20888                let client = &self.hub.client;
20889                dlg.pre_request();
20890                let mut req_builder = hyper::Request::builder()
20891                    .method(hyper::Method::GET)
20892                    .uri(url.as_str())
20893                    .header(USER_AGENT, self.hub._user_agent.clone());
20894
20895                if let Some(token) = token.as_ref() {
20896                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20897                }
20898
20899                let request = req_builder
20900                    .header(CONTENT_LENGTH, 0_u64)
20901                    .body(common::to_body::<String>(None));
20902
20903                client.request(request.unwrap()).await
20904            };
20905
20906            match req_result {
20907                Err(err) => {
20908                    if let common::Retry::After(d) = dlg.http_error(&err) {
20909                        sleep(d).await;
20910                        continue;
20911                    }
20912                    dlg.finished(false);
20913                    return Err(common::Error::HttpError(err));
20914                }
20915                Ok(res) => {
20916                    let (mut parts, body) = res.into_parts();
20917                    let mut body = common::Body::new(body);
20918                    if !parts.status.is_success() {
20919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20920                        let error = serde_json::from_str(&common::to_string(&bytes));
20921                        let response = common::to_response(parts, bytes.into());
20922
20923                        if let common::Retry::After(d) =
20924                            dlg.http_failure(&response, error.as_ref().ok())
20925                        {
20926                            sleep(d).await;
20927                            continue;
20928                        }
20929
20930                        dlg.finished(false);
20931
20932                        return Err(match error {
20933                            Ok(value) => common::Error::BadRequest(value),
20934                            _ => common::Error::Failure(response),
20935                        });
20936                    }
20937                    let response = {
20938                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20939                        let encoded = common::to_string(&bytes);
20940                        match serde_json::from_str(&encoded) {
20941                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20942                            Err(error) => {
20943                                dlg.response_json_decode_error(&encoded, &error);
20944                                return Err(common::Error::JsonDecodeError(
20945                                    encoded.to_string(),
20946                                    error,
20947                                ));
20948                            }
20949                        }
20950                    };
20951
20952                    dlg.finished(true);
20953                    return Ok(response);
20954                }
20955            }
20956        }
20957    }
20958
20959    /// Required. The project and location from which the ClientTlsPolicies should be listed, specified in the format `projects/*/locations/{location}`.
20960    ///
20961    /// Sets the *parent* path property to the given value.
20962    ///
20963    /// Even though the property as already been set when instantiating this call,
20964    /// we provide this method for API completeness.
20965    pub fn parent(mut self, new_value: &str) -> ProjectLocationClientTlsPolicyListCall<'a, C> {
20966        self._parent = new_value.to_string();
20967        self
20968    }
20969    /// The value returned by the last `ListClientTlsPoliciesResponse` Indicates that this is a continuation of a prior `ListClientTlsPolicies` call, and that the system should return the next page of data.
20970    ///
20971    /// Sets the *page token* query property to the given value.
20972    pub fn page_token(mut self, new_value: &str) -> ProjectLocationClientTlsPolicyListCall<'a, C> {
20973        self._page_token = Some(new_value.to_string());
20974        self
20975    }
20976    /// Maximum number of ClientTlsPolicies to return per call.
20977    ///
20978    /// Sets the *page size* query property to the given value.
20979    pub fn page_size(mut self, new_value: i32) -> ProjectLocationClientTlsPolicyListCall<'a, C> {
20980        self._page_size = Some(new_value);
20981        self
20982    }
20983    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20984    /// while executing the actual API request.
20985    ///
20986    /// ````text
20987    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20988    /// ````
20989    ///
20990    /// Sets the *delegate* property to the given value.
20991    pub fn delegate(
20992        mut self,
20993        new_value: &'a mut dyn common::Delegate,
20994    ) -> ProjectLocationClientTlsPolicyListCall<'a, C> {
20995        self._delegate = Some(new_value);
20996        self
20997    }
20998
20999    /// Set any additional parameter of the query string used in the request.
21000    /// It should be used to set parameters which are not yet available through their own
21001    /// setters.
21002    ///
21003    /// Please note that this method must not be used to set any of the known parameters
21004    /// which have their own setter method. If done anyway, the request will fail.
21005    ///
21006    /// # Additional Parameters
21007    ///
21008    /// * *$.xgafv* (query-string) - V1 error format.
21009    /// * *access_token* (query-string) - OAuth access token.
21010    /// * *alt* (query-string) - Data format for response.
21011    /// * *callback* (query-string) - JSONP
21012    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21013    /// * *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.
21014    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21015    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21016    /// * *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.
21017    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21018    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21019    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClientTlsPolicyListCall<'a, C>
21020    where
21021        T: AsRef<str>,
21022    {
21023        self._additional_params
21024            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21025        self
21026    }
21027
21028    /// Identifies the authorization scope for the method you are building.
21029    ///
21030    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21031    /// [`Scope::CloudPlatform`].
21032    ///
21033    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21034    /// tokens for more than one scope.
21035    ///
21036    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21037    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21038    /// sufficient, a read-write scope will do as well.
21039    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClientTlsPolicyListCall<'a, C>
21040    where
21041        St: AsRef<str>,
21042    {
21043        self._scopes.insert(String::from(scope.as_ref()));
21044        self
21045    }
21046    /// Identifies the authorization scope(s) for the method you are building.
21047    ///
21048    /// See [`Self::add_scope()`] for details.
21049    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClientTlsPolicyListCall<'a, C>
21050    where
21051        I: IntoIterator<Item = St>,
21052        St: AsRef<str>,
21053    {
21054        self._scopes
21055            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21056        self
21057    }
21058
21059    /// Removes all scopes, and no default scope will be used either.
21060    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21061    /// for details).
21062    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyListCall<'a, C> {
21063        self._scopes.clear();
21064        self
21065    }
21066}
21067
21068/// Updates the parameters of a single ClientTlsPolicy.
21069///
21070/// A builder for the *locations.clientTlsPolicies.patch* method supported by a *project* resource.
21071/// It is not used directly, but through a [`ProjectMethods`] instance.
21072///
21073/// # Example
21074///
21075/// Instantiate a resource method builder
21076///
21077/// ```test_harness,no_run
21078/// # extern crate hyper;
21079/// # extern crate hyper_rustls;
21080/// # extern crate google_networksecurity1 as networksecurity1;
21081/// use networksecurity1::api::ClientTlsPolicy;
21082/// # async fn dox() {
21083/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21084///
21085/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21087/// #     secret,
21088/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21089/// # ).build().await.unwrap();
21090///
21091/// # let client = hyper_util::client::legacy::Client::builder(
21092/// #     hyper_util::rt::TokioExecutor::new()
21093/// # )
21094/// # .build(
21095/// #     hyper_rustls::HttpsConnectorBuilder::new()
21096/// #         .with_native_roots()
21097/// #         .unwrap()
21098/// #         .https_or_http()
21099/// #         .enable_http1()
21100/// #         .build()
21101/// # );
21102/// # let mut hub = NetworkSecurity::new(client, auth);
21103/// // As the method needs a request, you would usually fill it with the desired information
21104/// // into the respective structure. Some of the parts shown here might not be applicable !
21105/// // Values shown here are possibly random and not representative !
21106/// let mut req = ClientTlsPolicy::default();
21107///
21108/// // You can configure optional parameters by calling the respective setters at will, and
21109/// // execute the final call using `doit()`.
21110/// // Values shown here are possibly random and not representative !
21111/// let result = hub.projects().locations_client_tls_policies_patch(req, "name")
21112///              .update_mask(FieldMask::new::<&str>(&[]))
21113///              .doit().await;
21114/// # }
21115/// ```
21116pub struct ProjectLocationClientTlsPolicyPatchCall<'a, C>
21117where
21118    C: 'a,
21119{
21120    hub: &'a NetworkSecurity<C>,
21121    _request: ClientTlsPolicy,
21122    _name: String,
21123    _update_mask: Option<common::FieldMask>,
21124    _delegate: Option<&'a mut dyn common::Delegate>,
21125    _additional_params: HashMap<String, String>,
21126    _scopes: BTreeSet<String>,
21127}
21128
21129impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyPatchCall<'a, C> {}
21130
21131impl<'a, C> ProjectLocationClientTlsPolicyPatchCall<'a, C>
21132where
21133    C: common::Connector,
21134{
21135    /// Perform the operation you have build so far.
21136    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21137        use std::borrow::Cow;
21138        use std::io::{Read, Seek};
21139
21140        use common::{url::Params, ToParts};
21141        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21142
21143        let mut dd = common::DefaultDelegate;
21144        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21145        dlg.begin(common::MethodInfo {
21146            id: "networksecurity.projects.locations.clientTlsPolicies.patch",
21147            http_method: hyper::Method::PATCH,
21148        });
21149
21150        for &field in ["alt", "name", "updateMask"].iter() {
21151            if self._additional_params.contains_key(field) {
21152                dlg.finished(false);
21153                return Err(common::Error::FieldClash(field));
21154            }
21155        }
21156
21157        let mut params = Params::with_capacity(5 + self._additional_params.len());
21158        params.push("name", self._name);
21159        if let Some(value) = self._update_mask.as_ref() {
21160            params.push("updateMask", value.to_string());
21161        }
21162
21163        params.extend(self._additional_params.iter());
21164
21165        params.push("alt", "json");
21166        let mut url = self.hub._base_url.clone() + "v1/{+name}";
21167        if self._scopes.is_empty() {
21168            self._scopes
21169                .insert(Scope::CloudPlatform.as_ref().to_string());
21170        }
21171
21172        #[allow(clippy::single_element_loop)]
21173        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21174            url = params.uri_replacement(url, param_name, find_this, true);
21175        }
21176        {
21177            let to_remove = ["name"];
21178            params.remove_params(&to_remove);
21179        }
21180
21181        let url = params.parse_with_url(&url);
21182
21183        let mut json_mime_type = mime::APPLICATION_JSON;
21184        let mut request_value_reader = {
21185            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21186            common::remove_json_null_values(&mut value);
21187            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21188            serde_json::to_writer(&mut dst, &value).unwrap();
21189            dst
21190        };
21191        let request_size = request_value_reader
21192            .seek(std::io::SeekFrom::End(0))
21193            .unwrap();
21194        request_value_reader
21195            .seek(std::io::SeekFrom::Start(0))
21196            .unwrap();
21197
21198        loop {
21199            let token = match self
21200                .hub
21201                .auth
21202                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21203                .await
21204            {
21205                Ok(token) => token,
21206                Err(e) => match dlg.token(e) {
21207                    Ok(token) => token,
21208                    Err(e) => {
21209                        dlg.finished(false);
21210                        return Err(common::Error::MissingToken(e));
21211                    }
21212                },
21213            };
21214            request_value_reader
21215                .seek(std::io::SeekFrom::Start(0))
21216                .unwrap();
21217            let mut req_result = {
21218                let client = &self.hub.client;
21219                dlg.pre_request();
21220                let mut req_builder = hyper::Request::builder()
21221                    .method(hyper::Method::PATCH)
21222                    .uri(url.as_str())
21223                    .header(USER_AGENT, self.hub._user_agent.clone());
21224
21225                if let Some(token) = token.as_ref() {
21226                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21227                }
21228
21229                let request = req_builder
21230                    .header(CONTENT_TYPE, json_mime_type.to_string())
21231                    .header(CONTENT_LENGTH, request_size as u64)
21232                    .body(common::to_body(
21233                        request_value_reader.get_ref().clone().into(),
21234                    ));
21235
21236                client.request(request.unwrap()).await
21237            };
21238
21239            match req_result {
21240                Err(err) => {
21241                    if let common::Retry::After(d) = dlg.http_error(&err) {
21242                        sleep(d).await;
21243                        continue;
21244                    }
21245                    dlg.finished(false);
21246                    return Err(common::Error::HttpError(err));
21247                }
21248                Ok(res) => {
21249                    let (mut parts, body) = res.into_parts();
21250                    let mut body = common::Body::new(body);
21251                    if !parts.status.is_success() {
21252                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21253                        let error = serde_json::from_str(&common::to_string(&bytes));
21254                        let response = common::to_response(parts, bytes.into());
21255
21256                        if let common::Retry::After(d) =
21257                            dlg.http_failure(&response, error.as_ref().ok())
21258                        {
21259                            sleep(d).await;
21260                            continue;
21261                        }
21262
21263                        dlg.finished(false);
21264
21265                        return Err(match error {
21266                            Ok(value) => common::Error::BadRequest(value),
21267                            _ => common::Error::Failure(response),
21268                        });
21269                    }
21270                    let response = {
21271                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21272                        let encoded = common::to_string(&bytes);
21273                        match serde_json::from_str(&encoded) {
21274                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21275                            Err(error) => {
21276                                dlg.response_json_decode_error(&encoded, &error);
21277                                return Err(common::Error::JsonDecodeError(
21278                                    encoded.to_string(),
21279                                    error,
21280                                ));
21281                            }
21282                        }
21283                    };
21284
21285                    dlg.finished(true);
21286                    return Ok(response);
21287                }
21288            }
21289        }
21290    }
21291
21292    ///
21293    /// Sets the *request* property to the given value.
21294    ///
21295    /// Even though the property as already been set when instantiating this call,
21296    /// we provide this method for API completeness.
21297    pub fn request(
21298        mut self,
21299        new_value: ClientTlsPolicy,
21300    ) -> ProjectLocationClientTlsPolicyPatchCall<'a, C> {
21301        self._request = new_value;
21302        self
21303    }
21304    /// Required. Name of the ClientTlsPolicy resource. It matches the pattern `projects/*/locations/{location}/clientTlsPolicies/{client_tls_policy}`
21305    ///
21306    /// Sets the *name* path property to the given value.
21307    ///
21308    /// Even though the property as already been set when instantiating this call,
21309    /// we provide this method for API completeness.
21310    pub fn name(mut self, new_value: &str) -> ProjectLocationClientTlsPolicyPatchCall<'a, C> {
21311        self._name = new_value.to_string();
21312        self
21313    }
21314    /// Optional. Field mask is used to specify the fields to be overwritten in the ClientTlsPolicy 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.
21315    ///
21316    /// Sets the *update mask* query property to the given value.
21317    pub fn update_mask(
21318        mut self,
21319        new_value: common::FieldMask,
21320    ) -> ProjectLocationClientTlsPolicyPatchCall<'a, C> {
21321        self._update_mask = Some(new_value);
21322        self
21323    }
21324    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21325    /// while executing the actual API request.
21326    ///
21327    /// ````text
21328    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21329    /// ````
21330    ///
21331    /// Sets the *delegate* property to the given value.
21332    pub fn delegate(
21333        mut self,
21334        new_value: &'a mut dyn common::Delegate,
21335    ) -> ProjectLocationClientTlsPolicyPatchCall<'a, C> {
21336        self._delegate = Some(new_value);
21337        self
21338    }
21339
21340    /// Set any additional parameter of the query string used in the request.
21341    /// It should be used to set parameters which are not yet available through their own
21342    /// setters.
21343    ///
21344    /// Please note that this method must not be used to set any of the known parameters
21345    /// which have their own setter method. If done anyway, the request will fail.
21346    ///
21347    /// # Additional Parameters
21348    ///
21349    /// * *$.xgafv* (query-string) - V1 error format.
21350    /// * *access_token* (query-string) - OAuth access token.
21351    /// * *alt* (query-string) - Data format for response.
21352    /// * *callback* (query-string) - JSONP
21353    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21354    /// * *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.
21355    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21356    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21357    /// * *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.
21358    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21359    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21360    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationClientTlsPolicyPatchCall<'a, C>
21361    where
21362        T: AsRef<str>,
21363    {
21364        self._additional_params
21365            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21366        self
21367    }
21368
21369    /// Identifies the authorization scope for the method you are building.
21370    ///
21371    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21372    /// [`Scope::CloudPlatform`].
21373    ///
21374    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21375    /// tokens for more than one scope.
21376    ///
21377    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21378    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21379    /// sufficient, a read-write scope will do as well.
21380    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationClientTlsPolicyPatchCall<'a, C>
21381    where
21382        St: AsRef<str>,
21383    {
21384        self._scopes.insert(String::from(scope.as_ref()));
21385        self
21386    }
21387    /// Identifies the authorization scope(s) for the method you are building.
21388    ///
21389    /// See [`Self::add_scope()`] for details.
21390    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationClientTlsPolicyPatchCall<'a, C>
21391    where
21392        I: IntoIterator<Item = St>,
21393        St: AsRef<str>,
21394    {
21395        self._scopes
21396            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21397        self
21398    }
21399
21400    /// Removes all scopes, and no default scope will be used either.
21401    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21402    /// for details).
21403    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyPatchCall<'a, C> {
21404        self._scopes.clear();
21405        self
21406    }
21407}
21408
21409/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
21410///
21411/// A builder for the *locations.clientTlsPolicies.setIamPolicy* method supported by a *project* resource.
21412/// It is not used directly, but through a [`ProjectMethods`] instance.
21413///
21414/// # Example
21415///
21416/// Instantiate a resource method builder
21417///
21418/// ```test_harness,no_run
21419/// # extern crate hyper;
21420/// # extern crate hyper_rustls;
21421/// # extern crate google_networksecurity1 as networksecurity1;
21422/// use networksecurity1::api::GoogleIamV1SetIamPolicyRequest;
21423/// # async fn dox() {
21424/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21425///
21426/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21427/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21428/// #     secret,
21429/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21430/// # ).build().await.unwrap();
21431///
21432/// # let client = hyper_util::client::legacy::Client::builder(
21433/// #     hyper_util::rt::TokioExecutor::new()
21434/// # )
21435/// # .build(
21436/// #     hyper_rustls::HttpsConnectorBuilder::new()
21437/// #         .with_native_roots()
21438/// #         .unwrap()
21439/// #         .https_or_http()
21440/// #         .enable_http1()
21441/// #         .build()
21442/// # );
21443/// # let mut hub = NetworkSecurity::new(client, auth);
21444/// // As the method needs a request, you would usually fill it with the desired information
21445/// // into the respective structure. Some of the parts shown here might not be applicable !
21446/// // Values shown here are possibly random and not representative !
21447/// let mut req = GoogleIamV1SetIamPolicyRequest::default();
21448///
21449/// // You can configure optional parameters by calling the respective setters at will, and
21450/// // execute the final call using `doit()`.
21451/// // Values shown here are possibly random and not representative !
21452/// let result = hub.projects().locations_client_tls_policies_set_iam_policy(req, "resource")
21453///              .doit().await;
21454/// # }
21455/// ```
21456pub struct ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C>
21457where
21458    C: 'a,
21459{
21460    hub: &'a NetworkSecurity<C>,
21461    _request: GoogleIamV1SetIamPolicyRequest,
21462    _resource: String,
21463    _delegate: Option<&'a mut dyn common::Delegate>,
21464    _additional_params: HashMap<String, String>,
21465    _scopes: BTreeSet<String>,
21466}
21467
21468impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C> {}
21469
21470impl<'a, C> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C>
21471where
21472    C: common::Connector,
21473{
21474    /// Perform the operation you have build so far.
21475    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
21476        use std::borrow::Cow;
21477        use std::io::{Read, Seek};
21478
21479        use common::{url::Params, ToParts};
21480        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21481
21482        let mut dd = common::DefaultDelegate;
21483        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21484        dlg.begin(common::MethodInfo {
21485            id: "networksecurity.projects.locations.clientTlsPolicies.setIamPolicy",
21486            http_method: hyper::Method::POST,
21487        });
21488
21489        for &field in ["alt", "resource"].iter() {
21490            if self._additional_params.contains_key(field) {
21491                dlg.finished(false);
21492                return Err(common::Error::FieldClash(field));
21493            }
21494        }
21495
21496        let mut params = Params::with_capacity(4 + self._additional_params.len());
21497        params.push("resource", self._resource);
21498
21499        params.extend(self._additional_params.iter());
21500
21501        params.push("alt", "json");
21502        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
21503        if self._scopes.is_empty() {
21504            self._scopes
21505                .insert(Scope::CloudPlatform.as_ref().to_string());
21506        }
21507
21508        #[allow(clippy::single_element_loop)]
21509        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
21510            url = params.uri_replacement(url, param_name, find_this, true);
21511        }
21512        {
21513            let to_remove = ["resource"];
21514            params.remove_params(&to_remove);
21515        }
21516
21517        let url = params.parse_with_url(&url);
21518
21519        let mut json_mime_type = mime::APPLICATION_JSON;
21520        let mut request_value_reader = {
21521            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21522            common::remove_json_null_values(&mut value);
21523            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21524            serde_json::to_writer(&mut dst, &value).unwrap();
21525            dst
21526        };
21527        let request_size = request_value_reader
21528            .seek(std::io::SeekFrom::End(0))
21529            .unwrap();
21530        request_value_reader
21531            .seek(std::io::SeekFrom::Start(0))
21532            .unwrap();
21533
21534        loop {
21535            let token = match self
21536                .hub
21537                .auth
21538                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21539                .await
21540            {
21541                Ok(token) => token,
21542                Err(e) => match dlg.token(e) {
21543                    Ok(token) => token,
21544                    Err(e) => {
21545                        dlg.finished(false);
21546                        return Err(common::Error::MissingToken(e));
21547                    }
21548                },
21549            };
21550            request_value_reader
21551                .seek(std::io::SeekFrom::Start(0))
21552                .unwrap();
21553            let mut req_result = {
21554                let client = &self.hub.client;
21555                dlg.pre_request();
21556                let mut req_builder = hyper::Request::builder()
21557                    .method(hyper::Method::POST)
21558                    .uri(url.as_str())
21559                    .header(USER_AGENT, self.hub._user_agent.clone());
21560
21561                if let Some(token) = token.as_ref() {
21562                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21563                }
21564
21565                let request = req_builder
21566                    .header(CONTENT_TYPE, json_mime_type.to_string())
21567                    .header(CONTENT_LENGTH, request_size as u64)
21568                    .body(common::to_body(
21569                        request_value_reader.get_ref().clone().into(),
21570                    ));
21571
21572                client.request(request.unwrap()).await
21573            };
21574
21575            match req_result {
21576                Err(err) => {
21577                    if let common::Retry::After(d) = dlg.http_error(&err) {
21578                        sleep(d).await;
21579                        continue;
21580                    }
21581                    dlg.finished(false);
21582                    return Err(common::Error::HttpError(err));
21583                }
21584                Ok(res) => {
21585                    let (mut parts, body) = res.into_parts();
21586                    let mut body = common::Body::new(body);
21587                    if !parts.status.is_success() {
21588                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21589                        let error = serde_json::from_str(&common::to_string(&bytes));
21590                        let response = common::to_response(parts, bytes.into());
21591
21592                        if let common::Retry::After(d) =
21593                            dlg.http_failure(&response, error.as_ref().ok())
21594                        {
21595                            sleep(d).await;
21596                            continue;
21597                        }
21598
21599                        dlg.finished(false);
21600
21601                        return Err(match error {
21602                            Ok(value) => common::Error::BadRequest(value),
21603                            _ => common::Error::Failure(response),
21604                        });
21605                    }
21606                    let response = {
21607                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21608                        let encoded = common::to_string(&bytes);
21609                        match serde_json::from_str(&encoded) {
21610                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21611                            Err(error) => {
21612                                dlg.response_json_decode_error(&encoded, &error);
21613                                return Err(common::Error::JsonDecodeError(
21614                                    encoded.to_string(),
21615                                    error,
21616                                ));
21617                            }
21618                        }
21619                    };
21620
21621                    dlg.finished(true);
21622                    return Ok(response);
21623                }
21624            }
21625        }
21626    }
21627
21628    ///
21629    /// Sets the *request* property to the given value.
21630    ///
21631    /// Even though the property as already been set when instantiating this call,
21632    /// we provide this method for API completeness.
21633    pub fn request(
21634        mut self,
21635        new_value: GoogleIamV1SetIamPolicyRequest,
21636    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C> {
21637        self._request = new_value;
21638        self
21639    }
21640    /// 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.
21641    ///
21642    /// Sets the *resource* path property to the given value.
21643    ///
21644    /// Even though the property as already been set when instantiating this call,
21645    /// we provide this method for API completeness.
21646    pub fn resource(
21647        mut self,
21648        new_value: &str,
21649    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C> {
21650        self._resource = new_value.to_string();
21651        self
21652    }
21653    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21654    /// while executing the actual API request.
21655    ///
21656    /// ````text
21657    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21658    /// ````
21659    ///
21660    /// Sets the *delegate* property to the given value.
21661    pub fn delegate(
21662        mut self,
21663        new_value: &'a mut dyn common::Delegate,
21664    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C> {
21665        self._delegate = Some(new_value);
21666        self
21667    }
21668
21669    /// Set any additional parameter of the query string used in the request.
21670    /// It should be used to set parameters which are not yet available through their own
21671    /// setters.
21672    ///
21673    /// Please note that this method must not be used to set any of the known parameters
21674    /// which have their own setter method. If done anyway, the request will fail.
21675    ///
21676    /// # Additional Parameters
21677    ///
21678    /// * *$.xgafv* (query-string) - V1 error format.
21679    /// * *access_token* (query-string) - OAuth access token.
21680    /// * *alt* (query-string) - Data format for response.
21681    /// * *callback* (query-string) - JSONP
21682    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21683    /// * *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.
21684    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21685    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21686    /// * *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.
21687    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21688    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21689    pub fn param<T>(
21690        mut self,
21691        name: T,
21692        value: T,
21693    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C>
21694    where
21695        T: AsRef<str>,
21696    {
21697        self._additional_params
21698            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21699        self
21700    }
21701
21702    /// Identifies the authorization scope for the method you are building.
21703    ///
21704    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21705    /// [`Scope::CloudPlatform`].
21706    ///
21707    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21708    /// tokens for more than one scope.
21709    ///
21710    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21711    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21712    /// sufficient, a read-write scope will do as well.
21713    pub fn add_scope<St>(
21714        mut self,
21715        scope: St,
21716    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C>
21717    where
21718        St: AsRef<str>,
21719    {
21720        self._scopes.insert(String::from(scope.as_ref()));
21721        self
21722    }
21723    /// Identifies the authorization scope(s) for the method you are building.
21724    ///
21725    /// See [`Self::add_scope()`] for details.
21726    pub fn add_scopes<I, St>(
21727        mut self,
21728        scopes: I,
21729    ) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C>
21730    where
21731        I: IntoIterator<Item = St>,
21732        St: AsRef<str>,
21733    {
21734        self._scopes
21735            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21736        self
21737    }
21738
21739    /// Removes all scopes, and no default scope will be used either.
21740    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21741    /// for details).
21742    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicySetIamPolicyCall<'a, C> {
21743        self._scopes.clear();
21744        self
21745    }
21746}
21747
21748/// 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.
21749///
21750/// A builder for the *locations.clientTlsPolicies.testIamPermissions* method supported by a *project* resource.
21751/// It is not used directly, but through a [`ProjectMethods`] instance.
21752///
21753/// # Example
21754///
21755/// Instantiate a resource method builder
21756///
21757/// ```test_harness,no_run
21758/// # extern crate hyper;
21759/// # extern crate hyper_rustls;
21760/// # extern crate google_networksecurity1 as networksecurity1;
21761/// use networksecurity1::api::GoogleIamV1TestIamPermissionsRequest;
21762/// # async fn dox() {
21763/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21764///
21765/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21766/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21767/// #     secret,
21768/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21769/// # ).build().await.unwrap();
21770///
21771/// # let client = hyper_util::client::legacy::Client::builder(
21772/// #     hyper_util::rt::TokioExecutor::new()
21773/// # )
21774/// # .build(
21775/// #     hyper_rustls::HttpsConnectorBuilder::new()
21776/// #         .with_native_roots()
21777/// #         .unwrap()
21778/// #         .https_or_http()
21779/// #         .enable_http1()
21780/// #         .build()
21781/// # );
21782/// # let mut hub = NetworkSecurity::new(client, auth);
21783/// // As the method needs a request, you would usually fill it with the desired information
21784/// // into the respective structure. Some of the parts shown here might not be applicable !
21785/// // Values shown here are possibly random and not representative !
21786/// let mut req = GoogleIamV1TestIamPermissionsRequest::default();
21787///
21788/// // You can configure optional parameters by calling the respective setters at will, and
21789/// // execute the final call using `doit()`.
21790/// // Values shown here are possibly random and not representative !
21791/// let result = hub.projects().locations_client_tls_policies_test_iam_permissions(req, "resource")
21792///              .doit().await;
21793/// # }
21794/// ```
21795pub struct ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C>
21796where
21797    C: 'a,
21798{
21799    hub: &'a NetworkSecurity<C>,
21800    _request: GoogleIamV1TestIamPermissionsRequest,
21801    _resource: String,
21802    _delegate: Option<&'a mut dyn common::Delegate>,
21803    _additional_params: HashMap<String, String>,
21804    _scopes: BTreeSet<String>,
21805}
21806
21807impl<'a, C> common::CallBuilder for ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C> {}
21808
21809impl<'a, C> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C>
21810where
21811    C: common::Connector,
21812{
21813    /// Perform the operation you have build so far.
21814    pub async fn doit(
21815        mut self,
21816    ) -> common::Result<(common::Response, GoogleIamV1TestIamPermissionsResponse)> {
21817        use std::borrow::Cow;
21818        use std::io::{Read, Seek};
21819
21820        use common::{url::Params, ToParts};
21821        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21822
21823        let mut dd = common::DefaultDelegate;
21824        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21825        dlg.begin(common::MethodInfo {
21826            id: "networksecurity.projects.locations.clientTlsPolicies.testIamPermissions",
21827            http_method: hyper::Method::POST,
21828        });
21829
21830        for &field in ["alt", "resource"].iter() {
21831            if self._additional_params.contains_key(field) {
21832                dlg.finished(false);
21833                return Err(common::Error::FieldClash(field));
21834            }
21835        }
21836
21837        let mut params = Params::with_capacity(4 + self._additional_params.len());
21838        params.push("resource", self._resource);
21839
21840        params.extend(self._additional_params.iter());
21841
21842        params.push("alt", "json");
21843        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
21844        if self._scopes.is_empty() {
21845            self._scopes
21846                .insert(Scope::CloudPlatform.as_ref().to_string());
21847        }
21848
21849        #[allow(clippy::single_element_loop)]
21850        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
21851            url = params.uri_replacement(url, param_name, find_this, true);
21852        }
21853        {
21854            let to_remove = ["resource"];
21855            params.remove_params(&to_remove);
21856        }
21857
21858        let url = params.parse_with_url(&url);
21859
21860        let mut json_mime_type = mime::APPLICATION_JSON;
21861        let mut request_value_reader = {
21862            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21863            common::remove_json_null_values(&mut value);
21864            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21865            serde_json::to_writer(&mut dst, &value).unwrap();
21866            dst
21867        };
21868        let request_size = request_value_reader
21869            .seek(std::io::SeekFrom::End(0))
21870            .unwrap();
21871        request_value_reader
21872            .seek(std::io::SeekFrom::Start(0))
21873            .unwrap();
21874
21875        loop {
21876            let token = match self
21877                .hub
21878                .auth
21879                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21880                .await
21881            {
21882                Ok(token) => token,
21883                Err(e) => match dlg.token(e) {
21884                    Ok(token) => token,
21885                    Err(e) => {
21886                        dlg.finished(false);
21887                        return Err(common::Error::MissingToken(e));
21888                    }
21889                },
21890            };
21891            request_value_reader
21892                .seek(std::io::SeekFrom::Start(0))
21893                .unwrap();
21894            let mut req_result = {
21895                let client = &self.hub.client;
21896                dlg.pre_request();
21897                let mut req_builder = hyper::Request::builder()
21898                    .method(hyper::Method::POST)
21899                    .uri(url.as_str())
21900                    .header(USER_AGENT, self.hub._user_agent.clone());
21901
21902                if let Some(token) = token.as_ref() {
21903                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21904                }
21905
21906                let request = req_builder
21907                    .header(CONTENT_TYPE, json_mime_type.to_string())
21908                    .header(CONTENT_LENGTH, request_size as u64)
21909                    .body(common::to_body(
21910                        request_value_reader.get_ref().clone().into(),
21911                    ));
21912
21913                client.request(request.unwrap()).await
21914            };
21915
21916            match req_result {
21917                Err(err) => {
21918                    if let common::Retry::After(d) = dlg.http_error(&err) {
21919                        sleep(d).await;
21920                        continue;
21921                    }
21922                    dlg.finished(false);
21923                    return Err(common::Error::HttpError(err));
21924                }
21925                Ok(res) => {
21926                    let (mut parts, body) = res.into_parts();
21927                    let mut body = common::Body::new(body);
21928                    if !parts.status.is_success() {
21929                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21930                        let error = serde_json::from_str(&common::to_string(&bytes));
21931                        let response = common::to_response(parts, bytes.into());
21932
21933                        if let common::Retry::After(d) =
21934                            dlg.http_failure(&response, error.as_ref().ok())
21935                        {
21936                            sleep(d).await;
21937                            continue;
21938                        }
21939
21940                        dlg.finished(false);
21941
21942                        return Err(match error {
21943                            Ok(value) => common::Error::BadRequest(value),
21944                            _ => common::Error::Failure(response),
21945                        });
21946                    }
21947                    let response = {
21948                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21949                        let encoded = common::to_string(&bytes);
21950                        match serde_json::from_str(&encoded) {
21951                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21952                            Err(error) => {
21953                                dlg.response_json_decode_error(&encoded, &error);
21954                                return Err(common::Error::JsonDecodeError(
21955                                    encoded.to_string(),
21956                                    error,
21957                                ));
21958                            }
21959                        }
21960                    };
21961
21962                    dlg.finished(true);
21963                    return Ok(response);
21964                }
21965            }
21966        }
21967    }
21968
21969    ///
21970    /// Sets the *request* property to the given value.
21971    ///
21972    /// Even though the property as already been set when instantiating this call,
21973    /// we provide this method for API completeness.
21974    pub fn request(
21975        mut self,
21976        new_value: GoogleIamV1TestIamPermissionsRequest,
21977    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C> {
21978        self._request = new_value;
21979        self
21980    }
21981    /// 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.
21982    ///
21983    /// Sets the *resource* path property to the given value.
21984    ///
21985    /// Even though the property as already been set when instantiating this call,
21986    /// we provide this method for API completeness.
21987    pub fn resource(
21988        mut self,
21989        new_value: &str,
21990    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C> {
21991        self._resource = new_value.to_string();
21992        self
21993    }
21994    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21995    /// while executing the actual API request.
21996    ///
21997    /// ````text
21998    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21999    /// ````
22000    ///
22001    /// Sets the *delegate* property to the given value.
22002    pub fn delegate(
22003        mut self,
22004        new_value: &'a mut dyn common::Delegate,
22005    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C> {
22006        self._delegate = Some(new_value);
22007        self
22008    }
22009
22010    /// Set any additional parameter of the query string used in the request.
22011    /// It should be used to set parameters which are not yet available through their own
22012    /// setters.
22013    ///
22014    /// Please note that this method must not be used to set any of the known parameters
22015    /// which have their own setter method. If done anyway, the request will fail.
22016    ///
22017    /// # Additional Parameters
22018    ///
22019    /// * *$.xgafv* (query-string) - V1 error format.
22020    /// * *access_token* (query-string) - OAuth access token.
22021    /// * *alt* (query-string) - Data format for response.
22022    /// * *callback* (query-string) - JSONP
22023    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22024    /// * *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.
22025    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22026    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22027    /// * *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.
22028    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22029    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22030    pub fn param<T>(
22031        mut self,
22032        name: T,
22033        value: T,
22034    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C>
22035    where
22036        T: AsRef<str>,
22037    {
22038        self._additional_params
22039            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22040        self
22041    }
22042
22043    /// Identifies the authorization scope for the method you are building.
22044    ///
22045    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22046    /// [`Scope::CloudPlatform`].
22047    ///
22048    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22049    /// tokens for more than one scope.
22050    ///
22051    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22052    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22053    /// sufficient, a read-write scope will do as well.
22054    pub fn add_scope<St>(
22055        mut self,
22056        scope: St,
22057    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C>
22058    where
22059        St: AsRef<str>,
22060    {
22061        self._scopes.insert(String::from(scope.as_ref()));
22062        self
22063    }
22064    /// Identifies the authorization scope(s) for the method you are building.
22065    ///
22066    /// See [`Self::add_scope()`] for details.
22067    pub fn add_scopes<I, St>(
22068        mut self,
22069        scopes: I,
22070    ) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C>
22071    where
22072        I: IntoIterator<Item = St>,
22073        St: AsRef<str>,
22074    {
22075        self._scopes
22076            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22077        self
22078    }
22079
22080    /// Removes all scopes, and no default scope will be used either.
22081    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22082    /// for details).
22083    pub fn clear_scopes(mut self) -> ProjectLocationClientTlsPolicyTestIamPermissionCall<'a, C> {
22084        self._scopes.clear();
22085        self
22086    }
22087}
22088
22089/// Creates a new FirewallEndpointAssociation in a given project and location.
22090///
22091/// A builder for the *locations.firewallEndpointAssociations.create* method supported by a *project* resource.
22092/// It is not used directly, but through a [`ProjectMethods`] instance.
22093///
22094/// # Example
22095///
22096/// Instantiate a resource method builder
22097///
22098/// ```test_harness,no_run
22099/// # extern crate hyper;
22100/// # extern crate hyper_rustls;
22101/// # extern crate google_networksecurity1 as networksecurity1;
22102/// use networksecurity1::api::FirewallEndpointAssociation;
22103/// # async fn dox() {
22104/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22105///
22106/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22108/// #     secret,
22109/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22110/// # ).build().await.unwrap();
22111///
22112/// # let client = hyper_util::client::legacy::Client::builder(
22113/// #     hyper_util::rt::TokioExecutor::new()
22114/// # )
22115/// # .build(
22116/// #     hyper_rustls::HttpsConnectorBuilder::new()
22117/// #         .with_native_roots()
22118/// #         .unwrap()
22119/// #         .https_or_http()
22120/// #         .enable_http1()
22121/// #         .build()
22122/// # );
22123/// # let mut hub = NetworkSecurity::new(client, auth);
22124/// // As the method needs a request, you would usually fill it with the desired information
22125/// // into the respective structure. Some of the parts shown here might not be applicable !
22126/// // Values shown here are possibly random and not representative !
22127/// let mut req = FirewallEndpointAssociation::default();
22128///
22129/// // You can configure optional parameters by calling the respective setters at will, and
22130/// // execute the final call using `doit()`.
22131/// // Values shown here are possibly random and not representative !
22132/// let result = hub.projects().locations_firewall_endpoint_associations_create(req, "parent")
22133///              .request_id("Lorem")
22134///              .firewall_endpoint_association_id("est")
22135///              .doit().await;
22136/// # }
22137/// ```
22138pub struct ProjectLocationFirewallEndpointAssociationCreateCall<'a, C>
22139where
22140    C: 'a,
22141{
22142    hub: &'a NetworkSecurity<C>,
22143    _request: FirewallEndpointAssociation,
22144    _parent: String,
22145    _request_id: Option<String>,
22146    _firewall_endpoint_association_id: Option<String>,
22147    _delegate: Option<&'a mut dyn common::Delegate>,
22148    _additional_params: HashMap<String, String>,
22149    _scopes: BTreeSet<String>,
22150}
22151
22152impl<'a, C> common::CallBuilder for ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {}
22153
22154impl<'a, C> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C>
22155where
22156    C: common::Connector,
22157{
22158    /// Perform the operation you have build so far.
22159    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22160        use std::borrow::Cow;
22161        use std::io::{Read, Seek};
22162
22163        use common::{url::Params, ToParts};
22164        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22165
22166        let mut dd = common::DefaultDelegate;
22167        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22168        dlg.begin(common::MethodInfo {
22169            id: "networksecurity.projects.locations.firewallEndpointAssociations.create",
22170            http_method: hyper::Method::POST,
22171        });
22172
22173        for &field in [
22174            "alt",
22175            "parent",
22176            "requestId",
22177            "firewallEndpointAssociationId",
22178        ]
22179        .iter()
22180        {
22181            if self._additional_params.contains_key(field) {
22182                dlg.finished(false);
22183                return Err(common::Error::FieldClash(field));
22184            }
22185        }
22186
22187        let mut params = Params::with_capacity(6 + self._additional_params.len());
22188        params.push("parent", self._parent);
22189        if let Some(value) = self._request_id.as_ref() {
22190            params.push("requestId", value);
22191        }
22192        if let Some(value) = self._firewall_endpoint_association_id.as_ref() {
22193            params.push("firewallEndpointAssociationId", value);
22194        }
22195
22196        params.extend(self._additional_params.iter());
22197
22198        params.push("alt", "json");
22199        let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallEndpointAssociations";
22200        if self._scopes.is_empty() {
22201            self._scopes
22202                .insert(Scope::CloudPlatform.as_ref().to_string());
22203        }
22204
22205        #[allow(clippy::single_element_loop)]
22206        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22207            url = params.uri_replacement(url, param_name, find_this, true);
22208        }
22209        {
22210            let to_remove = ["parent"];
22211            params.remove_params(&to_remove);
22212        }
22213
22214        let url = params.parse_with_url(&url);
22215
22216        let mut json_mime_type = mime::APPLICATION_JSON;
22217        let mut request_value_reader = {
22218            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22219            common::remove_json_null_values(&mut value);
22220            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22221            serde_json::to_writer(&mut dst, &value).unwrap();
22222            dst
22223        };
22224        let request_size = request_value_reader
22225            .seek(std::io::SeekFrom::End(0))
22226            .unwrap();
22227        request_value_reader
22228            .seek(std::io::SeekFrom::Start(0))
22229            .unwrap();
22230
22231        loop {
22232            let token = match self
22233                .hub
22234                .auth
22235                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22236                .await
22237            {
22238                Ok(token) => token,
22239                Err(e) => match dlg.token(e) {
22240                    Ok(token) => token,
22241                    Err(e) => {
22242                        dlg.finished(false);
22243                        return Err(common::Error::MissingToken(e));
22244                    }
22245                },
22246            };
22247            request_value_reader
22248                .seek(std::io::SeekFrom::Start(0))
22249                .unwrap();
22250            let mut req_result = {
22251                let client = &self.hub.client;
22252                dlg.pre_request();
22253                let mut req_builder = hyper::Request::builder()
22254                    .method(hyper::Method::POST)
22255                    .uri(url.as_str())
22256                    .header(USER_AGENT, self.hub._user_agent.clone());
22257
22258                if let Some(token) = token.as_ref() {
22259                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22260                }
22261
22262                let request = req_builder
22263                    .header(CONTENT_TYPE, json_mime_type.to_string())
22264                    .header(CONTENT_LENGTH, request_size as u64)
22265                    .body(common::to_body(
22266                        request_value_reader.get_ref().clone().into(),
22267                    ));
22268
22269                client.request(request.unwrap()).await
22270            };
22271
22272            match req_result {
22273                Err(err) => {
22274                    if let common::Retry::After(d) = dlg.http_error(&err) {
22275                        sleep(d).await;
22276                        continue;
22277                    }
22278                    dlg.finished(false);
22279                    return Err(common::Error::HttpError(err));
22280                }
22281                Ok(res) => {
22282                    let (mut parts, body) = res.into_parts();
22283                    let mut body = common::Body::new(body);
22284                    if !parts.status.is_success() {
22285                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22286                        let error = serde_json::from_str(&common::to_string(&bytes));
22287                        let response = common::to_response(parts, bytes.into());
22288
22289                        if let common::Retry::After(d) =
22290                            dlg.http_failure(&response, error.as_ref().ok())
22291                        {
22292                            sleep(d).await;
22293                            continue;
22294                        }
22295
22296                        dlg.finished(false);
22297
22298                        return Err(match error {
22299                            Ok(value) => common::Error::BadRequest(value),
22300                            _ => common::Error::Failure(response),
22301                        });
22302                    }
22303                    let response = {
22304                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22305                        let encoded = common::to_string(&bytes);
22306                        match serde_json::from_str(&encoded) {
22307                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22308                            Err(error) => {
22309                                dlg.response_json_decode_error(&encoded, &error);
22310                                return Err(common::Error::JsonDecodeError(
22311                                    encoded.to_string(),
22312                                    error,
22313                                ));
22314                            }
22315                        }
22316                    };
22317
22318                    dlg.finished(true);
22319                    return Ok(response);
22320                }
22321            }
22322        }
22323    }
22324
22325    ///
22326    /// Sets the *request* property to the given value.
22327    ///
22328    /// Even though the property as already been set when instantiating this call,
22329    /// we provide this method for API completeness.
22330    pub fn request(
22331        mut self,
22332        new_value: FirewallEndpointAssociation,
22333    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
22334        self._request = new_value;
22335        self
22336    }
22337    /// Required. Value for parent.
22338    ///
22339    /// Sets the *parent* path property to the given value.
22340    ///
22341    /// Even though the property as already been set when instantiating this call,
22342    /// we provide this method for API completeness.
22343    pub fn parent(
22344        mut self,
22345        new_value: &str,
22346    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
22347        self._parent = new_value.to_string();
22348        self
22349    }
22350    /// Optional. 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).
22351    ///
22352    /// Sets the *request id* query property to the given value.
22353    pub fn request_id(
22354        mut self,
22355        new_value: &str,
22356    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
22357        self._request_id = Some(new_value.to_string());
22358        self
22359    }
22360    /// Optional. Id of the requesting object. If auto-generating Id server-side, remove this field and firewall_endpoint_association_id from the method_signature of Create RPC.
22361    ///
22362    /// Sets the *firewall endpoint association id* query property to the given value.
22363    pub fn firewall_endpoint_association_id(
22364        mut self,
22365        new_value: &str,
22366    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
22367        self._firewall_endpoint_association_id = Some(new_value.to_string());
22368        self
22369    }
22370    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22371    /// while executing the actual API request.
22372    ///
22373    /// ````text
22374    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22375    /// ````
22376    ///
22377    /// Sets the *delegate* property to the given value.
22378    pub fn delegate(
22379        mut self,
22380        new_value: &'a mut dyn common::Delegate,
22381    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
22382        self._delegate = Some(new_value);
22383        self
22384    }
22385
22386    /// Set any additional parameter of the query string used in the request.
22387    /// It should be used to set parameters which are not yet available through their own
22388    /// setters.
22389    ///
22390    /// Please note that this method must not be used to set any of the known parameters
22391    /// which have their own setter method. If done anyway, the request will fail.
22392    ///
22393    /// # Additional Parameters
22394    ///
22395    /// * *$.xgafv* (query-string) - V1 error format.
22396    /// * *access_token* (query-string) - OAuth access token.
22397    /// * *alt* (query-string) - Data format for response.
22398    /// * *callback* (query-string) - JSONP
22399    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22400    /// * *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.
22401    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22402    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22403    /// * *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.
22404    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22405    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22406    pub fn param<T>(
22407        mut self,
22408        name: T,
22409        value: T,
22410    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C>
22411    where
22412        T: AsRef<str>,
22413    {
22414        self._additional_params
22415            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22416        self
22417    }
22418
22419    /// Identifies the authorization scope for the method you are building.
22420    ///
22421    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22422    /// [`Scope::CloudPlatform`].
22423    ///
22424    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22425    /// tokens for more than one scope.
22426    ///
22427    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22428    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22429    /// sufficient, a read-write scope will do as well.
22430    pub fn add_scope<St>(
22431        mut self,
22432        scope: St,
22433    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C>
22434    where
22435        St: AsRef<str>,
22436    {
22437        self._scopes.insert(String::from(scope.as_ref()));
22438        self
22439    }
22440    /// Identifies the authorization scope(s) for the method you are building.
22441    ///
22442    /// See [`Self::add_scope()`] for details.
22443    pub fn add_scopes<I, St>(
22444        mut self,
22445        scopes: I,
22446    ) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C>
22447    where
22448        I: IntoIterator<Item = St>,
22449        St: AsRef<str>,
22450    {
22451        self._scopes
22452            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22453        self
22454    }
22455
22456    /// Removes all scopes, and no default scope will be used either.
22457    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22458    /// for details).
22459    pub fn clear_scopes(mut self) -> ProjectLocationFirewallEndpointAssociationCreateCall<'a, C> {
22460        self._scopes.clear();
22461        self
22462    }
22463}
22464
22465/// Deletes a single FirewallEndpointAssociation.
22466///
22467/// A builder for the *locations.firewallEndpointAssociations.delete* method supported by a *project* resource.
22468/// It is not used directly, but through a [`ProjectMethods`] instance.
22469///
22470/// # Example
22471///
22472/// Instantiate a resource method builder
22473///
22474/// ```test_harness,no_run
22475/// # extern crate hyper;
22476/// # extern crate hyper_rustls;
22477/// # extern crate google_networksecurity1 as networksecurity1;
22478/// # async fn dox() {
22479/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22480///
22481/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22483/// #     secret,
22484/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22485/// # ).build().await.unwrap();
22486///
22487/// # let client = hyper_util::client::legacy::Client::builder(
22488/// #     hyper_util::rt::TokioExecutor::new()
22489/// # )
22490/// # .build(
22491/// #     hyper_rustls::HttpsConnectorBuilder::new()
22492/// #         .with_native_roots()
22493/// #         .unwrap()
22494/// #         .https_or_http()
22495/// #         .enable_http1()
22496/// #         .build()
22497/// # );
22498/// # let mut hub = NetworkSecurity::new(client, auth);
22499/// // You can configure optional parameters by calling the respective setters at will, and
22500/// // execute the final call using `doit()`.
22501/// // Values shown here are possibly random and not representative !
22502/// let result = hub.projects().locations_firewall_endpoint_associations_delete("name")
22503///              .request_id("diam")
22504///              .doit().await;
22505/// # }
22506/// ```
22507pub struct ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C>
22508where
22509    C: 'a,
22510{
22511    hub: &'a NetworkSecurity<C>,
22512    _name: String,
22513    _request_id: Option<String>,
22514    _delegate: Option<&'a mut dyn common::Delegate>,
22515    _additional_params: HashMap<String, String>,
22516    _scopes: BTreeSet<String>,
22517}
22518
22519impl<'a, C> common::CallBuilder for ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C> {}
22520
22521impl<'a, C> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C>
22522where
22523    C: common::Connector,
22524{
22525    /// Perform the operation you have build so far.
22526    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22527        use std::borrow::Cow;
22528        use std::io::{Read, Seek};
22529
22530        use common::{url::Params, ToParts};
22531        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22532
22533        let mut dd = common::DefaultDelegate;
22534        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22535        dlg.begin(common::MethodInfo {
22536            id: "networksecurity.projects.locations.firewallEndpointAssociations.delete",
22537            http_method: hyper::Method::DELETE,
22538        });
22539
22540        for &field in ["alt", "name", "requestId"].iter() {
22541            if self._additional_params.contains_key(field) {
22542                dlg.finished(false);
22543                return Err(common::Error::FieldClash(field));
22544            }
22545        }
22546
22547        let mut params = Params::with_capacity(4 + self._additional_params.len());
22548        params.push("name", self._name);
22549        if let Some(value) = self._request_id.as_ref() {
22550            params.push("requestId", value);
22551        }
22552
22553        params.extend(self._additional_params.iter());
22554
22555        params.push("alt", "json");
22556        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22557        if self._scopes.is_empty() {
22558            self._scopes
22559                .insert(Scope::CloudPlatform.as_ref().to_string());
22560        }
22561
22562        #[allow(clippy::single_element_loop)]
22563        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22564            url = params.uri_replacement(url, param_name, find_this, true);
22565        }
22566        {
22567            let to_remove = ["name"];
22568            params.remove_params(&to_remove);
22569        }
22570
22571        let url = params.parse_with_url(&url);
22572
22573        loop {
22574            let token = match self
22575                .hub
22576                .auth
22577                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22578                .await
22579            {
22580                Ok(token) => token,
22581                Err(e) => match dlg.token(e) {
22582                    Ok(token) => token,
22583                    Err(e) => {
22584                        dlg.finished(false);
22585                        return Err(common::Error::MissingToken(e));
22586                    }
22587                },
22588            };
22589            let mut req_result = {
22590                let client = &self.hub.client;
22591                dlg.pre_request();
22592                let mut req_builder = hyper::Request::builder()
22593                    .method(hyper::Method::DELETE)
22594                    .uri(url.as_str())
22595                    .header(USER_AGENT, self.hub._user_agent.clone());
22596
22597                if let Some(token) = token.as_ref() {
22598                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22599                }
22600
22601                let request = req_builder
22602                    .header(CONTENT_LENGTH, 0_u64)
22603                    .body(common::to_body::<String>(None));
22604
22605                client.request(request.unwrap()).await
22606            };
22607
22608            match req_result {
22609                Err(err) => {
22610                    if let common::Retry::After(d) = dlg.http_error(&err) {
22611                        sleep(d).await;
22612                        continue;
22613                    }
22614                    dlg.finished(false);
22615                    return Err(common::Error::HttpError(err));
22616                }
22617                Ok(res) => {
22618                    let (mut parts, body) = res.into_parts();
22619                    let mut body = common::Body::new(body);
22620                    if !parts.status.is_success() {
22621                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22622                        let error = serde_json::from_str(&common::to_string(&bytes));
22623                        let response = common::to_response(parts, bytes.into());
22624
22625                        if let common::Retry::After(d) =
22626                            dlg.http_failure(&response, error.as_ref().ok())
22627                        {
22628                            sleep(d).await;
22629                            continue;
22630                        }
22631
22632                        dlg.finished(false);
22633
22634                        return Err(match error {
22635                            Ok(value) => common::Error::BadRequest(value),
22636                            _ => common::Error::Failure(response),
22637                        });
22638                    }
22639                    let response = {
22640                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22641                        let encoded = common::to_string(&bytes);
22642                        match serde_json::from_str(&encoded) {
22643                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22644                            Err(error) => {
22645                                dlg.response_json_decode_error(&encoded, &error);
22646                                return Err(common::Error::JsonDecodeError(
22647                                    encoded.to_string(),
22648                                    error,
22649                                ));
22650                            }
22651                        }
22652                    };
22653
22654                    dlg.finished(true);
22655                    return Ok(response);
22656                }
22657            }
22658        }
22659    }
22660
22661    /// Required. Name of the resource
22662    ///
22663    /// Sets the *name* path property to the given value.
22664    ///
22665    /// Even though the property as already been set when instantiating this call,
22666    /// we provide this method for API completeness.
22667    pub fn name(
22668        mut self,
22669        new_value: &str,
22670    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C> {
22671        self._name = new_value.to_string();
22672        self
22673    }
22674    /// Optional. 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).
22675    ///
22676    /// Sets the *request id* query property to the given value.
22677    pub fn request_id(
22678        mut self,
22679        new_value: &str,
22680    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C> {
22681        self._request_id = Some(new_value.to_string());
22682        self
22683    }
22684    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22685    /// while executing the actual API request.
22686    ///
22687    /// ````text
22688    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22689    /// ````
22690    ///
22691    /// Sets the *delegate* property to the given value.
22692    pub fn delegate(
22693        mut self,
22694        new_value: &'a mut dyn common::Delegate,
22695    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C> {
22696        self._delegate = Some(new_value);
22697        self
22698    }
22699
22700    /// Set any additional parameter of the query string used in the request.
22701    /// It should be used to set parameters which are not yet available through their own
22702    /// setters.
22703    ///
22704    /// Please note that this method must not be used to set any of the known parameters
22705    /// which have their own setter method. If done anyway, the request will fail.
22706    ///
22707    /// # Additional Parameters
22708    ///
22709    /// * *$.xgafv* (query-string) - V1 error format.
22710    /// * *access_token* (query-string) - OAuth access token.
22711    /// * *alt* (query-string) - Data format for response.
22712    /// * *callback* (query-string) - JSONP
22713    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22714    /// * *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.
22715    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22716    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22717    /// * *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.
22718    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22719    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22720    pub fn param<T>(
22721        mut self,
22722        name: T,
22723        value: T,
22724    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C>
22725    where
22726        T: AsRef<str>,
22727    {
22728        self._additional_params
22729            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22730        self
22731    }
22732
22733    /// Identifies the authorization scope for the method you are building.
22734    ///
22735    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22736    /// [`Scope::CloudPlatform`].
22737    ///
22738    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22739    /// tokens for more than one scope.
22740    ///
22741    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22742    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22743    /// sufficient, a read-write scope will do as well.
22744    pub fn add_scope<St>(
22745        mut self,
22746        scope: St,
22747    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C>
22748    where
22749        St: AsRef<str>,
22750    {
22751        self._scopes.insert(String::from(scope.as_ref()));
22752        self
22753    }
22754    /// Identifies the authorization scope(s) for the method you are building.
22755    ///
22756    /// See [`Self::add_scope()`] for details.
22757    pub fn add_scopes<I, St>(
22758        mut self,
22759        scopes: I,
22760    ) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C>
22761    where
22762        I: IntoIterator<Item = St>,
22763        St: AsRef<str>,
22764    {
22765        self._scopes
22766            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22767        self
22768    }
22769
22770    /// Removes all scopes, and no default scope will be used either.
22771    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22772    /// for details).
22773    pub fn clear_scopes(mut self) -> ProjectLocationFirewallEndpointAssociationDeleteCall<'a, C> {
22774        self._scopes.clear();
22775        self
22776    }
22777}
22778
22779/// Gets details of a single FirewallEndpointAssociation.
22780///
22781/// A builder for the *locations.firewallEndpointAssociations.get* method supported by a *project* resource.
22782/// It is not used directly, but through a [`ProjectMethods`] instance.
22783///
22784/// # Example
22785///
22786/// Instantiate a resource method builder
22787///
22788/// ```test_harness,no_run
22789/// # extern crate hyper;
22790/// # extern crate hyper_rustls;
22791/// # extern crate google_networksecurity1 as networksecurity1;
22792/// # async fn dox() {
22793/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22794///
22795/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22796/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22797/// #     secret,
22798/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22799/// # ).build().await.unwrap();
22800///
22801/// # let client = hyper_util::client::legacy::Client::builder(
22802/// #     hyper_util::rt::TokioExecutor::new()
22803/// # )
22804/// # .build(
22805/// #     hyper_rustls::HttpsConnectorBuilder::new()
22806/// #         .with_native_roots()
22807/// #         .unwrap()
22808/// #         .https_or_http()
22809/// #         .enable_http1()
22810/// #         .build()
22811/// # );
22812/// # let mut hub = NetworkSecurity::new(client, auth);
22813/// // You can configure optional parameters by calling the respective setters at will, and
22814/// // execute the final call using `doit()`.
22815/// // Values shown here are possibly random and not representative !
22816/// let result = hub.projects().locations_firewall_endpoint_associations_get("name")
22817///              .doit().await;
22818/// # }
22819/// ```
22820pub struct ProjectLocationFirewallEndpointAssociationGetCall<'a, C>
22821where
22822    C: 'a,
22823{
22824    hub: &'a NetworkSecurity<C>,
22825    _name: String,
22826    _delegate: Option<&'a mut dyn common::Delegate>,
22827    _additional_params: HashMap<String, String>,
22828    _scopes: BTreeSet<String>,
22829}
22830
22831impl<'a, C> common::CallBuilder for ProjectLocationFirewallEndpointAssociationGetCall<'a, C> {}
22832
22833impl<'a, C> ProjectLocationFirewallEndpointAssociationGetCall<'a, C>
22834where
22835    C: common::Connector,
22836{
22837    /// Perform the operation you have build so far.
22838    pub async fn doit(mut self) -> common::Result<(common::Response, FirewallEndpointAssociation)> {
22839        use std::borrow::Cow;
22840        use std::io::{Read, Seek};
22841
22842        use common::{url::Params, ToParts};
22843        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22844
22845        let mut dd = common::DefaultDelegate;
22846        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22847        dlg.begin(common::MethodInfo {
22848            id: "networksecurity.projects.locations.firewallEndpointAssociations.get",
22849            http_method: hyper::Method::GET,
22850        });
22851
22852        for &field in ["alt", "name"].iter() {
22853            if self._additional_params.contains_key(field) {
22854                dlg.finished(false);
22855                return Err(common::Error::FieldClash(field));
22856            }
22857        }
22858
22859        let mut params = Params::with_capacity(3 + self._additional_params.len());
22860        params.push("name", self._name);
22861
22862        params.extend(self._additional_params.iter());
22863
22864        params.push("alt", "json");
22865        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22866        if self._scopes.is_empty() {
22867            self._scopes
22868                .insert(Scope::CloudPlatform.as_ref().to_string());
22869        }
22870
22871        #[allow(clippy::single_element_loop)]
22872        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22873            url = params.uri_replacement(url, param_name, find_this, true);
22874        }
22875        {
22876            let to_remove = ["name"];
22877            params.remove_params(&to_remove);
22878        }
22879
22880        let url = params.parse_with_url(&url);
22881
22882        loop {
22883            let token = match self
22884                .hub
22885                .auth
22886                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22887                .await
22888            {
22889                Ok(token) => token,
22890                Err(e) => match dlg.token(e) {
22891                    Ok(token) => token,
22892                    Err(e) => {
22893                        dlg.finished(false);
22894                        return Err(common::Error::MissingToken(e));
22895                    }
22896                },
22897            };
22898            let mut req_result = {
22899                let client = &self.hub.client;
22900                dlg.pre_request();
22901                let mut req_builder = hyper::Request::builder()
22902                    .method(hyper::Method::GET)
22903                    .uri(url.as_str())
22904                    .header(USER_AGENT, self.hub._user_agent.clone());
22905
22906                if let Some(token) = token.as_ref() {
22907                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22908                }
22909
22910                let request = req_builder
22911                    .header(CONTENT_LENGTH, 0_u64)
22912                    .body(common::to_body::<String>(None));
22913
22914                client.request(request.unwrap()).await
22915            };
22916
22917            match req_result {
22918                Err(err) => {
22919                    if let common::Retry::After(d) = dlg.http_error(&err) {
22920                        sleep(d).await;
22921                        continue;
22922                    }
22923                    dlg.finished(false);
22924                    return Err(common::Error::HttpError(err));
22925                }
22926                Ok(res) => {
22927                    let (mut parts, body) = res.into_parts();
22928                    let mut body = common::Body::new(body);
22929                    if !parts.status.is_success() {
22930                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22931                        let error = serde_json::from_str(&common::to_string(&bytes));
22932                        let response = common::to_response(parts, bytes.into());
22933
22934                        if let common::Retry::After(d) =
22935                            dlg.http_failure(&response, error.as_ref().ok())
22936                        {
22937                            sleep(d).await;
22938                            continue;
22939                        }
22940
22941                        dlg.finished(false);
22942
22943                        return Err(match error {
22944                            Ok(value) => common::Error::BadRequest(value),
22945                            _ => common::Error::Failure(response),
22946                        });
22947                    }
22948                    let response = {
22949                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22950                        let encoded = common::to_string(&bytes);
22951                        match serde_json::from_str(&encoded) {
22952                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22953                            Err(error) => {
22954                                dlg.response_json_decode_error(&encoded, &error);
22955                                return Err(common::Error::JsonDecodeError(
22956                                    encoded.to_string(),
22957                                    error,
22958                                ));
22959                            }
22960                        }
22961                    };
22962
22963                    dlg.finished(true);
22964                    return Ok(response);
22965                }
22966            }
22967        }
22968    }
22969
22970    /// Required. Name of the resource
22971    ///
22972    /// Sets the *name* path property to the given value.
22973    ///
22974    /// Even though the property as already been set when instantiating this call,
22975    /// we provide this method for API completeness.
22976    pub fn name(
22977        mut self,
22978        new_value: &str,
22979    ) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C> {
22980        self._name = new_value.to_string();
22981        self
22982    }
22983    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22984    /// while executing the actual API request.
22985    ///
22986    /// ````text
22987    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22988    /// ````
22989    ///
22990    /// Sets the *delegate* property to the given value.
22991    pub fn delegate(
22992        mut self,
22993        new_value: &'a mut dyn common::Delegate,
22994    ) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C> {
22995        self._delegate = Some(new_value);
22996        self
22997    }
22998
22999    /// Set any additional parameter of the query string used in the request.
23000    /// It should be used to set parameters which are not yet available through their own
23001    /// setters.
23002    ///
23003    /// Please note that this method must not be used to set any of the known parameters
23004    /// which have their own setter method. If done anyway, the request will fail.
23005    ///
23006    /// # Additional Parameters
23007    ///
23008    /// * *$.xgafv* (query-string) - V1 error format.
23009    /// * *access_token* (query-string) - OAuth access token.
23010    /// * *alt* (query-string) - Data format for response.
23011    /// * *callback* (query-string) - JSONP
23012    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23013    /// * *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.
23014    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23015    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23016    /// * *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.
23017    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23018    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23019    pub fn param<T>(
23020        mut self,
23021        name: T,
23022        value: T,
23023    ) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C>
23024    where
23025        T: AsRef<str>,
23026    {
23027        self._additional_params
23028            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23029        self
23030    }
23031
23032    /// Identifies the authorization scope for the method you are building.
23033    ///
23034    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23035    /// [`Scope::CloudPlatform`].
23036    ///
23037    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23038    /// tokens for more than one scope.
23039    ///
23040    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23041    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23042    /// sufficient, a read-write scope will do as well.
23043    pub fn add_scope<St>(
23044        mut self,
23045        scope: St,
23046    ) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C>
23047    where
23048        St: AsRef<str>,
23049    {
23050        self._scopes.insert(String::from(scope.as_ref()));
23051        self
23052    }
23053    /// Identifies the authorization scope(s) for the method you are building.
23054    ///
23055    /// See [`Self::add_scope()`] for details.
23056    pub fn add_scopes<I, St>(
23057        mut self,
23058        scopes: I,
23059    ) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C>
23060    where
23061        I: IntoIterator<Item = St>,
23062        St: AsRef<str>,
23063    {
23064        self._scopes
23065            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23066        self
23067    }
23068
23069    /// Removes all scopes, and no default scope will be used either.
23070    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23071    /// for details).
23072    pub fn clear_scopes(mut self) -> ProjectLocationFirewallEndpointAssociationGetCall<'a, C> {
23073        self._scopes.clear();
23074        self
23075    }
23076}
23077
23078/// Lists Associations in a given project and location.
23079///
23080/// A builder for the *locations.firewallEndpointAssociations.list* method supported by a *project* resource.
23081/// It is not used directly, but through a [`ProjectMethods`] instance.
23082///
23083/// # Example
23084///
23085/// Instantiate a resource method builder
23086///
23087/// ```test_harness,no_run
23088/// # extern crate hyper;
23089/// # extern crate hyper_rustls;
23090/// # extern crate google_networksecurity1 as networksecurity1;
23091/// # async fn dox() {
23092/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23093///
23094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23095/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23096/// #     secret,
23097/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23098/// # ).build().await.unwrap();
23099///
23100/// # let client = hyper_util::client::legacy::Client::builder(
23101/// #     hyper_util::rt::TokioExecutor::new()
23102/// # )
23103/// # .build(
23104/// #     hyper_rustls::HttpsConnectorBuilder::new()
23105/// #         .with_native_roots()
23106/// #         .unwrap()
23107/// #         .https_or_http()
23108/// #         .enable_http1()
23109/// #         .build()
23110/// # );
23111/// # let mut hub = NetworkSecurity::new(client, auth);
23112/// // You can configure optional parameters by calling the respective setters at will, and
23113/// // execute the final call using `doit()`.
23114/// // Values shown here are possibly random and not representative !
23115/// let result = hub.projects().locations_firewall_endpoint_associations_list("parent")
23116///              .page_token("et")
23117///              .page_size(-93)
23118///              .order_by("no")
23119///              .filter("et")
23120///              .doit().await;
23121/// # }
23122/// ```
23123pub struct ProjectLocationFirewallEndpointAssociationListCall<'a, C>
23124where
23125    C: 'a,
23126{
23127    hub: &'a NetworkSecurity<C>,
23128    _parent: String,
23129    _page_token: Option<String>,
23130    _page_size: Option<i32>,
23131    _order_by: Option<String>,
23132    _filter: Option<String>,
23133    _delegate: Option<&'a mut dyn common::Delegate>,
23134    _additional_params: HashMap<String, String>,
23135    _scopes: BTreeSet<String>,
23136}
23137
23138impl<'a, C> common::CallBuilder for ProjectLocationFirewallEndpointAssociationListCall<'a, C> {}
23139
23140impl<'a, C> ProjectLocationFirewallEndpointAssociationListCall<'a, C>
23141where
23142    C: common::Connector,
23143{
23144    /// Perform the operation you have build so far.
23145    pub async fn doit(
23146        mut self,
23147    ) -> common::Result<(common::Response, ListFirewallEndpointAssociationsResponse)> {
23148        use std::borrow::Cow;
23149        use std::io::{Read, Seek};
23150
23151        use common::{url::Params, ToParts};
23152        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23153
23154        let mut dd = common::DefaultDelegate;
23155        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23156        dlg.begin(common::MethodInfo {
23157            id: "networksecurity.projects.locations.firewallEndpointAssociations.list",
23158            http_method: hyper::Method::GET,
23159        });
23160
23161        for &field in [
23162            "alt",
23163            "parent",
23164            "pageToken",
23165            "pageSize",
23166            "orderBy",
23167            "filter",
23168        ]
23169        .iter()
23170        {
23171            if self._additional_params.contains_key(field) {
23172                dlg.finished(false);
23173                return Err(common::Error::FieldClash(field));
23174            }
23175        }
23176
23177        let mut params = Params::with_capacity(7 + self._additional_params.len());
23178        params.push("parent", self._parent);
23179        if let Some(value) = self._page_token.as_ref() {
23180            params.push("pageToken", value);
23181        }
23182        if let Some(value) = self._page_size.as_ref() {
23183            params.push("pageSize", value.to_string());
23184        }
23185        if let Some(value) = self._order_by.as_ref() {
23186            params.push("orderBy", value);
23187        }
23188        if let Some(value) = self._filter.as_ref() {
23189            params.push("filter", value);
23190        }
23191
23192        params.extend(self._additional_params.iter());
23193
23194        params.push("alt", "json");
23195        let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallEndpointAssociations";
23196        if self._scopes.is_empty() {
23197            self._scopes
23198                .insert(Scope::CloudPlatform.as_ref().to_string());
23199        }
23200
23201        #[allow(clippy::single_element_loop)]
23202        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
23203            url = params.uri_replacement(url, param_name, find_this, true);
23204        }
23205        {
23206            let to_remove = ["parent"];
23207            params.remove_params(&to_remove);
23208        }
23209
23210        let url = params.parse_with_url(&url);
23211
23212        loop {
23213            let token = match self
23214                .hub
23215                .auth
23216                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23217                .await
23218            {
23219                Ok(token) => token,
23220                Err(e) => match dlg.token(e) {
23221                    Ok(token) => token,
23222                    Err(e) => {
23223                        dlg.finished(false);
23224                        return Err(common::Error::MissingToken(e));
23225                    }
23226                },
23227            };
23228            let mut req_result = {
23229                let client = &self.hub.client;
23230                dlg.pre_request();
23231                let mut req_builder = hyper::Request::builder()
23232                    .method(hyper::Method::GET)
23233                    .uri(url.as_str())
23234                    .header(USER_AGENT, self.hub._user_agent.clone());
23235
23236                if let Some(token) = token.as_ref() {
23237                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23238                }
23239
23240                let request = req_builder
23241                    .header(CONTENT_LENGTH, 0_u64)
23242                    .body(common::to_body::<String>(None));
23243
23244                client.request(request.unwrap()).await
23245            };
23246
23247            match req_result {
23248                Err(err) => {
23249                    if let common::Retry::After(d) = dlg.http_error(&err) {
23250                        sleep(d).await;
23251                        continue;
23252                    }
23253                    dlg.finished(false);
23254                    return Err(common::Error::HttpError(err));
23255                }
23256                Ok(res) => {
23257                    let (mut parts, body) = res.into_parts();
23258                    let mut body = common::Body::new(body);
23259                    if !parts.status.is_success() {
23260                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23261                        let error = serde_json::from_str(&common::to_string(&bytes));
23262                        let response = common::to_response(parts, bytes.into());
23263
23264                        if let common::Retry::After(d) =
23265                            dlg.http_failure(&response, error.as_ref().ok())
23266                        {
23267                            sleep(d).await;
23268                            continue;
23269                        }
23270
23271                        dlg.finished(false);
23272
23273                        return Err(match error {
23274                            Ok(value) => common::Error::BadRequest(value),
23275                            _ => common::Error::Failure(response),
23276                        });
23277                    }
23278                    let response = {
23279                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23280                        let encoded = common::to_string(&bytes);
23281                        match serde_json::from_str(&encoded) {
23282                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23283                            Err(error) => {
23284                                dlg.response_json_decode_error(&encoded, &error);
23285                                return Err(common::Error::JsonDecodeError(
23286                                    encoded.to_string(),
23287                                    error,
23288                                ));
23289                            }
23290                        }
23291                    };
23292
23293                    dlg.finished(true);
23294                    return Ok(response);
23295                }
23296            }
23297        }
23298    }
23299
23300    /// Required. Parent value for ListAssociationsRequest
23301    ///
23302    /// Sets the *parent* path property to the given value.
23303    ///
23304    /// Even though the property as already been set when instantiating this call,
23305    /// we provide this method for API completeness.
23306    pub fn parent(
23307        mut self,
23308        new_value: &str,
23309    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23310        self._parent = new_value.to_string();
23311        self
23312    }
23313    /// A token identifying a page of results the server should return.
23314    ///
23315    /// Sets the *page token* query property to the given value.
23316    pub fn page_token(
23317        mut self,
23318        new_value: &str,
23319    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23320        self._page_token = Some(new_value.to_string());
23321        self
23322    }
23323    /// Optional. Requested page size. Server may return fewer items than requested. If unspecified, server will pick an appropriate default.
23324    ///
23325    /// Sets the *page size* query property to the given value.
23326    pub fn page_size(
23327        mut self,
23328        new_value: i32,
23329    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23330        self._page_size = Some(new_value);
23331        self
23332    }
23333    /// Hint for how to order the results
23334    ///
23335    /// Sets the *order by* query property to the given value.
23336    pub fn order_by(
23337        mut self,
23338        new_value: &str,
23339    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23340        self._order_by = Some(new_value.to_string());
23341        self
23342    }
23343    /// Optional. Filtering results
23344    ///
23345    /// Sets the *filter* query property to the given value.
23346    pub fn filter(
23347        mut self,
23348        new_value: &str,
23349    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23350        self._filter = Some(new_value.to_string());
23351        self
23352    }
23353    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23354    /// while executing the actual API request.
23355    ///
23356    /// ````text
23357    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23358    /// ````
23359    ///
23360    /// Sets the *delegate* property to the given value.
23361    pub fn delegate(
23362        mut self,
23363        new_value: &'a mut dyn common::Delegate,
23364    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23365        self._delegate = Some(new_value);
23366        self
23367    }
23368
23369    /// Set any additional parameter of the query string used in the request.
23370    /// It should be used to set parameters which are not yet available through their own
23371    /// setters.
23372    ///
23373    /// Please note that this method must not be used to set any of the known parameters
23374    /// which have their own setter method. If done anyway, the request will fail.
23375    ///
23376    /// # Additional Parameters
23377    ///
23378    /// * *$.xgafv* (query-string) - V1 error format.
23379    /// * *access_token* (query-string) - OAuth access token.
23380    /// * *alt* (query-string) - Data format for response.
23381    /// * *callback* (query-string) - JSONP
23382    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23383    /// * *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.
23384    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23385    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23386    /// * *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.
23387    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23388    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23389    pub fn param<T>(
23390        mut self,
23391        name: T,
23392        value: T,
23393    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C>
23394    where
23395        T: AsRef<str>,
23396    {
23397        self._additional_params
23398            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23399        self
23400    }
23401
23402    /// Identifies the authorization scope for the method you are building.
23403    ///
23404    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23405    /// [`Scope::CloudPlatform`].
23406    ///
23407    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23408    /// tokens for more than one scope.
23409    ///
23410    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23411    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23412    /// sufficient, a read-write scope will do as well.
23413    pub fn add_scope<St>(
23414        mut self,
23415        scope: St,
23416    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C>
23417    where
23418        St: AsRef<str>,
23419    {
23420        self._scopes.insert(String::from(scope.as_ref()));
23421        self
23422    }
23423    /// Identifies the authorization scope(s) for the method you are building.
23424    ///
23425    /// See [`Self::add_scope()`] for details.
23426    pub fn add_scopes<I, St>(
23427        mut self,
23428        scopes: I,
23429    ) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C>
23430    where
23431        I: IntoIterator<Item = St>,
23432        St: AsRef<str>,
23433    {
23434        self._scopes
23435            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23436        self
23437    }
23438
23439    /// Removes all scopes, and no default scope will be used either.
23440    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23441    /// for details).
23442    pub fn clear_scopes(mut self) -> ProjectLocationFirewallEndpointAssociationListCall<'a, C> {
23443        self._scopes.clear();
23444        self
23445    }
23446}
23447
23448/// Update a single FirewallEndpointAssociation.
23449///
23450/// A builder for the *locations.firewallEndpointAssociations.patch* method supported by a *project* resource.
23451/// It is not used directly, but through a [`ProjectMethods`] instance.
23452///
23453/// # Example
23454///
23455/// Instantiate a resource method builder
23456///
23457/// ```test_harness,no_run
23458/// # extern crate hyper;
23459/// # extern crate hyper_rustls;
23460/// # extern crate google_networksecurity1 as networksecurity1;
23461/// use networksecurity1::api::FirewallEndpointAssociation;
23462/// # async fn dox() {
23463/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23464///
23465/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23466/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23467/// #     secret,
23468/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23469/// # ).build().await.unwrap();
23470///
23471/// # let client = hyper_util::client::legacy::Client::builder(
23472/// #     hyper_util::rt::TokioExecutor::new()
23473/// # )
23474/// # .build(
23475/// #     hyper_rustls::HttpsConnectorBuilder::new()
23476/// #         .with_native_roots()
23477/// #         .unwrap()
23478/// #         .https_or_http()
23479/// #         .enable_http1()
23480/// #         .build()
23481/// # );
23482/// # let mut hub = NetworkSecurity::new(client, auth);
23483/// // As the method needs a request, you would usually fill it with the desired information
23484/// // into the respective structure. Some of the parts shown here might not be applicable !
23485/// // Values shown here are possibly random and not representative !
23486/// let mut req = FirewallEndpointAssociation::default();
23487///
23488/// // You can configure optional parameters by calling the respective setters at will, and
23489/// // execute the final call using `doit()`.
23490/// // Values shown here are possibly random and not representative !
23491/// let result = hub.projects().locations_firewall_endpoint_associations_patch(req, "name")
23492///              .update_mask(FieldMask::new::<&str>(&[]))
23493///              .request_id("sed")
23494///              .doit().await;
23495/// # }
23496/// ```
23497pub struct ProjectLocationFirewallEndpointAssociationPatchCall<'a, C>
23498where
23499    C: 'a,
23500{
23501    hub: &'a NetworkSecurity<C>,
23502    _request: FirewallEndpointAssociation,
23503    _name: String,
23504    _update_mask: Option<common::FieldMask>,
23505    _request_id: Option<String>,
23506    _delegate: Option<&'a mut dyn common::Delegate>,
23507    _additional_params: HashMap<String, String>,
23508    _scopes: BTreeSet<String>,
23509}
23510
23511impl<'a, C> common::CallBuilder for ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {}
23512
23513impl<'a, C> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C>
23514where
23515    C: common::Connector,
23516{
23517    /// Perform the operation you have build so far.
23518    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23519        use std::borrow::Cow;
23520        use std::io::{Read, Seek};
23521
23522        use common::{url::Params, ToParts};
23523        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23524
23525        let mut dd = common::DefaultDelegate;
23526        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23527        dlg.begin(common::MethodInfo {
23528            id: "networksecurity.projects.locations.firewallEndpointAssociations.patch",
23529            http_method: hyper::Method::PATCH,
23530        });
23531
23532        for &field in ["alt", "name", "updateMask", "requestId"].iter() {
23533            if self._additional_params.contains_key(field) {
23534                dlg.finished(false);
23535                return Err(common::Error::FieldClash(field));
23536            }
23537        }
23538
23539        let mut params = Params::with_capacity(6 + self._additional_params.len());
23540        params.push("name", self._name);
23541        if let Some(value) = self._update_mask.as_ref() {
23542            params.push("updateMask", value.to_string());
23543        }
23544        if let Some(value) = self._request_id.as_ref() {
23545            params.push("requestId", value);
23546        }
23547
23548        params.extend(self._additional_params.iter());
23549
23550        params.push("alt", "json");
23551        let mut url = self.hub._base_url.clone() + "v1/{+name}";
23552        if self._scopes.is_empty() {
23553            self._scopes
23554                .insert(Scope::CloudPlatform.as_ref().to_string());
23555        }
23556
23557        #[allow(clippy::single_element_loop)]
23558        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23559            url = params.uri_replacement(url, param_name, find_this, true);
23560        }
23561        {
23562            let to_remove = ["name"];
23563            params.remove_params(&to_remove);
23564        }
23565
23566        let url = params.parse_with_url(&url);
23567
23568        let mut json_mime_type = mime::APPLICATION_JSON;
23569        let mut request_value_reader = {
23570            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23571            common::remove_json_null_values(&mut value);
23572            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23573            serde_json::to_writer(&mut dst, &value).unwrap();
23574            dst
23575        };
23576        let request_size = request_value_reader
23577            .seek(std::io::SeekFrom::End(0))
23578            .unwrap();
23579        request_value_reader
23580            .seek(std::io::SeekFrom::Start(0))
23581            .unwrap();
23582
23583        loop {
23584            let token = match self
23585                .hub
23586                .auth
23587                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23588                .await
23589            {
23590                Ok(token) => token,
23591                Err(e) => match dlg.token(e) {
23592                    Ok(token) => token,
23593                    Err(e) => {
23594                        dlg.finished(false);
23595                        return Err(common::Error::MissingToken(e));
23596                    }
23597                },
23598            };
23599            request_value_reader
23600                .seek(std::io::SeekFrom::Start(0))
23601                .unwrap();
23602            let mut req_result = {
23603                let client = &self.hub.client;
23604                dlg.pre_request();
23605                let mut req_builder = hyper::Request::builder()
23606                    .method(hyper::Method::PATCH)
23607                    .uri(url.as_str())
23608                    .header(USER_AGENT, self.hub._user_agent.clone());
23609
23610                if let Some(token) = token.as_ref() {
23611                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23612                }
23613
23614                let request = req_builder
23615                    .header(CONTENT_TYPE, json_mime_type.to_string())
23616                    .header(CONTENT_LENGTH, request_size as u64)
23617                    .body(common::to_body(
23618                        request_value_reader.get_ref().clone().into(),
23619                    ));
23620
23621                client.request(request.unwrap()).await
23622            };
23623
23624            match req_result {
23625                Err(err) => {
23626                    if let common::Retry::After(d) = dlg.http_error(&err) {
23627                        sleep(d).await;
23628                        continue;
23629                    }
23630                    dlg.finished(false);
23631                    return Err(common::Error::HttpError(err));
23632                }
23633                Ok(res) => {
23634                    let (mut parts, body) = res.into_parts();
23635                    let mut body = common::Body::new(body);
23636                    if !parts.status.is_success() {
23637                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23638                        let error = serde_json::from_str(&common::to_string(&bytes));
23639                        let response = common::to_response(parts, bytes.into());
23640
23641                        if let common::Retry::After(d) =
23642                            dlg.http_failure(&response, error.as_ref().ok())
23643                        {
23644                            sleep(d).await;
23645                            continue;
23646                        }
23647
23648                        dlg.finished(false);
23649
23650                        return Err(match error {
23651                            Ok(value) => common::Error::BadRequest(value),
23652                            _ => common::Error::Failure(response),
23653                        });
23654                    }
23655                    let response = {
23656                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23657                        let encoded = common::to_string(&bytes);
23658                        match serde_json::from_str(&encoded) {
23659                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23660                            Err(error) => {
23661                                dlg.response_json_decode_error(&encoded, &error);
23662                                return Err(common::Error::JsonDecodeError(
23663                                    encoded.to_string(),
23664                                    error,
23665                                ));
23666                            }
23667                        }
23668                    };
23669
23670                    dlg.finished(true);
23671                    return Ok(response);
23672                }
23673            }
23674        }
23675    }
23676
23677    ///
23678    /// Sets the *request* property to the given value.
23679    ///
23680    /// Even though the property as already been set when instantiating this call,
23681    /// we provide this method for API completeness.
23682    pub fn request(
23683        mut self,
23684        new_value: FirewallEndpointAssociation,
23685    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
23686        self._request = new_value;
23687        self
23688    }
23689    /// Immutable. Identifier. name of resource
23690    ///
23691    /// Sets the *name* path property to the given value.
23692    ///
23693    /// Even though the property as already been set when instantiating this call,
23694    /// we provide this method for API completeness.
23695    pub fn name(
23696        mut self,
23697        new_value: &str,
23698    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
23699        self._name = new_value.to_string();
23700        self
23701    }
23702    /// Required. Field mask is used to specify the fields to be overwritten in the Association 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.
23703    ///
23704    /// Sets the *update mask* query property to the given value.
23705    pub fn update_mask(
23706        mut self,
23707        new_value: common::FieldMask,
23708    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
23709        self._update_mask = Some(new_value);
23710        self
23711    }
23712    /// Optional. 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).
23713    ///
23714    /// Sets the *request id* query property to the given value.
23715    pub fn request_id(
23716        mut self,
23717        new_value: &str,
23718    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
23719        self._request_id = Some(new_value.to_string());
23720        self
23721    }
23722    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23723    /// while executing the actual API request.
23724    ///
23725    /// ````text
23726    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23727    /// ````
23728    ///
23729    /// Sets the *delegate* property to the given value.
23730    pub fn delegate(
23731        mut self,
23732        new_value: &'a mut dyn common::Delegate,
23733    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
23734        self._delegate = Some(new_value);
23735        self
23736    }
23737
23738    /// Set any additional parameter of the query string used in the request.
23739    /// It should be used to set parameters which are not yet available through their own
23740    /// setters.
23741    ///
23742    /// Please note that this method must not be used to set any of the known parameters
23743    /// which have their own setter method. If done anyway, the request will fail.
23744    ///
23745    /// # Additional Parameters
23746    ///
23747    /// * *$.xgafv* (query-string) - V1 error format.
23748    /// * *access_token* (query-string) - OAuth access token.
23749    /// * *alt* (query-string) - Data format for response.
23750    /// * *callback* (query-string) - JSONP
23751    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23752    /// * *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.
23753    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23754    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23755    /// * *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.
23756    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23757    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23758    pub fn param<T>(
23759        mut self,
23760        name: T,
23761        value: T,
23762    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C>
23763    where
23764        T: AsRef<str>,
23765    {
23766        self._additional_params
23767            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23768        self
23769    }
23770
23771    /// Identifies the authorization scope for the method you are building.
23772    ///
23773    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23774    /// [`Scope::CloudPlatform`].
23775    ///
23776    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23777    /// tokens for more than one scope.
23778    ///
23779    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23780    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23781    /// sufficient, a read-write scope will do as well.
23782    pub fn add_scope<St>(
23783        mut self,
23784        scope: St,
23785    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C>
23786    where
23787        St: AsRef<str>,
23788    {
23789        self._scopes.insert(String::from(scope.as_ref()));
23790        self
23791    }
23792    /// Identifies the authorization scope(s) for the method you are building.
23793    ///
23794    /// See [`Self::add_scope()`] for details.
23795    pub fn add_scopes<I, St>(
23796        mut self,
23797        scopes: I,
23798    ) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C>
23799    where
23800        I: IntoIterator<Item = St>,
23801        St: AsRef<str>,
23802    {
23803        self._scopes
23804            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23805        self
23806    }
23807
23808    /// Removes all scopes, and no default scope will be used either.
23809    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23810    /// for details).
23811    pub fn clear_scopes(mut self) -> ProjectLocationFirewallEndpointAssociationPatchCall<'a, C> {
23812        self._scopes.clear();
23813        self
23814    }
23815}
23816
23817/// Creates a new GatewaySecurityPolicy in a given project and location.
23818///
23819/// A builder for the *locations.gatewaySecurityPolicies.rules.create* method supported by a *project* resource.
23820/// It is not used directly, but through a [`ProjectMethods`] instance.
23821///
23822/// # Example
23823///
23824/// Instantiate a resource method builder
23825///
23826/// ```test_harness,no_run
23827/// # extern crate hyper;
23828/// # extern crate hyper_rustls;
23829/// # extern crate google_networksecurity1 as networksecurity1;
23830/// use networksecurity1::api::GatewaySecurityPolicyRule;
23831/// # async fn dox() {
23832/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23833///
23834/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23835/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23836/// #     secret,
23837/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23838/// # ).build().await.unwrap();
23839///
23840/// # let client = hyper_util::client::legacy::Client::builder(
23841/// #     hyper_util::rt::TokioExecutor::new()
23842/// # )
23843/// # .build(
23844/// #     hyper_rustls::HttpsConnectorBuilder::new()
23845/// #         .with_native_roots()
23846/// #         .unwrap()
23847/// #         .https_or_http()
23848/// #         .enable_http1()
23849/// #         .build()
23850/// # );
23851/// # let mut hub = NetworkSecurity::new(client, auth);
23852/// // As the method needs a request, you would usually fill it with the desired information
23853/// // into the respective structure. Some of the parts shown here might not be applicable !
23854/// // Values shown here are possibly random and not representative !
23855/// let mut req = GatewaySecurityPolicyRule::default();
23856///
23857/// // You can configure optional parameters by calling the respective setters at will, and
23858/// // execute the final call using `doit()`.
23859/// // Values shown here are possibly random and not representative !
23860/// let result = hub.projects().locations_gateway_security_policies_rules_create(req, "parent")
23861///              .gateway_security_policy_rule_id("nonumy")
23862///              .doit().await;
23863/// # }
23864/// ```
23865pub struct ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C>
23866where
23867    C: 'a,
23868{
23869    hub: &'a NetworkSecurity<C>,
23870    _request: GatewaySecurityPolicyRule,
23871    _parent: String,
23872    _gateway_security_policy_rule_id: Option<String>,
23873    _delegate: Option<&'a mut dyn common::Delegate>,
23874    _additional_params: HashMap<String, String>,
23875    _scopes: BTreeSet<String>,
23876}
23877
23878impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {}
23879
23880impl<'a, C> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C>
23881where
23882    C: common::Connector,
23883{
23884    /// Perform the operation you have build so far.
23885    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23886        use std::borrow::Cow;
23887        use std::io::{Read, Seek};
23888
23889        use common::{url::Params, ToParts};
23890        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23891
23892        let mut dd = common::DefaultDelegate;
23893        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23894        dlg.begin(common::MethodInfo {
23895            id: "networksecurity.projects.locations.gatewaySecurityPolicies.rules.create",
23896            http_method: hyper::Method::POST,
23897        });
23898
23899        for &field in ["alt", "parent", "gatewaySecurityPolicyRuleId"].iter() {
23900            if self._additional_params.contains_key(field) {
23901                dlg.finished(false);
23902                return Err(common::Error::FieldClash(field));
23903            }
23904        }
23905
23906        let mut params = Params::with_capacity(5 + self._additional_params.len());
23907        params.push("parent", self._parent);
23908        if let Some(value) = self._gateway_security_policy_rule_id.as_ref() {
23909            params.push("gatewaySecurityPolicyRuleId", value);
23910        }
23911
23912        params.extend(self._additional_params.iter());
23913
23914        params.push("alt", "json");
23915        let mut url = self.hub._base_url.clone() + "v1/{+parent}/rules";
23916        if self._scopes.is_empty() {
23917            self._scopes
23918                .insert(Scope::CloudPlatform.as_ref().to_string());
23919        }
23920
23921        #[allow(clippy::single_element_loop)]
23922        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
23923            url = params.uri_replacement(url, param_name, find_this, true);
23924        }
23925        {
23926            let to_remove = ["parent"];
23927            params.remove_params(&to_remove);
23928        }
23929
23930        let url = params.parse_with_url(&url);
23931
23932        let mut json_mime_type = mime::APPLICATION_JSON;
23933        let mut request_value_reader = {
23934            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23935            common::remove_json_null_values(&mut value);
23936            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23937            serde_json::to_writer(&mut dst, &value).unwrap();
23938            dst
23939        };
23940        let request_size = request_value_reader
23941            .seek(std::io::SeekFrom::End(0))
23942            .unwrap();
23943        request_value_reader
23944            .seek(std::io::SeekFrom::Start(0))
23945            .unwrap();
23946
23947        loop {
23948            let token = match self
23949                .hub
23950                .auth
23951                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23952                .await
23953            {
23954                Ok(token) => token,
23955                Err(e) => match dlg.token(e) {
23956                    Ok(token) => token,
23957                    Err(e) => {
23958                        dlg.finished(false);
23959                        return Err(common::Error::MissingToken(e));
23960                    }
23961                },
23962            };
23963            request_value_reader
23964                .seek(std::io::SeekFrom::Start(0))
23965                .unwrap();
23966            let mut req_result = {
23967                let client = &self.hub.client;
23968                dlg.pre_request();
23969                let mut req_builder = hyper::Request::builder()
23970                    .method(hyper::Method::POST)
23971                    .uri(url.as_str())
23972                    .header(USER_AGENT, self.hub._user_agent.clone());
23973
23974                if let Some(token) = token.as_ref() {
23975                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23976                }
23977
23978                let request = req_builder
23979                    .header(CONTENT_TYPE, json_mime_type.to_string())
23980                    .header(CONTENT_LENGTH, request_size as u64)
23981                    .body(common::to_body(
23982                        request_value_reader.get_ref().clone().into(),
23983                    ));
23984
23985                client.request(request.unwrap()).await
23986            };
23987
23988            match req_result {
23989                Err(err) => {
23990                    if let common::Retry::After(d) = dlg.http_error(&err) {
23991                        sleep(d).await;
23992                        continue;
23993                    }
23994                    dlg.finished(false);
23995                    return Err(common::Error::HttpError(err));
23996                }
23997                Ok(res) => {
23998                    let (mut parts, body) = res.into_parts();
23999                    let mut body = common::Body::new(body);
24000                    if !parts.status.is_success() {
24001                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24002                        let error = serde_json::from_str(&common::to_string(&bytes));
24003                        let response = common::to_response(parts, bytes.into());
24004
24005                        if let common::Retry::After(d) =
24006                            dlg.http_failure(&response, error.as_ref().ok())
24007                        {
24008                            sleep(d).await;
24009                            continue;
24010                        }
24011
24012                        dlg.finished(false);
24013
24014                        return Err(match error {
24015                            Ok(value) => common::Error::BadRequest(value),
24016                            _ => common::Error::Failure(response),
24017                        });
24018                    }
24019                    let response = {
24020                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24021                        let encoded = common::to_string(&bytes);
24022                        match serde_json::from_str(&encoded) {
24023                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24024                            Err(error) => {
24025                                dlg.response_json_decode_error(&encoded, &error);
24026                                return Err(common::Error::JsonDecodeError(
24027                                    encoded.to_string(),
24028                                    error,
24029                                ));
24030                            }
24031                        }
24032                    };
24033
24034                    dlg.finished(true);
24035                    return Ok(response);
24036                }
24037            }
24038        }
24039    }
24040
24041    ///
24042    /// Sets the *request* property to the given value.
24043    ///
24044    /// Even though the property as already been set when instantiating this call,
24045    /// we provide this method for API completeness.
24046    pub fn request(
24047        mut self,
24048        new_value: GatewaySecurityPolicyRule,
24049    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {
24050        self._request = new_value;
24051        self
24052    }
24053    /// Required. The parent where this rule will be created. Format : projects/{project}/location/{location}/gatewaySecurityPolicies/*
24054    ///
24055    /// Sets the *parent* path property to the given value.
24056    ///
24057    /// Even though the property as already been set when instantiating this call,
24058    /// we provide this method for API completeness.
24059    pub fn parent(
24060        mut self,
24061        new_value: &str,
24062    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {
24063        self._parent = new_value.to_string();
24064        self
24065    }
24066    /// The ID to use for the rule, which will become the final component of the rule's resource name. This value should be 4-63 characters, and valid characters are /a-z-/.
24067    ///
24068    /// Sets the *gateway security policy rule id* query property to the given value.
24069    pub fn gateway_security_policy_rule_id(
24070        mut self,
24071        new_value: &str,
24072    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {
24073        self._gateway_security_policy_rule_id = Some(new_value.to_string());
24074        self
24075    }
24076    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24077    /// while executing the actual API request.
24078    ///
24079    /// ````text
24080    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24081    /// ````
24082    ///
24083    /// Sets the *delegate* property to the given value.
24084    pub fn delegate(
24085        mut self,
24086        new_value: &'a mut dyn common::Delegate,
24087    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {
24088        self._delegate = Some(new_value);
24089        self
24090    }
24091
24092    /// Set any additional parameter of the query string used in the request.
24093    /// It should be used to set parameters which are not yet available through their own
24094    /// setters.
24095    ///
24096    /// Please note that this method must not be used to set any of the known parameters
24097    /// which have their own setter method. If done anyway, the request will fail.
24098    ///
24099    /// # Additional Parameters
24100    ///
24101    /// * *$.xgafv* (query-string) - V1 error format.
24102    /// * *access_token* (query-string) - OAuth access token.
24103    /// * *alt* (query-string) - Data format for response.
24104    /// * *callback* (query-string) - JSONP
24105    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24106    /// * *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.
24107    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24108    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24109    /// * *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.
24110    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24111    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24112    pub fn param<T>(
24113        mut self,
24114        name: T,
24115        value: T,
24116    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C>
24117    where
24118        T: AsRef<str>,
24119    {
24120        self._additional_params
24121            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24122        self
24123    }
24124
24125    /// Identifies the authorization scope for the method you are building.
24126    ///
24127    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24128    /// [`Scope::CloudPlatform`].
24129    ///
24130    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24131    /// tokens for more than one scope.
24132    ///
24133    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24134    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24135    /// sufficient, a read-write scope will do as well.
24136    pub fn add_scope<St>(
24137        mut self,
24138        scope: St,
24139    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C>
24140    where
24141        St: AsRef<str>,
24142    {
24143        self._scopes.insert(String::from(scope.as_ref()));
24144        self
24145    }
24146    /// Identifies the authorization scope(s) for the method you are building.
24147    ///
24148    /// See [`Self::add_scope()`] for details.
24149    pub fn add_scopes<I, St>(
24150        mut self,
24151        scopes: I,
24152    ) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C>
24153    where
24154        I: IntoIterator<Item = St>,
24155        St: AsRef<str>,
24156    {
24157        self._scopes
24158            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24159        self
24160    }
24161
24162    /// Removes all scopes, and no default scope will be used either.
24163    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24164    /// for details).
24165    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyRuleCreateCall<'a, C> {
24166        self._scopes.clear();
24167        self
24168    }
24169}
24170
24171/// Deletes a single GatewaySecurityPolicyRule.
24172///
24173/// A builder for the *locations.gatewaySecurityPolicies.rules.delete* method supported by a *project* resource.
24174/// It is not used directly, but through a [`ProjectMethods`] instance.
24175///
24176/// # Example
24177///
24178/// Instantiate a resource method builder
24179///
24180/// ```test_harness,no_run
24181/// # extern crate hyper;
24182/// # extern crate hyper_rustls;
24183/// # extern crate google_networksecurity1 as networksecurity1;
24184/// # async fn dox() {
24185/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24186///
24187/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24188/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24189/// #     secret,
24190/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24191/// # ).build().await.unwrap();
24192///
24193/// # let client = hyper_util::client::legacy::Client::builder(
24194/// #     hyper_util::rt::TokioExecutor::new()
24195/// # )
24196/// # .build(
24197/// #     hyper_rustls::HttpsConnectorBuilder::new()
24198/// #         .with_native_roots()
24199/// #         .unwrap()
24200/// #         .https_or_http()
24201/// #         .enable_http1()
24202/// #         .build()
24203/// # );
24204/// # let mut hub = NetworkSecurity::new(client, auth);
24205/// // You can configure optional parameters by calling the respective setters at will, and
24206/// // execute the final call using `doit()`.
24207/// // Values shown here are possibly random and not representative !
24208/// let result = hub.projects().locations_gateway_security_policies_rules_delete("name")
24209///              .doit().await;
24210/// # }
24211/// ```
24212pub struct ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C>
24213where
24214    C: 'a,
24215{
24216    hub: &'a NetworkSecurity<C>,
24217    _name: String,
24218    _delegate: Option<&'a mut dyn common::Delegate>,
24219    _additional_params: HashMap<String, String>,
24220    _scopes: BTreeSet<String>,
24221}
24222
24223impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C> {}
24224
24225impl<'a, C> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C>
24226where
24227    C: common::Connector,
24228{
24229    /// Perform the operation you have build so far.
24230    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
24231        use std::borrow::Cow;
24232        use std::io::{Read, Seek};
24233
24234        use common::{url::Params, ToParts};
24235        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24236
24237        let mut dd = common::DefaultDelegate;
24238        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24239        dlg.begin(common::MethodInfo {
24240            id: "networksecurity.projects.locations.gatewaySecurityPolicies.rules.delete",
24241            http_method: hyper::Method::DELETE,
24242        });
24243
24244        for &field in ["alt", "name"].iter() {
24245            if self._additional_params.contains_key(field) {
24246                dlg.finished(false);
24247                return Err(common::Error::FieldClash(field));
24248            }
24249        }
24250
24251        let mut params = Params::with_capacity(3 + self._additional_params.len());
24252        params.push("name", self._name);
24253
24254        params.extend(self._additional_params.iter());
24255
24256        params.push("alt", "json");
24257        let mut url = self.hub._base_url.clone() + "v1/{+name}";
24258        if self._scopes.is_empty() {
24259            self._scopes
24260                .insert(Scope::CloudPlatform.as_ref().to_string());
24261        }
24262
24263        #[allow(clippy::single_element_loop)]
24264        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24265            url = params.uri_replacement(url, param_name, find_this, true);
24266        }
24267        {
24268            let to_remove = ["name"];
24269            params.remove_params(&to_remove);
24270        }
24271
24272        let url = params.parse_with_url(&url);
24273
24274        loop {
24275            let token = match self
24276                .hub
24277                .auth
24278                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24279                .await
24280            {
24281                Ok(token) => token,
24282                Err(e) => match dlg.token(e) {
24283                    Ok(token) => token,
24284                    Err(e) => {
24285                        dlg.finished(false);
24286                        return Err(common::Error::MissingToken(e));
24287                    }
24288                },
24289            };
24290            let mut req_result = {
24291                let client = &self.hub.client;
24292                dlg.pre_request();
24293                let mut req_builder = hyper::Request::builder()
24294                    .method(hyper::Method::DELETE)
24295                    .uri(url.as_str())
24296                    .header(USER_AGENT, self.hub._user_agent.clone());
24297
24298                if let Some(token) = token.as_ref() {
24299                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24300                }
24301
24302                let request = req_builder
24303                    .header(CONTENT_LENGTH, 0_u64)
24304                    .body(common::to_body::<String>(None));
24305
24306                client.request(request.unwrap()).await
24307            };
24308
24309            match req_result {
24310                Err(err) => {
24311                    if let common::Retry::After(d) = dlg.http_error(&err) {
24312                        sleep(d).await;
24313                        continue;
24314                    }
24315                    dlg.finished(false);
24316                    return Err(common::Error::HttpError(err));
24317                }
24318                Ok(res) => {
24319                    let (mut parts, body) = res.into_parts();
24320                    let mut body = common::Body::new(body);
24321                    if !parts.status.is_success() {
24322                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24323                        let error = serde_json::from_str(&common::to_string(&bytes));
24324                        let response = common::to_response(parts, bytes.into());
24325
24326                        if let common::Retry::After(d) =
24327                            dlg.http_failure(&response, error.as_ref().ok())
24328                        {
24329                            sleep(d).await;
24330                            continue;
24331                        }
24332
24333                        dlg.finished(false);
24334
24335                        return Err(match error {
24336                            Ok(value) => common::Error::BadRequest(value),
24337                            _ => common::Error::Failure(response),
24338                        });
24339                    }
24340                    let response = {
24341                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24342                        let encoded = common::to_string(&bytes);
24343                        match serde_json::from_str(&encoded) {
24344                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24345                            Err(error) => {
24346                                dlg.response_json_decode_error(&encoded, &error);
24347                                return Err(common::Error::JsonDecodeError(
24348                                    encoded.to_string(),
24349                                    error,
24350                                ));
24351                            }
24352                        }
24353                    };
24354
24355                    dlg.finished(true);
24356                    return Ok(response);
24357                }
24358            }
24359        }
24360    }
24361
24362    /// Required. A name of the GatewaySecurityPolicyRule to delete. Must be in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/{gatewaySecurityPolicy}/rules/*`.
24363    ///
24364    /// Sets the *name* path property to the given value.
24365    ///
24366    /// Even though the property as already been set when instantiating this call,
24367    /// we provide this method for API completeness.
24368    pub fn name(
24369        mut self,
24370        new_value: &str,
24371    ) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C> {
24372        self._name = new_value.to_string();
24373        self
24374    }
24375    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24376    /// while executing the actual API request.
24377    ///
24378    /// ````text
24379    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24380    /// ````
24381    ///
24382    /// Sets the *delegate* property to the given value.
24383    pub fn delegate(
24384        mut self,
24385        new_value: &'a mut dyn common::Delegate,
24386    ) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C> {
24387        self._delegate = Some(new_value);
24388        self
24389    }
24390
24391    /// Set any additional parameter of the query string used in the request.
24392    /// It should be used to set parameters which are not yet available through their own
24393    /// setters.
24394    ///
24395    /// Please note that this method must not be used to set any of the known parameters
24396    /// which have their own setter method. If done anyway, the request will fail.
24397    ///
24398    /// # Additional Parameters
24399    ///
24400    /// * *$.xgafv* (query-string) - V1 error format.
24401    /// * *access_token* (query-string) - OAuth access token.
24402    /// * *alt* (query-string) - Data format for response.
24403    /// * *callback* (query-string) - JSONP
24404    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24405    /// * *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.
24406    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24407    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24408    /// * *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.
24409    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24410    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24411    pub fn param<T>(
24412        mut self,
24413        name: T,
24414        value: T,
24415    ) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C>
24416    where
24417        T: AsRef<str>,
24418    {
24419        self._additional_params
24420            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24421        self
24422    }
24423
24424    /// Identifies the authorization scope for the method you are building.
24425    ///
24426    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24427    /// [`Scope::CloudPlatform`].
24428    ///
24429    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24430    /// tokens for more than one scope.
24431    ///
24432    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24433    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24434    /// sufficient, a read-write scope will do as well.
24435    pub fn add_scope<St>(
24436        mut self,
24437        scope: St,
24438    ) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C>
24439    where
24440        St: AsRef<str>,
24441    {
24442        self._scopes.insert(String::from(scope.as_ref()));
24443        self
24444    }
24445    /// Identifies the authorization scope(s) for the method you are building.
24446    ///
24447    /// See [`Self::add_scope()`] for details.
24448    pub fn add_scopes<I, St>(
24449        mut self,
24450        scopes: I,
24451    ) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C>
24452    where
24453        I: IntoIterator<Item = St>,
24454        St: AsRef<str>,
24455    {
24456        self._scopes
24457            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24458        self
24459    }
24460
24461    /// Removes all scopes, and no default scope will be used either.
24462    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24463    /// for details).
24464    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyRuleDeleteCall<'a, C> {
24465        self._scopes.clear();
24466        self
24467    }
24468}
24469
24470/// Gets details of a single GatewaySecurityPolicyRule.
24471///
24472/// A builder for the *locations.gatewaySecurityPolicies.rules.get* method supported by a *project* resource.
24473/// It is not used directly, but through a [`ProjectMethods`] instance.
24474///
24475/// # Example
24476///
24477/// Instantiate a resource method builder
24478///
24479/// ```test_harness,no_run
24480/// # extern crate hyper;
24481/// # extern crate hyper_rustls;
24482/// # extern crate google_networksecurity1 as networksecurity1;
24483/// # async fn dox() {
24484/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24485///
24486/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24487/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24488/// #     secret,
24489/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24490/// # ).build().await.unwrap();
24491///
24492/// # let client = hyper_util::client::legacy::Client::builder(
24493/// #     hyper_util::rt::TokioExecutor::new()
24494/// # )
24495/// # .build(
24496/// #     hyper_rustls::HttpsConnectorBuilder::new()
24497/// #         .with_native_roots()
24498/// #         .unwrap()
24499/// #         .https_or_http()
24500/// #         .enable_http1()
24501/// #         .build()
24502/// # );
24503/// # let mut hub = NetworkSecurity::new(client, auth);
24504/// // You can configure optional parameters by calling the respective setters at will, and
24505/// // execute the final call using `doit()`.
24506/// // Values shown here are possibly random and not representative !
24507/// let result = hub.projects().locations_gateway_security_policies_rules_get("name")
24508///              .doit().await;
24509/// # }
24510/// ```
24511pub struct ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C>
24512where
24513    C: 'a,
24514{
24515    hub: &'a NetworkSecurity<C>,
24516    _name: String,
24517    _delegate: Option<&'a mut dyn common::Delegate>,
24518    _additional_params: HashMap<String, String>,
24519    _scopes: BTreeSet<String>,
24520}
24521
24522impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C> {}
24523
24524impl<'a, C> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C>
24525where
24526    C: common::Connector,
24527{
24528    /// Perform the operation you have build so far.
24529    pub async fn doit(mut self) -> common::Result<(common::Response, GatewaySecurityPolicyRule)> {
24530        use std::borrow::Cow;
24531        use std::io::{Read, Seek};
24532
24533        use common::{url::Params, ToParts};
24534        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24535
24536        let mut dd = common::DefaultDelegate;
24537        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24538        dlg.begin(common::MethodInfo {
24539            id: "networksecurity.projects.locations.gatewaySecurityPolicies.rules.get",
24540            http_method: hyper::Method::GET,
24541        });
24542
24543        for &field in ["alt", "name"].iter() {
24544            if self._additional_params.contains_key(field) {
24545                dlg.finished(false);
24546                return Err(common::Error::FieldClash(field));
24547            }
24548        }
24549
24550        let mut params = Params::with_capacity(3 + self._additional_params.len());
24551        params.push("name", self._name);
24552
24553        params.extend(self._additional_params.iter());
24554
24555        params.push("alt", "json");
24556        let mut url = self.hub._base_url.clone() + "v1/{+name}";
24557        if self._scopes.is_empty() {
24558            self._scopes
24559                .insert(Scope::CloudPlatform.as_ref().to_string());
24560        }
24561
24562        #[allow(clippy::single_element_loop)]
24563        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24564            url = params.uri_replacement(url, param_name, find_this, true);
24565        }
24566        {
24567            let to_remove = ["name"];
24568            params.remove_params(&to_remove);
24569        }
24570
24571        let url = params.parse_with_url(&url);
24572
24573        loop {
24574            let token = match self
24575                .hub
24576                .auth
24577                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24578                .await
24579            {
24580                Ok(token) => token,
24581                Err(e) => match dlg.token(e) {
24582                    Ok(token) => token,
24583                    Err(e) => {
24584                        dlg.finished(false);
24585                        return Err(common::Error::MissingToken(e));
24586                    }
24587                },
24588            };
24589            let mut req_result = {
24590                let client = &self.hub.client;
24591                dlg.pre_request();
24592                let mut req_builder = hyper::Request::builder()
24593                    .method(hyper::Method::GET)
24594                    .uri(url.as_str())
24595                    .header(USER_AGENT, self.hub._user_agent.clone());
24596
24597                if let Some(token) = token.as_ref() {
24598                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24599                }
24600
24601                let request = req_builder
24602                    .header(CONTENT_LENGTH, 0_u64)
24603                    .body(common::to_body::<String>(None));
24604
24605                client.request(request.unwrap()).await
24606            };
24607
24608            match req_result {
24609                Err(err) => {
24610                    if let common::Retry::After(d) = dlg.http_error(&err) {
24611                        sleep(d).await;
24612                        continue;
24613                    }
24614                    dlg.finished(false);
24615                    return Err(common::Error::HttpError(err));
24616                }
24617                Ok(res) => {
24618                    let (mut parts, body) = res.into_parts();
24619                    let mut body = common::Body::new(body);
24620                    if !parts.status.is_success() {
24621                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24622                        let error = serde_json::from_str(&common::to_string(&bytes));
24623                        let response = common::to_response(parts, bytes.into());
24624
24625                        if let common::Retry::After(d) =
24626                            dlg.http_failure(&response, error.as_ref().ok())
24627                        {
24628                            sleep(d).await;
24629                            continue;
24630                        }
24631
24632                        dlg.finished(false);
24633
24634                        return Err(match error {
24635                            Ok(value) => common::Error::BadRequest(value),
24636                            _ => common::Error::Failure(response),
24637                        });
24638                    }
24639                    let response = {
24640                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24641                        let encoded = common::to_string(&bytes);
24642                        match serde_json::from_str(&encoded) {
24643                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24644                            Err(error) => {
24645                                dlg.response_json_decode_error(&encoded, &error);
24646                                return Err(common::Error::JsonDecodeError(
24647                                    encoded.to_string(),
24648                                    error,
24649                                ));
24650                            }
24651                        }
24652                    };
24653
24654                    dlg.finished(true);
24655                    return Ok(response);
24656                }
24657            }
24658        }
24659    }
24660
24661    /// Required. The name of the GatewaySecurityPolicyRule to retrieve. Format: projects/{project}/location/{location}/gatewaySecurityPolicies/*/rules/*
24662    ///
24663    /// Sets the *name* path property to the given value.
24664    ///
24665    /// Even though the property as already been set when instantiating this call,
24666    /// we provide this method for API completeness.
24667    pub fn name(
24668        mut self,
24669        new_value: &str,
24670    ) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C> {
24671        self._name = new_value.to_string();
24672        self
24673    }
24674    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24675    /// while executing the actual API request.
24676    ///
24677    /// ````text
24678    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24679    /// ````
24680    ///
24681    /// Sets the *delegate* property to the given value.
24682    pub fn delegate(
24683        mut self,
24684        new_value: &'a mut dyn common::Delegate,
24685    ) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C> {
24686        self._delegate = Some(new_value);
24687        self
24688    }
24689
24690    /// Set any additional parameter of the query string used in the request.
24691    /// It should be used to set parameters which are not yet available through their own
24692    /// setters.
24693    ///
24694    /// Please note that this method must not be used to set any of the known parameters
24695    /// which have their own setter method. If done anyway, the request will fail.
24696    ///
24697    /// # Additional Parameters
24698    ///
24699    /// * *$.xgafv* (query-string) - V1 error format.
24700    /// * *access_token* (query-string) - OAuth access token.
24701    /// * *alt* (query-string) - Data format for response.
24702    /// * *callback* (query-string) - JSONP
24703    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24704    /// * *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.
24705    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24706    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24707    /// * *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.
24708    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24709    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24710    pub fn param<T>(
24711        mut self,
24712        name: T,
24713        value: T,
24714    ) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C>
24715    where
24716        T: AsRef<str>,
24717    {
24718        self._additional_params
24719            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24720        self
24721    }
24722
24723    /// Identifies the authorization scope for the method you are building.
24724    ///
24725    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24726    /// [`Scope::CloudPlatform`].
24727    ///
24728    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24729    /// tokens for more than one scope.
24730    ///
24731    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24732    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24733    /// sufficient, a read-write scope will do as well.
24734    pub fn add_scope<St>(
24735        mut self,
24736        scope: St,
24737    ) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C>
24738    where
24739        St: AsRef<str>,
24740    {
24741        self._scopes.insert(String::from(scope.as_ref()));
24742        self
24743    }
24744    /// Identifies the authorization scope(s) for the method you are building.
24745    ///
24746    /// See [`Self::add_scope()`] for details.
24747    pub fn add_scopes<I, St>(
24748        mut self,
24749        scopes: I,
24750    ) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C>
24751    where
24752        I: IntoIterator<Item = St>,
24753        St: AsRef<str>,
24754    {
24755        self._scopes
24756            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24757        self
24758    }
24759
24760    /// Removes all scopes, and no default scope will be used either.
24761    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24762    /// for details).
24763    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyRuleGetCall<'a, C> {
24764        self._scopes.clear();
24765        self
24766    }
24767}
24768
24769/// Lists GatewaySecurityPolicyRules in a given project and location.
24770///
24771/// A builder for the *locations.gatewaySecurityPolicies.rules.list* method supported by a *project* resource.
24772/// It is not used directly, but through a [`ProjectMethods`] instance.
24773///
24774/// # Example
24775///
24776/// Instantiate a resource method builder
24777///
24778/// ```test_harness,no_run
24779/// # extern crate hyper;
24780/// # extern crate hyper_rustls;
24781/// # extern crate google_networksecurity1 as networksecurity1;
24782/// # async fn dox() {
24783/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24784///
24785/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24787/// #     secret,
24788/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24789/// # ).build().await.unwrap();
24790///
24791/// # let client = hyper_util::client::legacy::Client::builder(
24792/// #     hyper_util::rt::TokioExecutor::new()
24793/// # )
24794/// # .build(
24795/// #     hyper_rustls::HttpsConnectorBuilder::new()
24796/// #         .with_native_roots()
24797/// #         .unwrap()
24798/// #         .https_or_http()
24799/// #         .enable_http1()
24800/// #         .build()
24801/// # );
24802/// # let mut hub = NetworkSecurity::new(client, auth);
24803/// // You can configure optional parameters by calling the respective setters at will, and
24804/// // execute the final call using `doit()`.
24805/// // Values shown here are possibly random and not representative !
24806/// let result = hub.projects().locations_gateway_security_policies_rules_list("parent")
24807///              .page_token("dolores")
24808///              .page_size(-95)
24809///              .doit().await;
24810/// # }
24811/// ```
24812pub struct ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C>
24813where
24814    C: 'a,
24815{
24816    hub: &'a NetworkSecurity<C>,
24817    _parent: String,
24818    _page_token: Option<String>,
24819    _page_size: Option<i32>,
24820    _delegate: Option<&'a mut dyn common::Delegate>,
24821    _additional_params: HashMap<String, String>,
24822    _scopes: BTreeSet<String>,
24823}
24824
24825impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {}
24826
24827impl<'a, C> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C>
24828where
24829    C: common::Connector,
24830{
24831    /// Perform the operation you have build so far.
24832    pub async fn doit(
24833        mut self,
24834    ) -> common::Result<(common::Response, ListGatewaySecurityPolicyRulesResponse)> {
24835        use std::borrow::Cow;
24836        use std::io::{Read, Seek};
24837
24838        use common::{url::Params, ToParts};
24839        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24840
24841        let mut dd = common::DefaultDelegate;
24842        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24843        dlg.begin(common::MethodInfo {
24844            id: "networksecurity.projects.locations.gatewaySecurityPolicies.rules.list",
24845            http_method: hyper::Method::GET,
24846        });
24847
24848        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
24849            if self._additional_params.contains_key(field) {
24850                dlg.finished(false);
24851                return Err(common::Error::FieldClash(field));
24852            }
24853        }
24854
24855        let mut params = Params::with_capacity(5 + self._additional_params.len());
24856        params.push("parent", self._parent);
24857        if let Some(value) = self._page_token.as_ref() {
24858            params.push("pageToken", value);
24859        }
24860        if let Some(value) = self._page_size.as_ref() {
24861            params.push("pageSize", value.to_string());
24862        }
24863
24864        params.extend(self._additional_params.iter());
24865
24866        params.push("alt", "json");
24867        let mut url = self.hub._base_url.clone() + "v1/{+parent}/rules";
24868        if self._scopes.is_empty() {
24869            self._scopes
24870                .insert(Scope::CloudPlatform.as_ref().to_string());
24871        }
24872
24873        #[allow(clippy::single_element_loop)]
24874        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
24875            url = params.uri_replacement(url, param_name, find_this, true);
24876        }
24877        {
24878            let to_remove = ["parent"];
24879            params.remove_params(&to_remove);
24880        }
24881
24882        let url = params.parse_with_url(&url);
24883
24884        loop {
24885            let token = match self
24886                .hub
24887                .auth
24888                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24889                .await
24890            {
24891                Ok(token) => token,
24892                Err(e) => match dlg.token(e) {
24893                    Ok(token) => token,
24894                    Err(e) => {
24895                        dlg.finished(false);
24896                        return Err(common::Error::MissingToken(e));
24897                    }
24898                },
24899            };
24900            let mut req_result = {
24901                let client = &self.hub.client;
24902                dlg.pre_request();
24903                let mut req_builder = hyper::Request::builder()
24904                    .method(hyper::Method::GET)
24905                    .uri(url.as_str())
24906                    .header(USER_AGENT, self.hub._user_agent.clone());
24907
24908                if let Some(token) = token.as_ref() {
24909                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24910                }
24911
24912                let request = req_builder
24913                    .header(CONTENT_LENGTH, 0_u64)
24914                    .body(common::to_body::<String>(None));
24915
24916                client.request(request.unwrap()).await
24917            };
24918
24919            match req_result {
24920                Err(err) => {
24921                    if let common::Retry::After(d) = dlg.http_error(&err) {
24922                        sleep(d).await;
24923                        continue;
24924                    }
24925                    dlg.finished(false);
24926                    return Err(common::Error::HttpError(err));
24927                }
24928                Ok(res) => {
24929                    let (mut parts, body) = res.into_parts();
24930                    let mut body = common::Body::new(body);
24931                    if !parts.status.is_success() {
24932                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24933                        let error = serde_json::from_str(&common::to_string(&bytes));
24934                        let response = common::to_response(parts, bytes.into());
24935
24936                        if let common::Retry::After(d) =
24937                            dlg.http_failure(&response, error.as_ref().ok())
24938                        {
24939                            sleep(d).await;
24940                            continue;
24941                        }
24942
24943                        dlg.finished(false);
24944
24945                        return Err(match error {
24946                            Ok(value) => common::Error::BadRequest(value),
24947                            _ => common::Error::Failure(response),
24948                        });
24949                    }
24950                    let response = {
24951                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24952                        let encoded = common::to_string(&bytes);
24953                        match serde_json::from_str(&encoded) {
24954                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24955                            Err(error) => {
24956                                dlg.response_json_decode_error(&encoded, &error);
24957                                return Err(common::Error::JsonDecodeError(
24958                                    encoded.to_string(),
24959                                    error,
24960                                ));
24961                            }
24962                        }
24963                    };
24964
24965                    dlg.finished(true);
24966                    return Ok(response);
24967                }
24968            }
24969        }
24970    }
24971
24972    /// Required. The project, location and GatewaySecurityPolicy from which the GatewaySecurityPolicyRules should be listed, specified in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/{gatewaySecurityPolicy}`.
24973    ///
24974    /// Sets the *parent* path property to the given value.
24975    ///
24976    /// Even though the property as already been set when instantiating this call,
24977    /// we provide this method for API completeness.
24978    pub fn parent(
24979        mut self,
24980        new_value: &str,
24981    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {
24982        self._parent = new_value.to_string();
24983        self
24984    }
24985    /// The value returned by the last 'ListGatewaySecurityPolicyRulesResponse' Indicates that this is a continuation of a prior 'ListGatewaySecurityPolicyRules' call, and that the system should return the next page of data.
24986    ///
24987    /// Sets the *page token* query property to the given value.
24988    pub fn page_token(
24989        mut self,
24990        new_value: &str,
24991    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {
24992        self._page_token = Some(new_value.to_string());
24993        self
24994    }
24995    /// Maximum number of GatewaySecurityPolicyRules to return per call.
24996    ///
24997    /// Sets the *page size* query property to the given value.
24998    pub fn page_size(
24999        mut self,
25000        new_value: i32,
25001    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {
25002        self._page_size = Some(new_value);
25003        self
25004    }
25005    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25006    /// while executing the actual API request.
25007    ///
25008    /// ````text
25009    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25010    /// ````
25011    ///
25012    /// Sets the *delegate* property to the given value.
25013    pub fn delegate(
25014        mut self,
25015        new_value: &'a mut dyn common::Delegate,
25016    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {
25017        self._delegate = Some(new_value);
25018        self
25019    }
25020
25021    /// Set any additional parameter of the query string used in the request.
25022    /// It should be used to set parameters which are not yet available through their own
25023    /// setters.
25024    ///
25025    /// Please note that this method must not be used to set any of the known parameters
25026    /// which have their own setter method. If done anyway, the request will fail.
25027    ///
25028    /// # Additional Parameters
25029    ///
25030    /// * *$.xgafv* (query-string) - V1 error format.
25031    /// * *access_token* (query-string) - OAuth access token.
25032    /// * *alt* (query-string) - Data format for response.
25033    /// * *callback* (query-string) - JSONP
25034    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25035    /// * *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.
25036    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25037    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25038    /// * *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.
25039    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25040    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25041    pub fn param<T>(
25042        mut self,
25043        name: T,
25044        value: T,
25045    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C>
25046    where
25047        T: AsRef<str>,
25048    {
25049        self._additional_params
25050            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25051        self
25052    }
25053
25054    /// Identifies the authorization scope for the method you are building.
25055    ///
25056    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25057    /// [`Scope::CloudPlatform`].
25058    ///
25059    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25060    /// tokens for more than one scope.
25061    ///
25062    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25063    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25064    /// sufficient, a read-write scope will do as well.
25065    pub fn add_scope<St>(
25066        mut self,
25067        scope: St,
25068    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C>
25069    where
25070        St: AsRef<str>,
25071    {
25072        self._scopes.insert(String::from(scope.as_ref()));
25073        self
25074    }
25075    /// Identifies the authorization scope(s) for the method you are building.
25076    ///
25077    /// See [`Self::add_scope()`] for details.
25078    pub fn add_scopes<I, St>(
25079        mut self,
25080        scopes: I,
25081    ) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C>
25082    where
25083        I: IntoIterator<Item = St>,
25084        St: AsRef<str>,
25085    {
25086        self._scopes
25087            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25088        self
25089    }
25090
25091    /// Removes all scopes, and no default scope will be used either.
25092    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25093    /// for details).
25094    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyRuleListCall<'a, C> {
25095        self._scopes.clear();
25096        self
25097    }
25098}
25099
25100/// Updates the parameters of a single GatewaySecurityPolicyRule.
25101///
25102/// A builder for the *locations.gatewaySecurityPolicies.rules.patch* method supported by a *project* resource.
25103/// It is not used directly, but through a [`ProjectMethods`] instance.
25104///
25105/// # Example
25106///
25107/// Instantiate a resource method builder
25108///
25109/// ```test_harness,no_run
25110/// # extern crate hyper;
25111/// # extern crate hyper_rustls;
25112/// # extern crate google_networksecurity1 as networksecurity1;
25113/// use networksecurity1::api::GatewaySecurityPolicyRule;
25114/// # async fn dox() {
25115/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25116///
25117/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25118/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25119/// #     secret,
25120/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25121/// # ).build().await.unwrap();
25122///
25123/// # let client = hyper_util::client::legacy::Client::builder(
25124/// #     hyper_util::rt::TokioExecutor::new()
25125/// # )
25126/// # .build(
25127/// #     hyper_rustls::HttpsConnectorBuilder::new()
25128/// #         .with_native_roots()
25129/// #         .unwrap()
25130/// #         .https_or_http()
25131/// #         .enable_http1()
25132/// #         .build()
25133/// # );
25134/// # let mut hub = NetworkSecurity::new(client, auth);
25135/// // As the method needs a request, you would usually fill it with the desired information
25136/// // into the respective structure. Some of the parts shown here might not be applicable !
25137/// // Values shown here are possibly random and not representative !
25138/// let mut req = GatewaySecurityPolicyRule::default();
25139///
25140/// // You can configure optional parameters by calling the respective setters at will, and
25141/// // execute the final call using `doit()`.
25142/// // Values shown here are possibly random and not representative !
25143/// let result = hub.projects().locations_gateway_security_policies_rules_patch(req, "name")
25144///              .update_mask(FieldMask::new::<&str>(&[]))
25145///              .doit().await;
25146/// # }
25147/// ```
25148pub struct ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C>
25149where
25150    C: 'a,
25151{
25152    hub: &'a NetworkSecurity<C>,
25153    _request: GatewaySecurityPolicyRule,
25154    _name: String,
25155    _update_mask: Option<common::FieldMask>,
25156    _delegate: Option<&'a mut dyn common::Delegate>,
25157    _additional_params: HashMap<String, String>,
25158    _scopes: BTreeSet<String>,
25159}
25160
25161impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {}
25162
25163impl<'a, C> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C>
25164where
25165    C: common::Connector,
25166{
25167    /// Perform the operation you have build so far.
25168    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25169        use std::borrow::Cow;
25170        use std::io::{Read, Seek};
25171
25172        use common::{url::Params, ToParts};
25173        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25174
25175        let mut dd = common::DefaultDelegate;
25176        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25177        dlg.begin(common::MethodInfo {
25178            id: "networksecurity.projects.locations.gatewaySecurityPolicies.rules.patch",
25179            http_method: hyper::Method::PATCH,
25180        });
25181
25182        for &field in ["alt", "name", "updateMask"].iter() {
25183            if self._additional_params.contains_key(field) {
25184                dlg.finished(false);
25185                return Err(common::Error::FieldClash(field));
25186            }
25187        }
25188
25189        let mut params = Params::with_capacity(5 + self._additional_params.len());
25190        params.push("name", self._name);
25191        if let Some(value) = self._update_mask.as_ref() {
25192            params.push("updateMask", value.to_string());
25193        }
25194
25195        params.extend(self._additional_params.iter());
25196
25197        params.push("alt", "json");
25198        let mut url = self.hub._base_url.clone() + "v1/{+name}";
25199        if self._scopes.is_empty() {
25200            self._scopes
25201                .insert(Scope::CloudPlatform.as_ref().to_string());
25202        }
25203
25204        #[allow(clippy::single_element_loop)]
25205        for &(find_this, param_name) in [("{+name}", "name")].iter() {
25206            url = params.uri_replacement(url, param_name, find_this, true);
25207        }
25208        {
25209            let to_remove = ["name"];
25210            params.remove_params(&to_remove);
25211        }
25212
25213        let url = params.parse_with_url(&url);
25214
25215        let mut json_mime_type = mime::APPLICATION_JSON;
25216        let mut request_value_reader = {
25217            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25218            common::remove_json_null_values(&mut value);
25219            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25220            serde_json::to_writer(&mut dst, &value).unwrap();
25221            dst
25222        };
25223        let request_size = request_value_reader
25224            .seek(std::io::SeekFrom::End(0))
25225            .unwrap();
25226        request_value_reader
25227            .seek(std::io::SeekFrom::Start(0))
25228            .unwrap();
25229
25230        loop {
25231            let token = match self
25232                .hub
25233                .auth
25234                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25235                .await
25236            {
25237                Ok(token) => token,
25238                Err(e) => match dlg.token(e) {
25239                    Ok(token) => token,
25240                    Err(e) => {
25241                        dlg.finished(false);
25242                        return Err(common::Error::MissingToken(e));
25243                    }
25244                },
25245            };
25246            request_value_reader
25247                .seek(std::io::SeekFrom::Start(0))
25248                .unwrap();
25249            let mut req_result = {
25250                let client = &self.hub.client;
25251                dlg.pre_request();
25252                let mut req_builder = hyper::Request::builder()
25253                    .method(hyper::Method::PATCH)
25254                    .uri(url.as_str())
25255                    .header(USER_AGENT, self.hub._user_agent.clone());
25256
25257                if let Some(token) = token.as_ref() {
25258                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25259                }
25260
25261                let request = req_builder
25262                    .header(CONTENT_TYPE, json_mime_type.to_string())
25263                    .header(CONTENT_LENGTH, request_size as u64)
25264                    .body(common::to_body(
25265                        request_value_reader.get_ref().clone().into(),
25266                    ));
25267
25268                client.request(request.unwrap()).await
25269            };
25270
25271            match req_result {
25272                Err(err) => {
25273                    if let common::Retry::After(d) = dlg.http_error(&err) {
25274                        sleep(d).await;
25275                        continue;
25276                    }
25277                    dlg.finished(false);
25278                    return Err(common::Error::HttpError(err));
25279                }
25280                Ok(res) => {
25281                    let (mut parts, body) = res.into_parts();
25282                    let mut body = common::Body::new(body);
25283                    if !parts.status.is_success() {
25284                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25285                        let error = serde_json::from_str(&common::to_string(&bytes));
25286                        let response = common::to_response(parts, bytes.into());
25287
25288                        if let common::Retry::After(d) =
25289                            dlg.http_failure(&response, error.as_ref().ok())
25290                        {
25291                            sleep(d).await;
25292                            continue;
25293                        }
25294
25295                        dlg.finished(false);
25296
25297                        return Err(match error {
25298                            Ok(value) => common::Error::BadRequest(value),
25299                            _ => common::Error::Failure(response),
25300                        });
25301                    }
25302                    let response = {
25303                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25304                        let encoded = common::to_string(&bytes);
25305                        match serde_json::from_str(&encoded) {
25306                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25307                            Err(error) => {
25308                                dlg.response_json_decode_error(&encoded, &error);
25309                                return Err(common::Error::JsonDecodeError(
25310                                    encoded.to_string(),
25311                                    error,
25312                                ));
25313                            }
25314                        }
25315                    };
25316
25317                    dlg.finished(true);
25318                    return Ok(response);
25319                }
25320            }
25321        }
25322    }
25323
25324    ///
25325    /// Sets the *request* property to the given value.
25326    ///
25327    /// Even though the property as already been set when instantiating this call,
25328    /// we provide this method for API completeness.
25329    pub fn request(
25330        mut self,
25331        new_value: GatewaySecurityPolicyRule,
25332    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {
25333        self._request = new_value;
25334        self
25335    }
25336    /// Required. Immutable. Name of the resource. ame is the full resource name so projects/{project}/locations/{location}/gatewaySecurityPolicies/{gateway_security_policy}/rules/{rule} rule should match the pattern: (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
25337    ///
25338    /// Sets the *name* path property to the given value.
25339    ///
25340    /// Even though the property as already been set when instantiating this call,
25341    /// we provide this method for API completeness.
25342    pub fn name(
25343        mut self,
25344        new_value: &str,
25345    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {
25346        self._name = new_value.to_string();
25347        self
25348    }
25349    /// Optional. Field mask is used to specify the fields to be overwritten in the GatewaySecurityPolicy 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.
25350    ///
25351    /// Sets the *update mask* query property to the given value.
25352    pub fn update_mask(
25353        mut self,
25354        new_value: common::FieldMask,
25355    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {
25356        self._update_mask = Some(new_value);
25357        self
25358    }
25359    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25360    /// while executing the actual API request.
25361    ///
25362    /// ````text
25363    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25364    /// ````
25365    ///
25366    /// Sets the *delegate* property to the given value.
25367    pub fn delegate(
25368        mut self,
25369        new_value: &'a mut dyn common::Delegate,
25370    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {
25371        self._delegate = Some(new_value);
25372        self
25373    }
25374
25375    /// Set any additional parameter of the query string used in the request.
25376    /// It should be used to set parameters which are not yet available through their own
25377    /// setters.
25378    ///
25379    /// Please note that this method must not be used to set any of the known parameters
25380    /// which have their own setter method. If done anyway, the request will fail.
25381    ///
25382    /// # Additional Parameters
25383    ///
25384    /// * *$.xgafv* (query-string) - V1 error format.
25385    /// * *access_token* (query-string) - OAuth access token.
25386    /// * *alt* (query-string) - Data format for response.
25387    /// * *callback* (query-string) - JSONP
25388    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25389    /// * *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.
25390    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25391    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25392    /// * *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.
25393    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25394    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25395    pub fn param<T>(
25396        mut self,
25397        name: T,
25398        value: T,
25399    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C>
25400    where
25401        T: AsRef<str>,
25402    {
25403        self._additional_params
25404            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25405        self
25406    }
25407
25408    /// Identifies the authorization scope for the method you are building.
25409    ///
25410    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25411    /// [`Scope::CloudPlatform`].
25412    ///
25413    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25414    /// tokens for more than one scope.
25415    ///
25416    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25417    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25418    /// sufficient, a read-write scope will do as well.
25419    pub fn add_scope<St>(
25420        mut self,
25421        scope: St,
25422    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C>
25423    where
25424        St: AsRef<str>,
25425    {
25426        self._scopes.insert(String::from(scope.as_ref()));
25427        self
25428    }
25429    /// Identifies the authorization scope(s) for the method you are building.
25430    ///
25431    /// See [`Self::add_scope()`] for details.
25432    pub fn add_scopes<I, St>(
25433        mut self,
25434        scopes: I,
25435    ) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C>
25436    where
25437        I: IntoIterator<Item = St>,
25438        St: AsRef<str>,
25439    {
25440        self._scopes
25441            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25442        self
25443    }
25444
25445    /// Removes all scopes, and no default scope will be used either.
25446    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25447    /// for details).
25448    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyRulePatchCall<'a, C> {
25449        self._scopes.clear();
25450        self
25451    }
25452}
25453
25454/// Creates a new GatewaySecurityPolicy in a given project and location.
25455///
25456/// A builder for the *locations.gatewaySecurityPolicies.create* method supported by a *project* resource.
25457/// It is not used directly, but through a [`ProjectMethods`] instance.
25458///
25459/// # Example
25460///
25461/// Instantiate a resource method builder
25462///
25463/// ```test_harness,no_run
25464/// # extern crate hyper;
25465/// # extern crate hyper_rustls;
25466/// # extern crate google_networksecurity1 as networksecurity1;
25467/// use networksecurity1::api::GatewaySecurityPolicy;
25468/// # async fn dox() {
25469/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25470///
25471/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25473/// #     secret,
25474/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25475/// # ).build().await.unwrap();
25476///
25477/// # let client = hyper_util::client::legacy::Client::builder(
25478/// #     hyper_util::rt::TokioExecutor::new()
25479/// # )
25480/// # .build(
25481/// #     hyper_rustls::HttpsConnectorBuilder::new()
25482/// #         .with_native_roots()
25483/// #         .unwrap()
25484/// #         .https_or_http()
25485/// #         .enable_http1()
25486/// #         .build()
25487/// # );
25488/// # let mut hub = NetworkSecurity::new(client, auth);
25489/// // As the method needs a request, you would usually fill it with the desired information
25490/// // into the respective structure. Some of the parts shown here might not be applicable !
25491/// // Values shown here are possibly random and not representative !
25492/// let mut req = GatewaySecurityPolicy::default();
25493///
25494/// // You can configure optional parameters by calling the respective setters at will, and
25495/// // execute the final call using `doit()`.
25496/// // Values shown here are possibly random and not representative !
25497/// let result = hub.projects().locations_gateway_security_policies_create(req, "parent")
25498///              .gateway_security_policy_id("amet")
25499///              .doit().await;
25500/// # }
25501/// ```
25502pub struct ProjectLocationGatewaySecurityPolicyCreateCall<'a, C>
25503where
25504    C: 'a,
25505{
25506    hub: &'a NetworkSecurity<C>,
25507    _request: GatewaySecurityPolicy,
25508    _parent: String,
25509    _gateway_security_policy_id: Option<String>,
25510    _delegate: Option<&'a mut dyn common::Delegate>,
25511    _additional_params: HashMap<String, String>,
25512    _scopes: BTreeSet<String>,
25513}
25514
25515impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {}
25516
25517impl<'a, C> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C>
25518where
25519    C: common::Connector,
25520{
25521    /// Perform the operation you have build so far.
25522    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25523        use std::borrow::Cow;
25524        use std::io::{Read, Seek};
25525
25526        use common::{url::Params, ToParts};
25527        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25528
25529        let mut dd = common::DefaultDelegate;
25530        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25531        dlg.begin(common::MethodInfo {
25532            id: "networksecurity.projects.locations.gatewaySecurityPolicies.create",
25533            http_method: hyper::Method::POST,
25534        });
25535
25536        for &field in ["alt", "parent", "gatewaySecurityPolicyId"].iter() {
25537            if self._additional_params.contains_key(field) {
25538                dlg.finished(false);
25539                return Err(common::Error::FieldClash(field));
25540            }
25541        }
25542
25543        let mut params = Params::with_capacity(5 + self._additional_params.len());
25544        params.push("parent", self._parent);
25545        if let Some(value) = self._gateway_security_policy_id.as_ref() {
25546            params.push("gatewaySecurityPolicyId", value);
25547        }
25548
25549        params.extend(self._additional_params.iter());
25550
25551        params.push("alt", "json");
25552        let mut url = self.hub._base_url.clone() + "v1/{+parent}/gatewaySecurityPolicies";
25553        if self._scopes.is_empty() {
25554            self._scopes
25555                .insert(Scope::CloudPlatform.as_ref().to_string());
25556        }
25557
25558        #[allow(clippy::single_element_loop)]
25559        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
25560            url = params.uri_replacement(url, param_name, find_this, true);
25561        }
25562        {
25563            let to_remove = ["parent"];
25564            params.remove_params(&to_remove);
25565        }
25566
25567        let url = params.parse_with_url(&url);
25568
25569        let mut json_mime_type = mime::APPLICATION_JSON;
25570        let mut request_value_reader = {
25571            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25572            common::remove_json_null_values(&mut value);
25573            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25574            serde_json::to_writer(&mut dst, &value).unwrap();
25575            dst
25576        };
25577        let request_size = request_value_reader
25578            .seek(std::io::SeekFrom::End(0))
25579            .unwrap();
25580        request_value_reader
25581            .seek(std::io::SeekFrom::Start(0))
25582            .unwrap();
25583
25584        loop {
25585            let token = match self
25586                .hub
25587                .auth
25588                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25589                .await
25590            {
25591                Ok(token) => token,
25592                Err(e) => match dlg.token(e) {
25593                    Ok(token) => token,
25594                    Err(e) => {
25595                        dlg.finished(false);
25596                        return Err(common::Error::MissingToken(e));
25597                    }
25598                },
25599            };
25600            request_value_reader
25601                .seek(std::io::SeekFrom::Start(0))
25602                .unwrap();
25603            let mut req_result = {
25604                let client = &self.hub.client;
25605                dlg.pre_request();
25606                let mut req_builder = hyper::Request::builder()
25607                    .method(hyper::Method::POST)
25608                    .uri(url.as_str())
25609                    .header(USER_AGENT, self.hub._user_agent.clone());
25610
25611                if let Some(token) = token.as_ref() {
25612                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25613                }
25614
25615                let request = req_builder
25616                    .header(CONTENT_TYPE, json_mime_type.to_string())
25617                    .header(CONTENT_LENGTH, request_size as u64)
25618                    .body(common::to_body(
25619                        request_value_reader.get_ref().clone().into(),
25620                    ));
25621
25622                client.request(request.unwrap()).await
25623            };
25624
25625            match req_result {
25626                Err(err) => {
25627                    if let common::Retry::After(d) = dlg.http_error(&err) {
25628                        sleep(d).await;
25629                        continue;
25630                    }
25631                    dlg.finished(false);
25632                    return Err(common::Error::HttpError(err));
25633                }
25634                Ok(res) => {
25635                    let (mut parts, body) = res.into_parts();
25636                    let mut body = common::Body::new(body);
25637                    if !parts.status.is_success() {
25638                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25639                        let error = serde_json::from_str(&common::to_string(&bytes));
25640                        let response = common::to_response(parts, bytes.into());
25641
25642                        if let common::Retry::After(d) =
25643                            dlg.http_failure(&response, error.as_ref().ok())
25644                        {
25645                            sleep(d).await;
25646                            continue;
25647                        }
25648
25649                        dlg.finished(false);
25650
25651                        return Err(match error {
25652                            Ok(value) => common::Error::BadRequest(value),
25653                            _ => common::Error::Failure(response),
25654                        });
25655                    }
25656                    let response = {
25657                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25658                        let encoded = common::to_string(&bytes);
25659                        match serde_json::from_str(&encoded) {
25660                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25661                            Err(error) => {
25662                                dlg.response_json_decode_error(&encoded, &error);
25663                                return Err(common::Error::JsonDecodeError(
25664                                    encoded.to_string(),
25665                                    error,
25666                                ));
25667                            }
25668                        }
25669                    };
25670
25671                    dlg.finished(true);
25672                    return Ok(response);
25673                }
25674            }
25675        }
25676    }
25677
25678    ///
25679    /// Sets the *request* property to the given value.
25680    ///
25681    /// Even though the property as already been set when instantiating this call,
25682    /// we provide this method for API completeness.
25683    pub fn request(
25684        mut self,
25685        new_value: GatewaySecurityPolicy,
25686    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {
25687        self._request = new_value;
25688        self
25689    }
25690    /// Required. The parent resource of the GatewaySecurityPolicy. Must be in the format `projects/{project}/locations/{location}`.
25691    ///
25692    /// Sets the *parent* path property to the given value.
25693    ///
25694    /// Even though the property as already been set when instantiating this call,
25695    /// we provide this method for API completeness.
25696    pub fn parent(
25697        mut self,
25698        new_value: &str,
25699    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {
25700        self._parent = new_value.to_string();
25701        self
25702    }
25703    /// Required. Short name of the GatewaySecurityPolicy resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "gateway_security_policy1".
25704    ///
25705    /// Sets the *gateway security policy id* query property to the given value.
25706    pub fn gateway_security_policy_id(
25707        mut self,
25708        new_value: &str,
25709    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {
25710        self._gateway_security_policy_id = Some(new_value.to_string());
25711        self
25712    }
25713    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25714    /// while executing the actual API request.
25715    ///
25716    /// ````text
25717    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25718    /// ````
25719    ///
25720    /// Sets the *delegate* property to the given value.
25721    pub fn delegate(
25722        mut self,
25723        new_value: &'a mut dyn common::Delegate,
25724    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {
25725        self._delegate = Some(new_value);
25726        self
25727    }
25728
25729    /// Set any additional parameter of the query string used in the request.
25730    /// It should be used to set parameters which are not yet available through their own
25731    /// setters.
25732    ///
25733    /// Please note that this method must not be used to set any of the known parameters
25734    /// which have their own setter method. If done anyway, the request will fail.
25735    ///
25736    /// # Additional Parameters
25737    ///
25738    /// * *$.xgafv* (query-string) - V1 error format.
25739    /// * *access_token* (query-string) - OAuth access token.
25740    /// * *alt* (query-string) - Data format for response.
25741    /// * *callback* (query-string) - JSONP
25742    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25743    /// * *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.
25744    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25745    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25746    /// * *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.
25747    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25748    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25749    pub fn param<T>(
25750        mut self,
25751        name: T,
25752        value: T,
25753    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C>
25754    where
25755        T: AsRef<str>,
25756    {
25757        self._additional_params
25758            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25759        self
25760    }
25761
25762    /// Identifies the authorization scope for the method you are building.
25763    ///
25764    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25765    /// [`Scope::CloudPlatform`].
25766    ///
25767    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25768    /// tokens for more than one scope.
25769    ///
25770    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25771    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25772    /// sufficient, a read-write scope will do as well.
25773    pub fn add_scope<St>(
25774        mut self,
25775        scope: St,
25776    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C>
25777    where
25778        St: AsRef<str>,
25779    {
25780        self._scopes.insert(String::from(scope.as_ref()));
25781        self
25782    }
25783    /// Identifies the authorization scope(s) for the method you are building.
25784    ///
25785    /// See [`Self::add_scope()`] for details.
25786    pub fn add_scopes<I, St>(
25787        mut self,
25788        scopes: I,
25789    ) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C>
25790    where
25791        I: IntoIterator<Item = St>,
25792        St: AsRef<str>,
25793    {
25794        self._scopes
25795            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25796        self
25797    }
25798
25799    /// Removes all scopes, and no default scope will be used either.
25800    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25801    /// for details).
25802    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyCreateCall<'a, C> {
25803        self._scopes.clear();
25804        self
25805    }
25806}
25807
25808/// Deletes a single GatewaySecurityPolicy.
25809///
25810/// A builder for the *locations.gatewaySecurityPolicies.delete* method supported by a *project* resource.
25811/// It is not used directly, but through a [`ProjectMethods`] instance.
25812///
25813/// # Example
25814///
25815/// Instantiate a resource method builder
25816///
25817/// ```test_harness,no_run
25818/// # extern crate hyper;
25819/// # extern crate hyper_rustls;
25820/// # extern crate google_networksecurity1 as networksecurity1;
25821/// # async fn dox() {
25822/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25823///
25824/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25825/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25826/// #     secret,
25827/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25828/// # ).build().await.unwrap();
25829///
25830/// # let client = hyper_util::client::legacy::Client::builder(
25831/// #     hyper_util::rt::TokioExecutor::new()
25832/// # )
25833/// # .build(
25834/// #     hyper_rustls::HttpsConnectorBuilder::new()
25835/// #         .with_native_roots()
25836/// #         .unwrap()
25837/// #         .https_or_http()
25838/// #         .enable_http1()
25839/// #         .build()
25840/// # );
25841/// # let mut hub = NetworkSecurity::new(client, auth);
25842/// // You can configure optional parameters by calling the respective setters at will, and
25843/// // execute the final call using `doit()`.
25844/// // Values shown here are possibly random and not representative !
25845/// let result = hub.projects().locations_gateway_security_policies_delete("name")
25846///              .doit().await;
25847/// # }
25848/// ```
25849pub struct ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C>
25850where
25851    C: 'a,
25852{
25853    hub: &'a NetworkSecurity<C>,
25854    _name: String,
25855    _delegate: Option<&'a mut dyn common::Delegate>,
25856    _additional_params: HashMap<String, String>,
25857    _scopes: BTreeSet<String>,
25858}
25859
25860impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C> {}
25861
25862impl<'a, C> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C>
25863where
25864    C: common::Connector,
25865{
25866    /// Perform the operation you have build so far.
25867    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25868        use std::borrow::Cow;
25869        use std::io::{Read, Seek};
25870
25871        use common::{url::Params, ToParts};
25872        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25873
25874        let mut dd = common::DefaultDelegate;
25875        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25876        dlg.begin(common::MethodInfo {
25877            id: "networksecurity.projects.locations.gatewaySecurityPolicies.delete",
25878            http_method: hyper::Method::DELETE,
25879        });
25880
25881        for &field in ["alt", "name"].iter() {
25882            if self._additional_params.contains_key(field) {
25883                dlg.finished(false);
25884                return Err(common::Error::FieldClash(field));
25885            }
25886        }
25887
25888        let mut params = Params::with_capacity(3 + self._additional_params.len());
25889        params.push("name", self._name);
25890
25891        params.extend(self._additional_params.iter());
25892
25893        params.push("alt", "json");
25894        let mut url = self.hub._base_url.clone() + "v1/{+name}";
25895        if self._scopes.is_empty() {
25896            self._scopes
25897                .insert(Scope::CloudPlatform.as_ref().to_string());
25898        }
25899
25900        #[allow(clippy::single_element_loop)]
25901        for &(find_this, param_name) in [("{+name}", "name")].iter() {
25902            url = params.uri_replacement(url, param_name, find_this, true);
25903        }
25904        {
25905            let to_remove = ["name"];
25906            params.remove_params(&to_remove);
25907        }
25908
25909        let url = params.parse_with_url(&url);
25910
25911        loop {
25912            let token = match self
25913                .hub
25914                .auth
25915                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25916                .await
25917            {
25918                Ok(token) => token,
25919                Err(e) => match dlg.token(e) {
25920                    Ok(token) => token,
25921                    Err(e) => {
25922                        dlg.finished(false);
25923                        return Err(common::Error::MissingToken(e));
25924                    }
25925                },
25926            };
25927            let mut req_result = {
25928                let client = &self.hub.client;
25929                dlg.pre_request();
25930                let mut req_builder = hyper::Request::builder()
25931                    .method(hyper::Method::DELETE)
25932                    .uri(url.as_str())
25933                    .header(USER_AGENT, self.hub._user_agent.clone());
25934
25935                if let Some(token) = token.as_ref() {
25936                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25937                }
25938
25939                let request = req_builder
25940                    .header(CONTENT_LENGTH, 0_u64)
25941                    .body(common::to_body::<String>(None));
25942
25943                client.request(request.unwrap()).await
25944            };
25945
25946            match req_result {
25947                Err(err) => {
25948                    if let common::Retry::After(d) = dlg.http_error(&err) {
25949                        sleep(d).await;
25950                        continue;
25951                    }
25952                    dlg.finished(false);
25953                    return Err(common::Error::HttpError(err));
25954                }
25955                Ok(res) => {
25956                    let (mut parts, body) = res.into_parts();
25957                    let mut body = common::Body::new(body);
25958                    if !parts.status.is_success() {
25959                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25960                        let error = serde_json::from_str(&common::to_string(&bytes));
25961                        let response = common::to_response(parts, bytes.into());
25962
25963                        if let common::Retry::After(d) =
25964                            dlg.http_failure(&response, error.as_ref().ok())
25965                        {
25966                            sleep(d).await;
25967                            continue;
25968                        }
25969
25970                        dlg.finished(false);
25971
25972                        return Err(match error {
25973                            Ok(value) => common::Error::BadRequest(value),
25974                            _ => common::Error::Failure(response),
25975                        });
25976                    }
25977                    let response = {
25978                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25979                        let encoded = common::to_string(&bytes);
25980                        match serde_json::from_str(&encoded) {
25981                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25982                            Err(error) => {
25983                                dlg.response_json_decode_error(&encoded, &error);
25984                                return Err(common::Error::JsonDecodeError(
25985                                    encoded.to_string(),
25986                                    error,
25987                                ));
25988                            }
25989                        }
25990                    };
25991
25992                    dlg.finished(true);
25993                    return Ok(response);
25994                }
25995            }
25996        }
25997    }
25998
25999    /// Required. A name of the GatewaySecurityPolicy to delete. Must be in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/*`.
26000    ///
26001    /// Sets the *name* path property to the given value.
26002    ///
26003    /// Even though the property as already been set when instantiating this call,
26004    /// we provide this method for API completeness.
26005    pub fn name(
26006        mut self,
26007        new_value: &str,
26008    ) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C> {
26009        self._name = new_value.to_string();
26010        self
26011    }
26012    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26013    /// while executing the actual API request.
26014    ///
26015    /// ````text
26016    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26017    /// ````
26018    ///
26019    /// Sets the *delegate* property to the given value.
26020    pub fn delegate(
26021        mut self,
26022        new_value: &'a mut dyn common::Delegate,
26023    ) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C> {
26024        self._delegate = Some(new_value);
26025        self
26026    }
26027
26028    /// Set any additional parameter of the query string used in the request.
26029    /// It should be used to set parameters which are not yet available through their own
26030    /// setters.
26031    ///
26032    /// Please note that this method must not be used to set any of the known parameters
26033    /// which have their own setter method. If done anyway, the request will fail.
26034    ///
26035    /// # Additional Parameters
26036    ///
26037    /// * *$.xgafv* (query-string) - V1 error format.
26038    /// * *access_token* (query-string) - OAuth access token.
26039    /// * *alt* (query-string) - Data format for response.
26040    /// * *callback* (query-string) - JSONP
26041    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26042    /// * *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.
26043    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26044    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26045    /// * *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.
26046    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26047    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26048    pub fn param<T>(
26049        mut self,
26050        name: T,
26051        value: T,
26052    ) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C>
26053    where
26054        T: AsRef<str>,
26055    {
26056        self._additional_params
26057            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26058        self
26059    }
26060
26061    /// Identifies the authorization scope for the method you are building.
26062    ///
26063    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26064    /// [`Scope::CloudPlatform`].
26065    ///
26066    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26067    /// tokens for more than one scope.
26068    ///
26069    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26070    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26071    /// sufficient, a read-write scope will do as well.
26072    pub fn add_scope<St>(
26073        mut self,
26074        scope: St,
26075    ) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C>
26076    where
26077        St: AsRef<str>,
26078    {
26079        self._scopes.insert(String::from(scope.as_ref()));
26080        self
26081    }
26082    /// Identifies the authorization scope(s) for the method you are building.
26083    ///
26084    /// See [`Self::add_scope()`] for details.
26085    pub fn add_scopes<I, St>(
26086        mut self,
26087        scopes: I,
26088    ) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C>
26089    where
26090        I: IntoIterator<Item = St>,
26091        St: AsRef<str>,
26092    {
26093        self._scopes
26094            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26095        self
26096    }
26097
26098    /// Removes all scopes, and no default scope will be used either.
26099    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26100    /// for details).
26101    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyDeleteCall<'a, C> {
26102        self._scopes.clear();
26103        self
26104    }
26105}
26106
26107/// Gets details of a single GatewaySecurityPolicy.
26108///
26109/// A builder for the *locations.gatewaySecurityPolicies.get* method supported by a *project* resource.
26110/// It is not used directly, but through a [`ProjectMethods`] instance.
26111///
26112/// # Example
26113///
26114/// Instantiate a resource method builder
26115///
26116/// ```test_harness,no_run
26117/// # extern crate hyper;
26118/// # extern crate hyper_rustls;
26119/// # extern crate google_networksecurity1 as networksecurity1;
26120/// # async fn dox() {
26121/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26122///
26123/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26124/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26125/// #     secret,
26126/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26127/// # ).build().await.unwrap();
26128///
26129/// # let client = hyper_util::client::legacy::Client::builder(
26130/// #     hyper_util::rt::TokioExecutor::new()
26131/// # )
26132/// # .build(
26133/// #     hyper_rustls::HttpsConnectorBuilder::new()
26134/// #         .with_native_roots()
26135/// #         .unwrap()
26136/// #         .https_or_http()
26137/// #         .enable_http1()
26138/// #         .build()
26139/// # );
26140/// # let mut hub = NetworkSecurity::new(client, auth);
26141/// // You can configure optional parameters by calling the respective setters at will, and
26142/// // execute the final call using `doit()`.
26143/// // Values shown here are possibly random and not representative !
26144/// let result = hub.projects().locations_gateway_security_policies_get("name")
26145///              .doit().await;
26146/// # }
26147/// ```
26148pub struct ProjectLocationGatewaySecurityPolicyGetCall<'a, C>
26149where
26150    C: 'a,
26151{
26152    hub: &'a NetworkSecurity<C>,
26153    _name: String,
26154    _delegate: Option<&'a mut dyn common::Delegate>,
26155    _additional_params: HashMap<String, String>,
26156    _scopes: BTreeSet<String>,
26157}
26158
26159impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyGetCall<'a, C> {}
26160
26161impl<'a, C> ProjectLocationGatewaySecurityPolicyGetCall<'a, C>
26162where
26163    C: common::Connector,
26164{
26165    /// Perform the operation you have build so far.
26166    pub async fn doit(mut self) -> common::Result<(common::Response, GatewaySecurityPolicy)> {
26167        use std::borrow::Cow;
26168        use std::io::{Read, Seek};
26169
26170        use common::{url::Params, ToParts};
26171        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26172
26173        let mut dd = common::DefaultDelegate;
26174        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26175        dlg.begin(common::MethodInfo {
26176            id: "networksecurity.projects.locations.gatewaySecurityPolicies.get",
26177            http_method: hyper::Method::GET,
26178        });
26179
26180        for &field in ["alt", "name"].iter() {
26181            if self._additional_params.contains_key(field) {
26182                dlg.finished(false);
26183                return Err(common::Error::FieldClash(field));
26184            }
26185        }
26186
26187        let mut params = Params::with_capacity(3 + self._additional_params.len());
26188        params.push("name", self._name);
26189
26190        params.extend(self._additional_params.iter());
26191
26192        params.push("alt", "json");
26193        let mut url = self.hub._base_url.clone() + "v1/{+name}";
26194        if self._scopes.is_empty() {
26195            self._scopes
26196                .insert(Scope::CloudPlatform.as_ref().to_string());
26197        }
26198
26199        #[allow(clippy::single_element_loop)]
26200        for &(find_this, param_name) in [("{+name}", "name")].iter() {
26201            url = params.uri_replacement(url, param_name, find_this, true);
26202        }
26203        {
26204            let to_remove = ["name"];
26205            params.remove_params(&to_remove);
26206        }
26207
26208        let url = params.parse_with_url(&url);
26209
26210        loop {
26211            let token = match self
26212                .hub
26213                .auth
26214                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26215                .await
26216            {
26217                Ok(token) => token,
26218                Err(e) => match dlg.token(e) {
26219                    Ok(token) => token,
26220                    Err(e) => {
26221                        dlg.finished(false);
26222                        return Err(common::Error::MissingToken(e));
26223                    }
26224                },
26225            };
26226            let mut req_result = {
26227                let client = &self.hub.client;
26228                dlg.pre_request();
26229                let mut req_builder = hyper::Request::builder()
26230                    .method(hyper::Method::GET)
26231                    .uri(url.as_str())
26232                    .header(USER_AGENT, self.hub._user_agent.clone());
26233
26234                if let Some(token) = token.as_ref() {
26235                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26236                }
26237
26238                let request = req_builder
26239                    .header(CONTENT_LENGTH, 0_u64)
26240                    .body(common::to_body::<String>(None));
26241
26242                client.request(request.unwrap()).await
26243            };
26244
26245            match req_result {
26246                Err(err) => {
26247                    if let common::Retry::After(d) = dlg.http_error(&err) {
26248                        sleep(d).await;
26249                        continue;
26250                    }
26251                    dlg.finished(false);
26252                    return Err(common::Error::HttpError(err));
26253                }
26254                Ok(res) => {
26255                    let (mut parts, body) = res.into_parts();
26256                    let mut body = common::Body::new(body);
26257                    if !parts.status.is_success() {
26258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26259                        let error = serde_json::from_str(&common::to_string(&bytes));
26260                        let response = common::to_response(parts, bytes.into());
26261
26262                        if let common::Retry::After(d) =
26263                            dlg.http_failure(&response, error.as_ref().ok())
26264                        {
26265                            sleep(d).await;
26266                            continue;
26267                        }
26268
26269                        dlg.finished(false);
26270
26271                        return Err(match error {
26272                            Ok(value) => common::Error::BadRequest(value),
26273                            _ => common::Error::Failure(response),
26274                        });
26275                    }
26276                    let response = {
26277                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26278                        let encoded = common::to_string(&bytes);
26279                        match serde_json::from_str(&encoded) {
26280                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26281                            Err(error) => {
26282                                dlg.response_json_decode_error(&encoded, &error);
26283                                return Err(common::Error::JsonDecodeError(
26284                                    encoded.to_string(),
26285                                    error,
26286                                ));
26287                            }
26288                        }
26289                    };
26290
26291                    dlg.finished(true);
26292                    return Ok(response);
26293                }
26294            }
26295        }
26296    }
26297
26298    /// Required. A name of the GatewaySecurityPolicy to get. Must be in the format `projects/{project}/locations/{location}/gatewaySecurityPolicies/*`.
26299    ///
26300    /// Sets the *name* path property to the given value.
26301    ///
26302    /// Even though the property as already been set when instantiating this call,
26303    /// we provide this method for API completeness.
26304    pub fn name(mut self, new_value: &str) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C> {
26305        self._name = new_value.to_string();
26306        self
26307    }
26308    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26309    /// while executing the actual API request.
26310    ///
26311    /// ````text
26312    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26313    /// ````
26314    ///
26315    /// Sets the *delegate* property to the given value.
26316    pub fn delegate(
26317        mut self,
26318        new_value: &'a mut dyn common::Delegate,
26319    ) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C> {
26320        self._delegate = Some(new_value);
26321        self
26322    }
26323
26324    /// Set any additional parameter of the query string used in the request.
26325    /// It should be used to set parameters which are not yet available through their own
26326    /// setters.
26327    ///
26328    /// Please note that this method must not be used to set any of the known parameters
26329    /// which have their own setter method. If done anyway, the request will fail.
26330    ///
26331    /// # Additional Parameters
26332    ///
26333    /// * *$.xgafv* (query-string) - V1 error format.
26334    /// * *access_token* (query-string) - OAuth access token.
26335    /// * *alt* (query-string) - Data format for response.
26336    /// * *callback* (query-string) - JSONP
26337    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26338    /// * *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.
26339    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26340    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26341    /// * *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.
26342    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26343    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26344    pub fn param<T>(
26345        mut self,
26346        name: T,
26347        value: T,
26348    ) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C>
26349    where
26350        T: AsRef<str>,
26351    {
26352        self._additional_params
26353            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26354        self
26355    }
26356
26357    /// Identifies the authorization scope for the method you are building.
26358    ///
26359    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26360    /// [`Scope::CloudPlatform`].
26361    ///
26362    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26363    /// tokens for more than one scope.
26364    ///
26365    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26366    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26367    /// sufficient, a read-write scope will do as well.
26368    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C>
26369    where
26370        St: AsRef<str>,
26371    {
26372        self._scopes.insert(String::from(scope.as_ref()));
26373        self
26374    }
26375    /// Identifies the authorization scope(s) for the method you are building.
26376    ///
26377    /// See [`Self::add_scope()`] for details.
26378    pub fn add_scopes<I, St>(
26379        mut self,
26380        scopes: I,
26381    ) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C>
26382    where
26383        I: IntoIterator<Item = St>,
26384        St: AsRef<str>,
26385    {
26386        self._scopes
26387            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26388        self
26389    }
26390
26391    /// Removes all scopes, and no default scope will be used either.
26392    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26393    /// for details).
26394    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyGetCall<'a, C> {
26395        self._scopes.clear();
26396        self
26397    }
26398}
26399
26400/// Lists GatewaySecurityPolicies in a given project and location.
26401///
26402/// A builder for the *locations.gatewaySecurityPolicies.list* method supported by a *project* resource.
26403/// It is not used directly, but through a [`ProjectMethods`] instance.
26404///
26405/// # Example
26406///
26407/// Instantiate a resource method builder
26408///
26409/// ```test_harness,no_run
26410/// # extern crate hyper;
26411/// # extern crate hyper_rustls;
26412/// # extern crate google_networksecurity1 as networksecurity1;
26413/// # async fn dox() {
26414/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26415///
26416/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26417/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26418/// #     secret,
26419/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26420/// # ).build().await.unwrap();
26421///
26422/// # let client = hyper_util::client::legacy::Client::builder(
26423/// #     hyper_util::rt::TokioExecutor::new()
26424/// # )
26425/// # .build(
26426/// #     hyper_rustls::HttpsConnectorBuilder::new()
26427/// #         .with_native_roots()
26428/// #         .unwrap()
26429/// #         .https_or_http()
26430/// #         .enable_http1()
26431/// #         .build()
26432/// # );
26433/// # let mut hub = NetworkSecurity::new(client, auth);
26434/// // You can configure optional parameters by calling the respective setters at will, and
26435/// // execute the final call using `doit()`.
26436/// // Values shown here are possibly random and not representative !
26437/// let result = hub.projects().locations_gateway_security_policies_list("parent")
26438///              .page_token("consetetur")
26439///              .page_size(-46)
26440///              .doit().await;
26441/// # }
26442/// ```
26443pub struct ProjectLocationGatewaySecurityPolicyListCall<'a, C>
26444where
26445    C: 'a,
26446{
26447    hub: &'a NetworkSecurity<C>,
26448    _parent: String,
26449    _page_token: Option<String>,
26450    _page_size: Option<i32>,
26451    _delegate: Option<&'a mut dyn common::Delegate>,
26452    _additional_params: HashMap<String, String>,
26453    _scopes: BTreeSet<String>,
26454}
26455
26456impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyListCall<'a, C> {}
26457
26458impl<'a, C> ProjectLocationGatewaySecurityPolicyListCall<'a, C>
26459where
26460    C: common::Connector,
26461{
26462    /// Perform the operation you have build so far.
26463    pub async fn doit(
26464        mut self,
26465    ) -> common::Result<(common::Response, ListGatewaySecurityPoliciesResponse)> {
26466        use std::borrow::Cow;
26467        use std::io::{Read, Seek};
26468
26469        use common::{url::Params, ToParts};
26470        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26471
26472        let mut dd = common::DefaultDelegate;
26473        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26474        dlg.begin(common::MethodInfo {
26475            id: "networksecurity.projects.locations.gatewaySecurityPolicies.list",
26476            http_method: hyper::Method::GET,
26477        });
26478
26479        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
26480            if self._additional_params.contains_key(field) {
26481                dlg.finished(false);
26482                return Err(common::Error::FieldClash(field));
26483            }
26484        }
26485
26486        let mut params = Params::with_capacity(5 + self._additional_params.len());
26487        params.push("parent", self._parent);
26488        if let Some(value) = self._page_token.as_ref() {
26489            params.push("pageToken", value);
26490        }
26491        if let Some(value) = self._page_size.as_ref() {
26492            params.push("pageSize", value.to_string());
26493        }
26494
26495        params.extend(self._additional_params.iter());
26496
26497        params.push("alt", "json");
26498        let mut url = self.hub._base_url.clone() + "v1/{+parent}/gatewaySecurityPolicies";
26499        if self._scopes.is_empty() {
26500            self._scopes
26501                .insert(Scope::CloudPlatform.as_ref().to_string());
26502        }
26503
26504        #[allow(clippy::single_element_loop)]
26505        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
26506            url = params.uri_replacement(url, param_name, find_this, true);
26507        }
26508        {
26509            let to_remove = ["parent"];
26510            params.remove_params(&to_remove);
26511        }
26512
26513        let url = params.parse_with_url(&url);
26514
26515        loop {
26516            let token = match self
26517                .hub
26518                .auth
26519                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26520                .await
26521            {
26522                Ok(token) => token,
26523                Err(e) => match dlg.token(e) {
26524                    Ok(token) => token,
26525                    Err(e) => {
26526                        dlg.finished(false);
26527                        return Err(common::Error::MissingToken(e));
26528                    }
26529                },
26530            };
26531            let mut req_result = {
26532                let client = &self.hub.client;
26533                dlg.pre_request();
26534                let mut req_builder = hyper::Request::builder()
26535                    .method(hyper::Method::GET)
26536                    .uri(url.as_str())
26537                    .header(USER_AGENT, self.hub._user_agent.clone());
26538
26539                if let Some(token) = token.as_ref() {
26540                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26541                }
26542
26543                let request = req_builder
26544                    .header(CONTENT_LENGTH, 0_u64)
26545                    .body(common::to_body::<String>(None));
26546
26547                client.request(request.unwrap()).await
26548            };
26549
26550            match req_result {
26551                Err(err) => {
26552                    if let common::Retry::After(d) = dlg.http_error(&err) {
26553                        sleep(d).await;
26554                        continue;
26555                    }
26556                    dlg.finished(false);
26557                    return Err(common::Error::HttpError(err));
26558                }
26559                Ok(res) => {
26560                    let (mut parts, body) = res.into_parts();
26561                    let mut body = common::Body::new(body);
26562                    if !parts.status.is_success() {
26563                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26564                        let error = serde_json::from_str(&common::to_string(&bytes));
26565                        let response = common::to_response(parts, bytes.into());
26566
26567                        if let common::Retry::After(d) =
26568                            dlg.http_failure(&response, error.as_ref().ok())
26569                        {
26570                            sleep(d).await;
26571                            continue;
26572                        }
26573
26574                        dlg.finished(false);
26575
26576                        return Err(match error {
26577                            Ok(value) => common::Error::BadRequest(value),
26578                            _ => common::Error::Failure(response),
26579                        });
26580                    }
26581                    let response = {
26582                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26583                        let encoded = common::to_string(&bytes);
26584                        match serde_json::from_str(&encoded) {
26585                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26586                            Err(error) => {
26587                                dlg.response_json_decode_error(&encoded, &error);
26588                                return Err(common::Error::JsonDecodeError(
26589                                    encoded.to_string(),
26590                                    error,
26591                                ));
26592                            }
26593                        }
26594                    };
26595
26596                    dlg.finished(true);
26597                    return Ok(response);
26598                }
26599            }
26600        }
26601    }
26602
26603    /// Required. The project and location from which the GatewaySecurityPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
26604    ///
26605    /// Sets the *parent* path property to the given value.
26606    ///
26607    /// Even though the property as already been set when instantiating this call,
26608    /// we provide this method for API completeness.
26609    pub fn parent(
26610        mut self,
26611        new_value: &str,
26612    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C> {
26613        self._parent = new_value.to_string();
26614        self
26615    }
26616    /// The value returned by the last 'ListGatewaySecurityPoliciesResponse' Indicates that this is a continuation of a prior 'ListGatewaySecurityPolicies' call, and that the system should return the next page of data.
26617    ///
26618    /// Sets the *page token* query property to the given value.
26619    pub fn page_token(
26620        mut self,
26621        new_value: &str,
26622    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C> {
26623        self._page_token = Some(new_value.to_string());
26624        self
26625    }
26626    /// Maximum number of GatewaySecurityPolicies to return per call.
26627    ///
26628    /// Sets the *page size* query property to the given value.
26629    pub fn page_size(
26630        mut self,
26631        new_value: i32,
26632    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C> {
26633        self._page_size = Some(new_value);
26634        self
26635    }
26636    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26637    /// while executing the actual API request.
26638    ///
26639    /// ````text
26640    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26641    /// ````
26642    ///
26643    /// Sets the *delegate* property to the given value.
26644    pub fn delegate(
26645        mut self,
26646        new_value: &'a mut dyn common::Delegate,
26647    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C> {
26648        self._delegate = Some(new_value);
26649        self
26650    }
26651
26652    /// Set any additional parameter of the query string used in the request.
26653    /// It should be used to set parameters which are not yet available through their own
26654    /// setters.
26655    ///
26656    /// Please note that this method must not be used to set any of the known parameters
26657    /// which have their own setter method. If done anyway, the request will fail.
26658    ///
26659    /// # Additional Parameters
26660    ///
26661    /// * *$.xgafv* (query-string) - V1 error format.
26662    /// * *access_token* (query-string) - OAuth access token.
26663    /// * *alt* (query-string) - Data format for response.
26664    /// * *callback* (query-string) - JSONP
26665    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26666    /// * *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.
26667    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26668    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26669    /// * *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.
26670    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26671    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26672    pub fn param<T>(
26673        mut self,
26674        name: T,
26675        value: T,
26676    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C>
26677    where
26678        T: AsRef<str>,
26679    {
26680        self._additional_params
26681            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26682        self
26683    }
26684
26685    /// Identifies the authorization scope for the method you are building.
26686    ///
26687    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26688    /// [`Scope::CloudPlatform`].
26689    ///
26690    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26691    /// tokens for more than one scope.
26692    ///
26693    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26694    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26695    /// sufficient, a read-write scope will do as well.
26696    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C>
26697    where
26698        St: AsRef<str>,
26699    {
26700        self._scopes.insert(String::from(scope.as_ref()));
26701        self
26702    }
26703    /// Identifies the authorization scope(s) for the method you are building.
26704    ///
26705    /// See [`Self::add_scope()`] for details.
26706    pub fn add_scopes<I, St>(
26707        mut self,
26708        scopes: I,
26709    ) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C>
26710    where
26711        I: IntoIterator<Item = St>,
26712        St: AsRef<str>,
26713    {
26714        self._scopes
26715            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26716        self
26717    }
26718
26719    /// Removes all scopes, and no default scope will be used either.
26720    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26721    /// for details).
26722    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyListCall<'a, C> {
26723        self._scopes.clear();
26724        self
26725    }
26726}
26727
26728/// Updates the parameters of a single GatewaySecurityPolicy.
26729///
26730/// A builder for the *locations.gatewaySecurityPolicies.patch* method supported by a *project* resource.
26731/// It is not used directly, but through a [`ProjectMethods`] instance.
26732///
26733/// # Example
26734///
26735/// Instantiate a resource method builder
26736///
26737/// ```test_harness,no_run
26738/// # extern crate hyper;
26739/// # extern crate hyper_rustls;
26740/// # extern crate google_networksecurity1 as networksecurity1;
26741/// use networksecurity1::api::GatewaySecurityPolicy;
26742/// # async fn dox() {
26743/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26744///
26745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26747/// #     secret,
26748/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26749/// # ).build().await.unwrap();
26750///
26751/// # let client = hyper_util::client::legacy::Client::builder(
26752/// #     hyper_util::rt::TokioExecutor::new()
26753/// # )
26754/// # .build(
26755/// #     hyper_rustls::HttpsConnectorBuilder::new()
26756/// #         .with_native_roots()
26757/// #         .unwrap()
26758/// #         .https_or_http()
26759/// #         .enable_http1()
26760/// #         .build()
26761/// # );
26762/// # let mut hub = NetworkSecurity::new(client, auth);
26763/// // As the method needs a request, you would usually fill it with the desired information
26764/// // into the respective structure. Some of the parts shown here might not be applicable !
26765/// // Values shown here are possibly random and not representative !
26766/// let mut req = GatewaySecurityPolicy::default();
26767///
26768/// // You can configure optional parameters by calling the respective setters at will, and
26769/// // execute the final call using `doit()`.
26770/// // Values shown here are possibly random and not representative !
26771/// let result = hub.projects().locations_gateway_security_policies_patch(req, "name")
26772///              .update_mask(FieldMask::new::<&str>(&[]))
26773///              .doit().await;
26774/// # }
26775/// ```
26776pub struct ProjectLocationGatewaySecurityPolicyPatchCall<'a, C>
26777where
26778    C: 'a,
26779{
26780    hub: &'a NetworkSecurity<C>,
26781    _request: GatewaySecurityPolicy,
26782    _name: String,
26783    _update_mask: Option<common::FieldMask>,
26784    _delegate: Option<&'a mut dyn common::Delegate>,
26785    _additional_params: HashMap<String, String>,
26786    _scopes: BTreeSet<String>,
26787}
26788
26789impl<'a, C> common::CallBuilder for ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {}
26790
26791impl<'a, C> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C>
26792where
26793    C: common::Connector,
26794{
26795    /// Perform the operation you have build so far.
26796    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26797        use std::borrow::Cow;
26798        use std::io::{Read, Seek};
26799
26800        use common::{url::Params, ToParts};
26801        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26802
26803        let mut dd = common::DefaultDelegate;
26804        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26805        dlg.begin(common::MethodInfo {
26806            id: "networksecurity.projects.locations.gatewaySecurityPolicies.patch",
26807            http_method: hyper::Method::PATCH,
26808        });
26809
26810        for &field in ["alt", "name", "updateMask"].iter() {
26811            if self._additional_params.contains_key(field) {
26812                dlg.finished(false);
26813                return Err(common::Error::FieldClash(field));
26814            }
26815        }
26816
26817        let mut params = Params::with_capacity(5 + self._additional_params.len());
26818        params.push("name", self._name);
26819        if let Some(value) = self._update_mask.as_ref() {
26820            params.push("updateMask", value.to_string());
26821        }
26822
26823        params.extend(self._additional_params.iter());
26824
26825        params.push("alt", "json");
26826        let mut url = self.hub._base_url.clone() + "v1/{+name}";
26827        if self._scopes.is_empty() {
26828            self._scopes
26829                .insert(Scope::CloudPlatform.as_ref().to_string());
26830        }
26831
26832        #[allow(clippy::single_element_loop)]
26833        for &(find_this, param_name) in [("{+name}", "name")].iter() {
26834            url = params.uri_replacement(url, param_name, find_this, true);
26835        }
26836        {
26837            let to_remove = ["name"];
26838            params.remove_params(&to_remove);
26839        }
26840
26841        let url = params.parse_with_url(&url);
26842
26843        let mut json_mime_type = mime::APPLICATION_JSON;
26844        let mut request_value_reader = {
26845            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26846            common::remove_json_null_values(&mut value);
26847            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26848            serde_json::to_writer(&mut dst, &value).unwrap();
26849            dst
26850        };
26851        let request_size = request_value_reader
26852            .seek(std::io::SeekFrom::End(0))
26853            .unwrap();
26854        request_value_reader
26855            .seek(std::io::SeekFrom::Start(0))
26856            .unwrap();
26857
26858        loop {
26859            let token = match self
26860                .hub
26861                .auth
26862                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26863                .await
26864            {
26865                Ok(token) => token,
26866                Err(e) => match dlg.token(e) {
26867                    Ok(token) => token,
26868                    Err(e) => {
26869                        dlg.finished(false);
26870                        return Err(common::Error::MissingToken(e));
26871                    }
26872                },
26873            };
26874            request_value_reader
26875                .seek(std::io::SeekFrom::Start(0))
26876                .unwrap();
26877            let mut req_result = {
26878                let client = &self.hub.client;
26879                dlg.pre_request();
26880                let mut req_builder = hyper::Request::builder()
26881                    .method(hyper::Method::PATCH)
26882                    .uri(url.as_str())
26883                    .header(USER_AGENT, self.hub._user_agent.clone());
26884
26885                if let Some(token) = token.as_ref() {
26886                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26887                }
26888
26889                let request = req_builder
26890                    .header(CONTENT_TYPE, json_mime_type.to_string())
26891                    .header(CONTENT_LENGTH, request_size as u64)
26892                    .body(common::to_body(
26893                        request_value_reader.get_ref().clone().into(),
26894                    ));
26895
26896                client.request(request.unwrap()).await
26897            };
26898
26899            match req_result {
26900                Err(err) => {
26901                    if let common::Retry::After(d) = dlg.http_error(&err) {
26902                        sleep(d).await;
26903                        continue;
26904                    }
26905                    dlg.finished(false);
26906                    return Err(common::Error::HttpError(err));
26907                }
26908                Ok(res) => {
26909                    let (mut parts, body) = res.into_parts();
26910                    let mut body = common::Body::new(body);
26911                    if !parts.status.is_success() {
26912                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26913                        let error = serde_json::from_str(&common::to_string(&bytes));
26914                        let response = common::to_response(parts, bytes.into());
26915
26916                        if let common::Retry::After(d) =
26917                            dlg.http_failure(&response, error.as_ref().ok())
26918                        {
26919                            sleep(d).await;
26920                            continue;
26921                        }
26922
26923                        dlg.finished(false);
26924
26925                        return Err(match error {
26926                            Ok(value) => common::Error::BadRequest(value),
26927                            _ => common::Error::Failure(response),
26928                        });
26929                    }
26930                    let response = {
26931                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26932                        let encoded = common::to_string(&bytes);
26933                        match serde_json::from_str(&encoded) {
26934                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26935                            Err(error) => {
26936                                dlg.response_json_decode_error(&encoded, &error);
26937                                return Err(common::Error::JsonDecodeError(
26938                                    encoded.to_string(),
26939                                    error,
26940                                ));
26941                            }
26942                        }
26943                    };
26944
26945                    dlg.finished(true);
26946                    return Ok(response);
26947                }
26948            }
26949        }
26950    }
26951
26952    ///
26953    /// Sets the *request* property to the given value.
26954    ///
26955    /// Even though the property as already been set when instantiating this call,
26956    /// we provide this method for API completeness.
26957    pub fn request(
26958        mut self,
26959        new_value: GatewaySecurityPolicy,
26960    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {
26961        self._request = new_value;
26962        self
26963    }
26964    /// Required. Name of the resource. Name is of the form projects/{project}/locations/{location}/gatewaySecurityPolicies/{gateway_security_policy} gateway_security_policy should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
26965    ///
26966    /// Sets the *name* path property to the given value.
26967    ///
26968    /// Even though the property as already been set when instantiating this call,
26969    /// we provide this method for API completeness.
26970    pub fn name(mut self, new_value: &str) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {
26971        self._name = new_value.to_string();
26972        self
26973    }
26974    /// Optional. Field mask is used to specify the fields to be overwritten in the GatewaySecurityPolicy 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.
26975    ///
26976    /// Sets the *update mask* query property to the given value.
26977    pub fn update_mask(
26978        mut self,
26979        new_value: common::FieldMask,
26980    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {
26981        self._update_mask = Some(new_value);
26982        self
26983    }
26984    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26985    /// while executing the actual API request.
26986    ///
26987    /// ````text
26988    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26989    /// ````
26990    ///
26991    /// Sets the *delegate* property to the given value.
26992    pub fn delegate(
26993        mut self,
26994        new_value: &'a mut dyn common::Delegate,
26995    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {
26996        self._delegate = Some(new_value);
26997        self
26998    }
26999
27000    /// Set any additional parameter of the query string used in the request.
27001    /// It should be used to set parameters which are not yet available through their own
27002    /// setters.
27003    ///
27004    /// Please note that this method must not be used to set any of the known parameters
27005    /// which have their own setter method. If done anyway, the request will fail.
27006    ///
27007    /// # Additional Parameters
27008    ///
27009    /// * *$.xgafv* (query-string) - V1 error format.
27010    /// * *access_token* (query-string) - OAuth access token.
27011    /// * *alt* (query-string) - Data format for response.
27012    /// * *callback* (query-string) - JSONP
27013    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27014    /// * *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.
27015    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27016    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27017    /// * *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.
27018    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27019    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27020    pub fn param<T>(
27021        mut self,
27022        name: T,
27023        value: T,
27024    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C>
27025    where
27026        T: AsRef<str>,
27027    {
27028        self._additional_params
27029            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27030        self
27031    }
27032
27033    /// Identifies the authorization scope for the method you are building.
27034    ///
27035    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27036    /// [`Scope::CloudPlatform`].
27037    ///
27038    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27039    /// tokens for more than one scope.
27040    ///
27041    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27042    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27043    /// sufficient, a read-write scope will do as well.
27044    pub fn add_scope<St>(
27045        mut self,
27046        scope: St,
27047    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C>
27048    where
27049        St: AsRef<str>,
27050    {
27051        self._scopes.insert(String::from(scope.as_ref()));
27052        self
27053    }
27054    /// Identifies the authorization scope(s) for the method you are building.
27055    ///
27056    /// See [`Self::add_scope()`] for details.
27057    pub fn add_scopes<I, St>(
27058        mut self,
27059        scopes: I,
27060    ) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C>
27061    where
27062        I: IntoIterator<Item = St>,
27063        St: AsRef<str>,
27064    {
27065        self._scopes
27066            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27067        self
27068    }
27069
27070    /// Removes all scopes, and no default scope will be used either.
27071    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27072    /// for details).
27073    pub fn clear_scopes(mut self) -> ProjectLocationGatewaySecurityPolicyPatchCall<'a, C> {
27074        self._scopes.clear();
27075        self
27076    }
27077}
27078
27079/// 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`.
27080///
27081/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
27082/// It is not used directly, but through a [`ProjectMethods`] instance.
27083///
27084/// # Example
27085///
27086/// Instantiate a resource method builder
27087///
27088/// ```test_harness,no_run
27089/// # extern crate hyper;
27090/// # extern crate hyper_rustls;
27091/// # extern crate google_networksecurity1 as networksecurity1;
27092/// use networksecurity1::api::CancelOperationRequest;
27093/// # async fn dox() {
27094/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27095///
27096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27098/// #     secret,
27099/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27100/// # ).build().await.unwrap();
27101///
27102/// # let client = hyper_util::client::legacy::Client::builder(
27103/// #     hyper_util::rt::TokioExecutor::new()
27104/// # )
27105/// # .build(
27106/// #     hyper_rustls::HttpsConnectorBuilder::new()
27107/// #         .with_native_roots()
27108/// #         .unwrap()
27109/// #         .https_or_http()
27110/// #         .enable_http1()
27111/// #         .build()
27112/// # );
27113/// # let mut hub = NetworkSecurity::new(client, auth);
27114/// // As the method needs a request, you would usually fill it with the desired information
27115/// // into the respective structure. Some of the parts shown here might not be applicable !
27116/// // Values shown here are possibly random and not representative !
27117/// let mut req = CancelOperationRequest::default();
27118///
27119/// // You can configure optional parameters by calling the respective setters at will, and
27120/// // execute the final call using `doit()`.
27121/// // Values shown here are possibly random and not representative !
27122/// let result = hub.projects().locations_operations_cancel(req, "name")
27123///              .doit().await;
27124/// # }
27125/// ```
27126pub struct ProjectLocationOperationCancelCall<'a, C>
27127where
27128    C: 'a,
27129{
27130    hub: &'a NetworkSecurity<C>,
27131    _request: CancelOperationRequest,
27132    _name: String,
27133    _delegate: Option<&'a mut dyn common::Delegate>,
27134    _additional_params: HashMap<String, String>,
27135    _scopes: BTreeSet<String>,
27136}
27137
27138impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
27139
27140impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
27141where
27142    C: common::Connector,
27143{
27144    /// Perform the operation you have build so far.
27145    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
27146        use std::borrow::Cow;
27147        use std::io::{Read, Seek};
27148
27149        use common::{url::Params, ToParts};
27150        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27151
27152        let mut dd = common::DefaultDelegate;
27153        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27154        dlg.begin(common::MethodInfo {
27155            id: "networksecurity.projects.locations.operations.cancel",
27156            http_method: hyper::Method::POST,
27157        });
27158
27159        for &field in ["alt", "name"].iter() {
27160            if self._additional_params.contains_key(field) {
27161                dlg.finished(false);
27162                return Err(common::Error::FieldClash(field));
27163            }
27164        }
27165
27166        let mut params = Params::with_capacity(4 + self._additional_params.len());
27167        params.push("name", self._name);
27168
27169        params.extend(self._additional_params.iter());
27170
27171        params.push("alt", "json");
27172        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
27173        if self._scopes.is_empty() {
27174            self._scopes
27175                .insert(Scope::CloudPlatform.as_ref().to_string());
27176        }
27177
27178        #[allow(clippy::single_element_loop)]
27179        for &(find_this, param_name) in [("{+name}", "name")].iter() {
27180            url = params.uri_replacement(url, param_name, find_this, true);
27181        }
27182        {
27183            let to_remove = ["name"];
27184            params.remove_params(&to_remove);
27185        }
27186
27187        let url = params.parse_with_url(&url);
27188
27189        let mut json_mime_type = mime::APPLICATION_JSON;
27190        let mut request_value_reader = {
27191            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27192            common::remove_json_null_values(&mut value);
27193            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27194            serde_json::to_writer(&mut dst, &value).unwrap();
27195            dst
27196        };
27197        let request_size = request_value_reader
27198            .seek(std::io::SeekFrom::End(0))
27199            .unwrap();
27200        request_value_reader
27201            .seek(std::io::SeekFrom::Start(0))
27202            .unwrap();
27203
27204        loop {
27205            let token = match self
27206                .hub
27207                .auth
27208                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27209                .await
27210            {
27211                Ok(token) => token,
27212                Err(e) => match dlg.token(e) {
27213                    Ok(token) => token,
27214                    Err(e) => {
27215                        dlg.finished(false);
27216                        return Err(common::Error::MissingToken(e));
27217                    }
27218                },
27219            };
27220            request_value_reader
27221                .seek(std::io::SeekFrom::Start(0))
27222                .unwrap();
27223            let mut req_result = {
27224                let client = &self.hub.client;
27225                dlg.pre_request();
27226                let mut req_builder = hyper::Request::builder()
27227                    .method(hyper::Method::POST)
27228                    .uri(url.as_str())
27229                    .header(USER_AGENT, self.hub._user_agent.clone());
27230
27231                if let Some(token) = token.as_ref() {
27232                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27233                }
27234
27235                let request = req_builder
27236                    .header(CONTENT_TYPE, json_mime_type.to_string())
27237                    .header(CONTENT_LENGTH, request_size as u64)
27238                    .body(common::to_body(
27239                        request_value_reader.get_ref().clone().into(),
27240                    ));
27241
27242                client.request(request.unwrap()).await
27243            };
27244
27245            match req_result {
27246                Err(err) => {
27247                    if let common::Retry::After(d) = dlg.http_error(&err) {
27248                        sleep(d).await;
27249                        continue;
27250                    }
27251                    dlg.finished(false);
27252                    return Err(common::Error::HttpError(err));
27253                }
27254                Ok(res) => {
27255                    let (mut parts, body) = res.into_parts();
27256                    let mut body = common::Body::new(body);
27257                    if !parts.status.is_success() {
27258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27259                        let error = serde_json::from_str(&common::to_string(&bytes));
27260                        let response = common::to_response(parts, bytes.into());
27261
27262                        if let common::Retry::After(d) =
27263                            dlg.http_failure(&response, error.as_ref().ok())
27264                        {
27265                            sleep(d).await;
27266                            continue;
27267                        }
27268
27269                        dlg.finished(false);
27270
27271                        return Err(match error {
27272                            Ok(value) => common::Error::BadRequest(value),
27273                            _ => common::Error::Failure(response),
27274                        });
27275                    }
27276                    let response = {
27277                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27278                        let encoded = common::to_string(&bytes);
27279                        match serde_json::from_str(&encoded) {
27280                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27281                            Err(error) => {
27282                                dlg.response_json_decode_error(&encoded, &error);
27283                                return Err(common::Error::JsonDecodeError(
27284                                    encoded.to_string(),
27285                                    error,
27286                                ));
27287                            }
27288                        }
27289                    };
27290
27291                    dlg.finished(true);
27292                    return Ok(response);
27293                }
27294            }
27295        }
27296    }
27297
27298    ///
27299    /// Sets the *request* property to the given value.
27300    ///
27301    /// Even though the property as already been set when instantiating this call,
27302    /// we provide this method for API completeness.
27303    pub fn request(
27304        mut self,
27305        new_value: CancelOperationRequest,
27306    ) -> ProjectLocationOperationCancelCall<'a, C> {
27307        self._request = new_value;
27308        self
27309    }
27310    /// The name of the operation resource to be cancelled.
27311    ///
27312    /// Sets the *name* path property to the given value.
27313    ///
27314    /// Even though the property as already been set when instantiating this call,
27315    /// we provide this method for API completeness.
27316    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
27317        self._name = new_value.to_string();
27318        self
27319    }
27320    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27321    /// while executing the actual API request.
27322    ///
27323    /// ````text
27324    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27325    /// ````
27326    ///
27327    /// Sets the *delegate* property to the given value.
27328    pub fn delegate(
27329        mut self,
27330        new_value: &'a mut dyn common::Delegate,
27331    ) -> ProjectLocationOperationCancelCall<'a, C> {
27332        self._delegate = Some(new_value);
27333        self
27334    }
27335
27336    /// Set any additional parameter of the query string used in the request.
27337    /// It should be used to set parameters which are not yet available through their own
27338    /// setters.
27339    ///
27340    /// Please note that this method must not be used to set any of the known parameters
27341    /// which have their own setter method. If done anyway, the request will fail.
27342    ///
27343    /// # Additional Parameters
27344    ///
27345    /// * *$.xgafv* (query-string) - V1 error format.
27346    /// * *access_token* (query-string) - OAuth access token.
27347    /// * *alt* (query-string) - Data format for response.
27348    /// * *callback* (query-string) - JSONP
27349    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27350    /// * *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.
27351    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27352    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27353    /// * *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.
27354    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27355    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27356    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
27357    where
27358        T: AsRef<str>,
27359    {
27360        self._additional_params
27361            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27362        self
27363    }
27364
27365    /// Identifies the authorization scope for the method you are building.
27366    ///
27367    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27368    /// [`Scope::CloudPlatform`].
27369    ///
27370    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27371    /// tokens for more than one scope.
27372    ///
27373    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27374    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27375    /// sufficient, a read-write scope will do as well.
27376    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
27377    where
27378        St: AsRef<str>,
27379    {
27380        self._scopes.insert(String::from(scope.as_ref()));
27381        self
27382    }
27383    /// Identifies the authorization scope(s) for the method you are building.
27384    ///
27385    /// See [`Self::add_scope()`] for details.
27386    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
27387    where
27388        I: IntoIterator<Item = St>,
27389        St: AsRef<str>,
27390    {
27391        self._scopes
27392            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27393        self
27394    }
27395
27396    /// Removes all scopes, and no default scope will be used either.
27397    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27398    /// for details).
27399    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
27400        self._scopes.clear();
27401        self
27402    }
27403}
27404
27405/// 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`.
27406///
27407/// A builder for the *locations.operations.delete* method supported by a *project* resource.
27408/// It is not used directly, but through a [`ProjectMethods`] instance.
27409///
27410/// # Example
27411///
27412/// Instantiate a resource method builder
27413///
27414/// ```test_harness,no_run
27415/// # extern crate hyper;
27416/// # extern crate hyper_rustls;
27417/// # extern crate google_networksecurity1 as networksecurity1;
27418/// # async fn dox() {
27419/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27420///
27421/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27422/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27423/// #     secret,
27424/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27425/// # ).build().await.unwrap();
27426///
27427/// # let client = hyper_util::client::legacy::Client::builder(
27428/// #     hyper_util::rt::TokioExecutor::new()
27429/// # )
27430/// # .build(
27431/// #     hyper_rustls::HttpsConnectorBuilder::new()
27432/// #         .with_native_roots()
27433/// #         .unwrap()
27434/// #         .https_or_http()
27435/// #         .enable_http1()
27436/// #         .build()
27437/// # );
27438/// # let mut hub = NetworkSecurity::new(client, auth);
27439/// // You can configure optional parameters by calling the respective setters at will, and
27440/// // execute the final call using `doit()`.
27441/// // Values shown here are possibly random and not representative !
27442/// let result = hub.projects().locations_operations_delete("name")
27443///              .doit().await;
27444/// # }
27445/// ```
27446pub struct ProjectLocationOperationDeleteCall<'a, C>
27447where
27448    C: 'a,
27449{
27450    hub: &'a NetworkSecurity<C>,
27451    _name: String,
27452    _delegate: Option<&'a mut dyn common::Delegate>,
27453    _additional_params: HashMap<String, String>,
27454    _scopes: BTreeSet<String>,
27455}
27456
27457impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
27458
27459impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
27460where
27461    C: common::Connector,
27462{
27463    /// Perform the operation you have build so far.
27464    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
27465        use std::borrow::Cow;
27466        use std::io::{Read, Seek};
27467
27468        use common::{url::Params, ToParts};
27469        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27470
27471        let mut dd = common::DefaultDelegate;
27472        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27473        dlg.begin(common::MethodInfo {
27474            id: "networksecurity.projects.locations.operations.delete",
27475            http_method: hyper::Method::DELETE,
27476        });
27477
27478        for &field in ["alt", "name"].iter() {
27479            if self._additional_params.contains_key(field) {
27480                dlg.finished(false);
27481                return Err(common::Error::FieldClash(field));
27482            }
27483        }
27484
27485        let mut params = Params::with_capacity(3 + self._additional_params.len());
27486        params.push("name", self._name);
27487
27488        params.extend(self._additional_params.iter());
27489
27490        params.push("alt", "json");
27491        let mut url = self.hub._base_url.clone() + "v1/{+name}";
27492        if self._scopes.is_empty() {
27493            self._scopes
27494                .insert(Scope::CloudPlatform.as_ref().to_string());
27495        }
27496
27497        #[allow(clippy::single_element_loop)]
27498        for &(find_this, param_name) in [("{+name}", "name")].iter() {
27499            url = params.uri_replacement(url, param_name, find_this, true);
27500        }
27501        {
27502            let to_remove = ["name"];
27503            params.remove_params(&to_remove);
27504        }
27505
27506        let url = params.parse_with_url(&url);
27507
27508        loop {
27509            let token = match self
27510                .hub
27511                .auth
27512                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27513                .await
27514            {
27515                Ok(token) => token,
27516                Err(e) => match dlg.token(e) {
27517                    Ok(token) => token,
27518                    Err(e) => {
27519                        dlg.finished(false);
27520                        return Err(common::Error::MissingToken(e));
27521                    }
27522                },
27523            };
27524            let mut req_result = {
27525                let client = &self.hub.client;
27526                dlg.pre_request();
27527                let mut req_builder = hyper::Request::builder()
27528                    .method(hyper::Method::DELETE)
27529                    .uri(url.as_str())
27530                    .header(USER_AGENT, self.hub._user_agent.clone());
27531
27532                if let Some(token) = token.as_ref() {
27533                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27534                }
27535
27536                let request = req_builder
27537                    .header(CONTENT_LENGTH, 0_u64)
27538                    .body(common::to_body::<String>(None));
27539
27540                client.request(request.unwrap()).await
27541            };
27542
27543            match req_result {
27544                Err(err) => {
27545                    if let common::Retry::After(d) = dlg.http_error(&err) {
27546                        sleep(d).await;
27547                        continue;
27548                    }
27549                    dlg.finished(false);
27550                    return Err(common::Error::HttpError(err));
27551                }
27552                Ok(res) => {
27553                    let (mut parts, body) = res.into_parts();
27554                    let mut body = common::Body::new(body);
27555                    if !parts.status.is_success() {
27556                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27557                        let error = serde_json::from_str(&common::to_string(&bytes));
27558                        let response = common::to_response(parts, bytes.into());
27559
27560                        if let common::Retry::After(d) =
27561                            dlg.http_failure(&response, error.as_ref().ok())
27562                        {
27563                            sleep(d).await;
27564                            continue;
27565                        }
27566
27567                        dlg.finished(false);
27568
27569                        return Err(match error {
27570                            Ok(value) => common::Error::BadRequest(value),
27571                            _ => common::Error::Failure(response),
27572                        });
27573                    }
27574                    let response = {
27575                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27576                        let encoded = common::to_string(&bytes);
27577                        match serde_json::from_str(&encoded) {
27578                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27579                            Err(error) => {
27580                                dlg.response_json_decode_error(&encoded, &error);
27581                                return Err(common::Error::JsonDecodeError(
27582                                    encoded.to_string(),
27583                                    error,
27584                                ));
27585                            }
27586                        }
27587                    };
27588
27589                    dlg.finished(true);
27590                    return Ok(response);
27591                }
27592            }
27593        }
27594    }
27595
27596    /// The name of the operation resource to be deleted.
27597    ///
27598    /// Sets the *name* path property to the given value.
27599    ///
27600    /// Even though the property as already been set when instantiating this call,
27601    /// we provide this method for API completeness.
27602    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
27603        self._name = new_value.to_string();
27604        self
27605    }
27606    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27607    /// while executing the actual API request.
27608    ///
27609    /// ````text
27610    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27611    /// ````
27612    ///
27613    /// Sets the *delegate* property to the given value.
27614    pub fn delegate(
27615        mut self,
27616        new_value: &'a mut dyn common::Delegate,
27617    ) -> ProjectLocationOperationDeleteCall<'a, C> {
27618        self._delegate = Some(new_value);
27619        self
27620    }
27621
27622    /// Set any additional parameter of the query string used in the request.
27623    /// It should be used to set parameters which are not yet available through their own
27624    /// setters.
27625    ///
27626    /// Please note that this method must not be used to set any of the known parameters
27627    /// which have their own setter method. If done anyway, the request will fail.
27628    ///
27629    /// # Additional Parameters
27630    ///
27631    /// * *$.xgafv* (query-string) - V1 error format.
27632    /// * *access_token* (query-string) - OAuth access token.
27633    /// * *alt* (query-string) - Data format for response.
27634    /// * *callback* (query-string) - JSONP
27635    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27636    /// * *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.
27637    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27638    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27639    /// * *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.
27640    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27641    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27642    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
27643    where
27644        T: AsRef<str>,
27645    {
27646        self._additional_params
27647            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27648        self
27649    }
27650
27651    /// Identifies the authorization scope for the method you are building.
27652    ///
27653    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27654    /// [`Scope::CloudPlatform`].
27655    ///
27656    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27657    /// tokens for more than one scope.
27658    ///
27659    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27660    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27661    /// sufficient, a read-write scope will do as well.
27662    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
27663    where
27664        St: AsRef<str>,
27665    {
27666        self._scopes.insert(String::from(scope.as_ref()));
27667        self
27668    }
27669    /// Identifies the authorization scope(s) for the method you are building.
27670    ///
27671    /// See [`Self::add_scope()`] for details.
27672    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
27673    where
27674        I: IntoIterator<Item = St>,
27675        St: AsRef<str>,
27676    {
27677        self._scopes
27678            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27679        self
27680    }
27681
27682    /// Removes all scopes, and no default scope will be used either.
27683    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27684    /// for details).
27685    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
27686        self._scopes.clear();
27687        self
27688    }
27689}
27690
27691/// 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.
27692///
27693/// A builder for the *locations.operations.get* method supported by a *project* resource.
27694/// It is not used directly, but through a [`ProjectMethods`] instance.
27695///
27696/// # Example
27697///
27698/// Instantiate a resource method builder
27699///
27700/// ```test_harness,no_run
27701/// # extern crate hyper;
27702/// # extern crate hyper_rustls;
27703/// # extern crate google_networksecurity1 as networksecurity1;
27704/// # async fn dox() {
27705/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27706///
27707/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27708/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27709/// #     secret,
27710/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27711/// # ).build().await.unwrap();
27712///
27713/// # let client = hyper_util::client::legacy::Client::builder(
27714/// #     hyper_util::rt::TokioExecutor::new()
27715/// # )
27716/// # .build(
27717/// #     hyper_rustls::HttpsConnectorBuilder::new()
27718/// #         .with_native_roots()
27719/// #         .unwrap()
27720/// #         .https_or_http()
27721/// #         .enable_http1()
27722/// #         .build()
27723/// # );
27724/// # let mut hub = NetworkSecurity::new(client, auth);
27725/// // You can configure optional parameters by calling the respective setters at will, and
27726/// // execute the final call using `doit()`.
27727/// // Values shown here are possibly random and not representative !
27728/// let result = hub.projects().locations_operations_get("name")
27729///              .doit().await;
27730/// # }
27731/// ```
27732pub struct ProjectLocationOperationGetCall<'a, C>
27733where
27734    C: 'a,
27735{
27736    hub: &'a NetworkSecurity<C>,
27737    _name: String,
27738    _delegate: Option<&'a mut dyn common::Delegate>,
27739    _additional_params: HashMap<String, String>,
27740    _scopes: BTreeSet<String>,
27741}
27742
27743impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
27744
27745impl<'a, C> ProjectLocationOperationGetCall<'a, C>
27746where
27747    C: common::Connector,
27748{
27749    /// Perform the operation you have build so far.
27750    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
27751        use std::borrow::Cow;
27752        use std::io::{Read, Seek};
27753
27754        use common::{url::Params, ToParts};
27755        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27756
27757        let mut dd = common::DefaultDelegate;
27758        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27759        dlg.begin(common::MethodInfo {
27760            id: "networksecurity.projects.locations.operations.get",
27761            http_method: hyper::Method::GET,
27762        });
27763
27764        for &field in ["alt", "name"].iter() {
27765            if self._additional_params.contains_key(field) {
27766                dlg.finished(false);
27767                return Err(common::Error::FieldClash(field));
27768            }
27769        }
27770
27771        let mut params = Params::with_capacity(3 + self._additional_params.len());
27772        params.push("name", self._name);
27773
27774        params.extend(self._additional_params.iter());
27775
27776        params.push("alt", "json");
27777        let mut url = self.hub._base_url.clone() + "v1/{+name}";
27778        if self._scopes.is_empty() {
27779            self._scopes
27780                .insert(Scope::CloudPlatform.as_ref().to_string());
27781        }
27782
27783        #[allow(clippy::single_element_loop)]
27784        for &(find_this, param_name) in [("{+name}", "name")].iter() {
27785            url = params.uri_replacement(url, param_name, find_this, true);
27786        }
27787        {
27788            let to_remove = ["name"];
27789            params.remove_params(&to_remove);
27790        }
27791
27792        let url = params.parse_with_url(&url);
27793
27794        loop {
27795            let token = match self
27796                .hub
27797                .auth
27798                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27799                .await
27800            {
27801                Ok(token) => token,
27802                Err(e) => match dlg.token(e) {
27803                    Ok(token) => token,
27804                    Err(e) => {
27805                        dlg.finished(false);
27806                        return Err(common::Error::MissingToken(e));
27807                    }
27808                },
27809            };
27810            let mut req_result = {
27811                let client = &self.hub.client;
27812                dlg.pre_request();
27813                let mut req_builder = hyper::Request::builder()
27814                    .method(hyper::Method::GET)
27815                    .uri(url.as_str())
27816                    .header(USER_AGENT, self.hub._user_agent.clone());
27817
27818                if let Some(token) = token.as_ref() {
27819                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27820                }
27821
27822                let request = req_builder
27823                    .header(CONTENT_LENGTH, 0_u64)
27824                    .body(common::to_body::<String>(None));
27825
27826                client.request(request.unwrap()).await
27827            };
27828
27829            match req_result {
27830                Err(err) => {
27831                    if let common::Retry::After(d) = dlg.http_error(&err) {
27832                        sleep(d).await;
27833                        continue;
27834                    }
27835                    dlg.finished(false);
27836                    return Err(common::Error::HttpError(err));
27837                }
27838                Ok(res) => {
27839                    let (mut parts, body) = res.into_parts();
27840                    let mut body = common::Body::new(body);
27841                    if !parts.status.is_success() {
27842                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27843                        let error = serde_json::from_str(&common::to_string(&bytes));
27844                        let response = common::to_response(parts, bytes.into());
27845
27846                        if let common::Retry::After(d) =
27847                            dlg.http_failure(&response, error.as_ref().ok())
27848                        {
27849                            sleep(d).await;
27850                            continue;
27851                        }
27852
27853                        dlg.finished(false);
27854
27855                        return Err(match error {
27856                            Ok(value) => common::Error::BadRequest(value),
27857                            _ => common::Error::Failure(response),
27858                        });
27859                    }
27860                    let response = {
27861                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27862                        let encoded = common::to_string(&bytes);
27863                        match serde_json::from_str(&encoded) {
27864                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27865                            Err(error) => {
27866                                dlg.response_json_decode_error(&encoded, &error);
27867                                return Err(common::Error::JsonDecodeError(
27868                                    encoded.to_string(),
27869                                    error,
27870                                ));
27871                            }
27872                        }
27873                    };
27874
27875                    dlg.finished(true);
27876                    return Ok(response);
27877                }
27878            }
27879        }
27880    }
27881
27882    /// The name of the operation resource.
27883    ///
27884    /// Sets the *name* path property to the given value.
27885    ///
27886    /// Even though the property as already been set when instantiating this call,
27887    /// we provide this method for API completeness.
27888    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
27889        self._name = new_value.to_string();
27890        self
27891    }
27892    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27893    /// while executing the actual API request.
27894    ///
27895    /// ````text
27896    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27897    /// ````
27898    ///
27899    /// Sets the *delegate* property to the given value.
27900    pub fn delegate(
27901        mut self,
27902        new_value: &'a mut dyn common::Delegate,
27903    ) -> ProjectLocationOperationGetCall<'a, C> {
27904        self._delegate = Some(new_value);
27905        self
27906    }
27907
27908    /// Set any additional parameter of the query string used in the request.
27909    /// It should be used to set parameters which are not yet available through their own
27910    /// setters.
27911    ///
27912    /// Please note that this method must not be used to set any of the known parameters
27913    /// which have their own setter method. If done anyway, the request will fail.
27914    ///
27915    /// # Additional Parameters
27916    ///
27917    /// * *$.xgafv* (query-string) - V1 error format.
27918    /// * *access_token* (query-string) - OAuth access token.
27919    /// * *alt* (query-string) - Data format for response.
27920    /// * *callback* (query-string) - JSONP
27921    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27922    /// * *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.
27923    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27924    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27925    /// * *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.
27926    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27927    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27928    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
27929    where
27930        T: AsRef<str>,
27931    {
27932        self._additional_params
27933            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27934        self
27935    }
27936
27937    /// Identifies the authorization scope for the method you are building.
27938    ///
27939    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27940    /// [`Scope::CloudPlatform`].
27941    ///
27942    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27943    /// tokens for more than one scope.
27944    ///
27945    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27946    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27947    /// sufficient, a read-write scope will do as well.
27948    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
27949    where
27950        St: AsRef<str>,
27951    {
27952        self._scopes.insert(String::from(scope.as_ref()));
27953        self
27954    }
27955    /// Identifies the authorization scope(s) for the method you are building.
27956    ///
27957    /// See [`Self::add_scope()`] for details.
27958    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
27959    where
27960        I: IntoIterator<Item = St>,
27961        St: AsRef<str>,
27962    {
27963        self._scopes
27964            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27965        self
27966    }
27967
27968    /// Removes all scopes, and no default scope will be used either.
27969    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27970    /// for details).
27971    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
27972        self._scopes.clear();
27973        self
27974    }
27975}
27976
27977/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
27978///
27979/// A builder for the *locations.operations.list* method supported by a *project* resource.
27980/// It is not used directly, but through a [`ProjectMethods`] instance.
27981///
27982/// # Example
27983///
27984/// Instantiate a resource method builder
27985///
27986/// ```test_harness,no_run
27987/// # extern crate hyper;
27988/// # extern crate hyper_rustls;
27989/// # extern crate google_networksecurity1 as networksecurity1;
27990/// # async fn dox() {
27991/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27992///
27993/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27994/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27995/// #     secret,
27996/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27997/// # ).build().await.unwrap();
27998///
27999/// # let client = hyper_util::client::legacy::Client::builder(
28000/// #     hyper_util::rt::TokioExecutor::new()
28001/// # )
28002/// # .build(
28003/// #     hyper_rustls::HttpsConnectorBuilder::new()
28004/// #         .with_native_roots()
28005/// #         .unwrap()
28006/// #         .https_or_http()
28007/// #         .enable_http1()
28008/// #         .build()
28009/// # );
28010/// # let mut hub = NetworkSecurity::new(client, auth);
28011/// // You can configure optional parameters by calling the respective setters at will, and
28012/// // execute the final call using `doit()`.
28013/// // Values shown here are possibly random and not representative !
28014/// let result = hub.projects().locations_operations_list("name")
28015///              .page_token("diam")
28016///              .page_size(-57)
28017///              .filter("sit")
28018///              .doit().await;
28019/// # }
28020/// ```
28021pub struct ProjectLocationOperationListCall<'a, C>
28022where
28023    C: 'a,
28024{
28025    hub: &'a NetworkSecurity<C>,
28026    _name: String,
28027    _page_token: Option<String>,
28028    _page_size: Option<i32>,
28029    _filter: Option<String>,
28030    _delegate: Option<&'a mut dyn common::Delegate>,
28031    _additional_params: HashMap<String, String>,
28032    _scopes: BTreeSet<String>,
28033}
28034
28035impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
28036
28037impl<'a, C> ProjectLocationOperationListCall<'a, C>
28038where
28039    C: common::Connector,
28040{
28041    /// Perform the operation you have build so far.
28042    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
28043        use std::borrow::Cow;
28044        use std::io::{Read, Seek};
28045
28046        use common::{url::Params, ToParts};
28047        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28048
28049        let mut dd = common::DefaultDelegate;
28050        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28051        dlg.begin(common::MethodInfo {
28052            id: "networksecurity.projects.locations.operations.list",
28053            http_method: hyper::Method::GET,
28054        });
28055
28056        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
28057            if self._additional_params.contains_key(field) {
28058                dlg.finished(false);
28059                return Err(common::Error::FieldClash(field));
28060            }
28061        }
28062
28063        let mut params = Params::with_capacity(6 + self._additional_params.len());
28064        params.push("name", self._name);
28065        if let Some(value) = self._page_token.as_ref() {
28066            params.push("pageToken", value);
28067        }
28068        if let Some(value) = self._page_size.as_ref() {
28069            params.push("pageSize", value.to_string());
28070        }
28071        if let Some(value) = self._filter.as_ref() {
28072            params.push("filter", value);
28073        }
28074
28075        params.extend(self._additional_params.iter());
28076
28077        params.push("alt", "json");
28078        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
28079        if self._scopes.is_empty() {
28080            self._scopes
28081                .insert(Scope::CloudPlatform.as_ref().to_string());
28082        }
28083
28084        #[allow(clippy::single_element_loop)]
28085        for &(find_this, param_name) in [("{+name}", "name")].iter() {
28086            url = params.uri_replacement(url, param_name, find_this, true);
28087        }
28088        {
28089            let to_remove = ["name"];
28090            params.remove_params(&to_remove);
28091        }
28092
28093        let url = params.parse_with_url(&url);
28094
28095        loop {
28096            let token = match self
28097                .hub
28098                .auth
28099                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28100                .await
28101            {
28102                Ok(token) => token,
28103                Err(e) => match dlg.token(e) {
28104                    Ok(token) => token,
28105                    Err(e) => {
28106                        dlg.finished(false);
28107                        return Err(common::Error::MissingToken(e));
28108                    }
28109                },
28110            };
28111            let mut req_result = {
28112                let client = &self.hub.client;
28113                dlg.pre_request();
28114                let mut req_builder = hyper::Request::builder()
28115                    .method(hyper::Method::GET)
28116                    .uri(url.as_str())
28117                    .header(USER_AGENT, self.hub._user_agent.clone());
28118
28119                if let Some(token) = token.as_ref() {
28120                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28121                }
28122
28123                let request = req_builder
28124                    .header(CONTENT_LENGTH, 0_u64)
28125                    .body(common::to_body::<String>(None));
28126
28127                client.request(request.unwrap()).await
28128            };
28129
28130            match req_result {
28131                Err(err) => {
28132                    if let common::Retry::After(d) = dlg.http_error(&err) {
28133                        sleep(d).await;
28134                        continue;
28135                    }
28136                    dlg.finished(false);
28137                    return Err(common::Error::HttpError(err));
28138                }
28139                Ok(res) => {
28140                    let (mut parts, body) = res.into_parts();
28141                    let mut body = common::Body::new(body);
28142                    if !parts.status.is_success() {
28143                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28144                        let error = serde_json::from_str(&common::to_string(&bytes));
28145                        let response = common::to_response(parts, bytes.into());
28146
28147                        if let common::Retry::After(d) =
28148                            dlg.http_failure(&response, error.as_ref().ok())
28149                        {
28150                            sleep(d).await;
28151                            continue;
28152                        }
28153
28154                        dlg.finished(false);
28155
28156                        return Err(match error {
28157                            Ok(value) => common::Error::BadRequest(value),
28158                            _ => common::Error::Failure(response),
28159                        });
28160                    }
28161                    let response = {
28162                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28163                        let encoded = common::to_string(&bytes);
28164                        match serde_json::from_str(&encoded) {
28165                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28166                            Err(error) => {
28167                                dlg.response_json_decode_error(&encoded, &error);
28168                                return Err(common::Error::JsonDecodeError(
28169                                    encoded.to_string(),
28170                                    error,
28171                                ));
28172                            }
28173                        }
28174                    };
28175
28176                    dlg.finished(true);
28177                    return Ok(response);
28178                }
28179            }
28180        }
28181    }
28182
28183    /// The name of the operation's parent resource.
28184    ///
28185    /// Sets the *name* path property to the given value.
28186    ///
28187    /// Even though the property as already been set when instantiating this call,
28188    /// we provide this method for API completeness.
28189    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
28190        self._name = new_value.to_string();
28191        self
28192    }
28193    /// The standard list page token.
28194    ///
28195    /// Sets the *page token* query property to the given value.
28196    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
28197        self._page_token = Some(new_value.to_string());
28198        self
28199    }
28200    /// The standard list page size.
28201    ///
28202    /// Sets the *page size* query property to the given value.
28203    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
28204        self._page_size = Some(new_value);
28205        self
28206    }
28207    /// The standard list filter.
28208    ///
28209    /// Sets the *filter* query property to the given value.
28210    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
28211        self._filter = Some(new_value.to_string());
28212        self
28213    }
28214    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28215    /// while executing the actual API request.
28216    ///
28217    /// ````text
28218    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28219    /// ````
28220    ///
28221    /// Sets the *delegate* property to the given value.
28222    pub fn delegate(
28223        mut self,
28224        new_value: &'a mut dyn common::Delegate,
28225    ) -> ProjectLocationOperationListCall<'a, C> {
28226        self._delegate = Some(new_value);
28227        self
28228    }
28229
28230    /// Set any additional parameter of the query string used in the request.
28231    /// It should be used to set parameters which are not yet available through their own
28232    /// setters.
28233    ///
28234    /// Please note that this method must not be used to set any of the known parameters
28235    /// which have their own setter method. If done anyway, the request will fail.
28236    ///
28237    /// # Additional Parameters
28238    ///
28239    /// * *$.xgafv* (query-string) - V1 error format.
28240    /// * *access_token* (query-string) - OAuth access token.
28241    /// * *alt* (query-string) - Data format for response.
28242    /// * *callback* (query-string) - JSONP
28243    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28244    /// * *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.
28245    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28246    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28247    /// * *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.
28248    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28249    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28250    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
28251    where
28252        T: AsRef<str>,
28253    {
28254        self._additional_params
28255            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28256        self
28257    }
28258
28259    /// Identifies the authorization scope for the method you are building.
28260    ///
28261    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28262    /// [`Scope::CloudPlatform`].
28263    ///
28264    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28265    /// tokens for more than one scope.
28266    ///
28267    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28268    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28269    /// sufficient, a read-write scope will do as well.
28270    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
28271    where
28272        St: AsRef<str>,
28273    {
28274        self._scopes.insert(String::from(scope.as_ref()));
28275        self
28276    }
28277    /// Identifies the authorization scope(s) for the method you are building.
28278    ///
28279    /// See [`Self::add_scope()`] for details.
28280    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
28281    where
28282        I: IntoIterator<Item = St>,
28283        St: AsRef<str>,
28284    {
28285        self._scopes
28286            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28287        self
28288    }
28289
28290    /// Removes all scopes, and no default scope will be used either.
28291    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28292    /// for details).
28293    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
28294        self._scopes.clear();
28295        self
28296    }
28297}
28298
28299/// Creates a new ServerTlsPolicy in a given project and location.
28300///
28301/// A builder for the *locations.serverTlsPolicies.create* method supported by a *project* resource.
28302/// It is not used directly, but through a [`ProjectMethods`] instance.
28303///
28304/// # Example
28305///
28306/// Instantiate a resource method builder
28307///
28308/// ```test_harness,no_run
28309/// # extern crate hyper;
28310/// # extern crate hyper_rustls;
28311/// # extern crate google_networksecurity1 as networksecurity1;
28312/// use networksecurity1::api::ServerTlsPolicy;
28313/// # async fn dox() {
28314/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28315///
28316/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28317/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28318/// #     secret,
28319/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28320/// # ).build().await.unwrap();
28321///
28322/// # let client = hyper_util::client::legacy::Client::builder(
28323/// #     hyper_util::rt::TokioExecutor::new()
28324/// # )
28325/// # .build(
28326/// #     hyper_rustls::HttpsConnectorBuilder::new()
28327/// #         .with_native_roots()
28328/// #         .unwrap()
28329/// #         .https_or_http()
28330/// #         .enable_http1()
28331/// #         .build()
28332/// # );
28333/// # let mut hub = NetworkSecurity::new(client, auth);
28334/// // As the method needs a request, you would usually fill it with the desired information
28335/// // into the respective structure. Some of the parts shown here might not be applicable !
28336/// // Values shown here are possibly random and not representative !
28337/// let mut req = ServerTlsPolicy::default();
28338///
28339/// // You can configure optional parameters by calling the respective setters at will, and
28340/// // execute the final call using `doit()`.
28341/// // Values shown here are possibly random and not representative !
28342/// let result = hub.projects().locations_server_tls_policies_create(req, "parent")
28343///              .server_tls_policy_id("eos")
28344///              .doit().await;
28345/// # }
28346/// ```
28347pub struct ProjectLocationServerTlsPolicyCreateCall<'a, C>
28348where
28349    C: 'a,
28350{
28351    hub: &'a NetworkSecurity<C>,
28352    _request: ServerTlsPolicy,
28353    _parent: String,
28354    _server_tls_policy_id: Option<String>,
28355    _delegate: Option<&'a mut dyn common::Delegate>,
28356    _additional_params: HashMap<String, String>,
28357    _scopes: BTreeSet<String>,
28358}
28359
28360impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyCreateCall<'a, C> {}
28361
28362impl<'a, C> ProjectLocationServerTlsPolicyCreateCall<'a, C>
28363where
28364    C: common::Connector,
28365{
28366    /// Perform the operation you have build so far.
28367    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
28368        use std::borrow::Cow;
28369        use std::io::{Read, Seek};
28370
28371        use common::{url::Params, ToParts};
28372        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28373
28374        let mut dd = common::DefaultDelegate;
28375        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28376        dlg.begin(common::MethodInfo {
28377            id: "networksecurity.projects.locations.serverTlsPolicies.create",
28378            http_method: hyper::Method::POST,
28379        });
28380
28381        for &field in ["alt", "parent", "serverTlsPolicyId"].iter() {
28382            if self._additional_params.contains_key(field) {
28383                dlg.finished(false);
28384                return Err(common::Error::FieldClash(field));
28385            }
28386        }
28387
28388        let mut params = Params::with_capacity(5 + self._additional_params.len());
28389        params.push("parent", self._parent);
28390        if let Some(value) = self._server_tls_policy_id.as_ref() {
28391            params.push("serverTlsPolicyId", value);
28392        }
28393
28394        params.extend(self._additional_params.iter());
28395
28396        params.push("alt", "json");
28397        let mut url = self.hub._base_url.clone() + "v1/{+parent}/serverTlsPolicies";
28398        if self._scopes.is_empty() {
28399            self._scopes
28400                .insert(Scope::CloudPlatform.as_ref().to_string());
28401        }
28402
28403        #[allow(clippy::single_element_loop)]
28404        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
28405            url = params.uri_replacement(url, param_name, find_this, true);
28406        }
28407        {
28408            let to_remove = ["parent"];
28409            params.remove_params(&to_remove);
28410        }
28411
28412        let url = params.parse_with_url(&url);
28413
28414        let mut json_mime_type = mime::APPLICATION_JSON;
28415        let mut request_value_reader = {
28416            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28417            common::remove_json_null_values(&mut value);
28418            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28419            serde_json::to_writer(&mut dst, &value).unwrap();
28420            dst
28421        };
28422        let request_size = request_value_reader
28423            .seek(std::io::SeekFrom::End(0))
28424            .unwrap();
28425        request_value_reader
28426            .seek(std::io::SeekFrom::Start(0))
28427            .unwrap();
28428
28429        loop {
28430            let token = match self
28431                .hub
28432                .auth
28433                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28434                .await
28435            {
28436                Ok(token) => token,
28437                Err(e) => match dlg.token(e) {
28438                    Ok(token) => token,
28439                    Err(e) => {
28440                        dlg.finished(false);
28441                        return Err(common::Error::MissingToken(e));
28442                    }
28443                },
28444            };
28445            request_value_reader
28446                .seek(std::io::SeekFrom::Start(0))
28447                .unwrap();
28448            let mut req_result = {
28449                let client = &self.hub.client;
28450                dlg.pre_request();
28451                let mut req_builder = hyper::Request::builder()
28452                    .method(hyper::Method::POST)
28453                    .uri(url.as_str())
28454                    .header(USER_AGENT, self.hub._user_agent.clone());
28455
28456                if let Some(token) = token.as_ref() {
28457                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28458                }
28459
28460                let request = req_builder
28461                    .header(CONTENT_TYPE, json_mime_type.to_string())
28462                    .header(CONTENT_LENGTH, request_size as u64)
28463                    .body(common::to_body(
28464                        request_value_reader.get_ref().clone().into(),
28465                    ));
28466
28467                client.request(request.unwrap()).await
28468            };
28469
28470            match req_result {
28471                Err(err) => {
28472                    if let common::Retry::After(d) = dlg.http_error(&err) {
28473                        sleep(d).await;
28474                        continue;
28475                    }
28476                    dlg.finished(false);
28477                    return Err(common::Error::HttpError(err));
28478                }
28479                Ok(res) => {
28480                    let (mut parts, body) = res.into_parts();
28481                    let mut body = common::Body::new(body);
28482                    if !parts.status.is_success() {
28483                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28484                        let error = serde_json::from_str(&common::to_string(&bytes));
28485                        let response = common::to_response(parts, bytes.into());
28486
28487                        if let common::Retry::After(d) =
28488                            dlg.http_failure(&response, error.as_ref().ok())
28489                        {
28490                            sleep(d).await;
28491                            continue;
28492                        }
28493
28494                        dlg.finished(false);
28495
28496                        return Err(match error {
28497                            Ok(value) => common::Error::BadRequest(value),
28498                            _ => common::Error::Failure(response),
28499                        });
28500                    }
28501                    let response = {
28502                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28503                        let encoded = common::to_string(&bytes);
28504                        match serde_json::from_str(&encoded) {
28505                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28506                            Err(error) => {
28507                                dlg.response_json_decode_error(&encoded, &error);
28508                                return Err(common::Error::JsonDecodeError(
28509                                    encoded.to_string(),
28510                                    error,
28511                                ));
28512                            }
28513                        }
28514                    };
28515
28516                    dlg.finished(true);
28517                    return Ok(response);
28518                }
28519            }
28520        }
28521    }
28522
28523    ///
28524    /// Sets the *request* property to the given value.
28525    ///
28526    /// Even though the property as already been set when instantiating this call,
28527    /// we provide this method for API completeness.
28528    pub fn request(
28529        mut self,
28530        new_value: ServerTlsPolicy,
28531    ) -> ProjectLocationServerTlsPolicyCreateCall<'a, C> {
28532        self._request = new_value;
28533        self
28534    }
28535    /// Required. The parent resource of the ServerTlsPolicy. Must be in the format `projects/*/locations/{location}`.
28536    ///
28537    /// Sets the *parent* path property to the given value.
28538    ///
28539    /// Even though the property as already been set when instantiating this call,
28540    /// we provide this method for API completeness.
28541    pub fn parent(mut self, new_value: &str) -> ProjectLocationServerTlsPolicyCreateCall<'a, C> {
28542        self._parent = new_value.to_string();
28543        self
28544    }
28545    /// Required. Short name of the ServerTlsPolicy resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "server_mtls_policy".
28546    ///
28547    /// Sets the *server tls policy id* query property to the given value.
28548    pub fn server_tls_policy_id(
28549        mut self,
28550        new_value: &str,
28551    ) -> ProjectLocationServerTlsPolicyCreateCall<'a, C> {
28552        self._server_tls_policy_id = Some(new_value.to_string());
28553        self
28554    }
28555    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28556    /// while executing the actual API request.
28557    ///
28558    /// ````text
28559    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28560    /// ````
28561    ///
28562    /// Sets the *delegate* property to the given value.
28563    pub fn delegate(
28564        mut self,
28565        new_value: &'a mut dyn common::Delegate,
28566    ) -> ProjectLocationServerTlsPolicyCreateCall<'a, C> {
28567        self._delegate = Some(new_value);
28568        self
28569    }
28570
28571    /// Set any additional parameter of the query string used in the request.
28572    /// It should be used to set parameters which are not yet available through their own
28573    /// setters.
28574    ///
28575    /// Please note that this method must not be used to set any of the known parameters
28576    /// which have their own setter method. If done anyway, the request will fail.
28577    ///
28578    /// # Additional Parameters
28579    ///
28580    /// * *$.xgafv* (query-string) - V1 error format.
28581    /// * *access_token* (query-string) - OAuth access token.
28582    /// * *alt* (query-string) - Data format for response.
28583    /// * *callback* (query-string) - JSONP
28584    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28585    /// * *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.
28586    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28587    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28588    /// * *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.
28589    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28590    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28591    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServerTlsPolicyCreateCall<'a, C>
28592    where
28593        T: AsRef<str>,
28594    {
28595        self._additional_params
28596            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28597        self
28598    }
28599
28600    /// Identifies the authorization scope for the method you are building.
28601    ///
28602    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28603    /// [`Scope::CloudPlatform`].
28604    ///
28605    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28606    /// tokens for more than one scope.
28607    ///
28608    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28609    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28610    /// sufficient, a read-write scope will do as well.
28611    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServerTlsPolicyCreateCall<'a, C>
28612    where
28613        St: AsRef<str>,
28614    {
28615        self._scopes.insert(String::from(scope.as_ref()));
28616        self
28617    }
28618    /// Identifies the authorization scope(s) for the method you are building.
28619    ///
28620    /// See [`Self::add_scope()`] for details.
28621    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServerTlsPolicyCreateCall<'a, C>
28622    where
28623        I: IntoIterator<Item = St>,
28624        St: AsRef<str>,
28625    {
28626        self._scopes
28627            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28628        self
28629    }
28630
28631    /// Removes all scopes, and no default scope will be used either.
28632    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28633    /// for details).
28634    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyCreateCall<'a, C> {
28635        self._scopes.clear();
28636        self
28637    }
28638}
28639
28640/// Deletes a single ServerTlsPolicy.
28641///
28642/// A builder for the *locations.serverTlsPolicies.delete* method supported by a *project* resource.
28643/// It is not used directly, but through a [`ProjectMethods`] instance.
28644///
28645/// # Example
28646///
28647/// Instantiate a resource method builder
28648///
28649/// ```test_harness,no_run
28650/// # extern crate hyper;
28651/// # extern crate hyper_rustls;
28652/// # extern crate google_networksecurity1 as networksecurity1;
28653/// # async fn dox() {
28654/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28655///
28656/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28657/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28658/// #     secret,
28659/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28660/// # ).build().await.unwrap();
28661///
28662/// # let client = hyper_util::client::legacy::Client::builder(
28663/// #     hyper_util::rt::TokioExecutor::new()
28664/// # )
28665/// # .build(
28666/// #     hyper_rustls::HttpsConnectorBuilder::new()
28667/// #         .with_native_roots()
28668/// #         .unwrap()
28669/// #         .https_or_http()
28670/// #         .enable_http1()
28671/// #         .build()
28672/// # );
28673/// # let mut hub = NetworkSecurity::new(client, auth);
28674/// // You can configure optional parameters by calling the respective setters at will, and
28675/// // execute the final call using `doit()`.
28676/// // Values shown here are possibly random and not representative !
28677/// let result = hub.projects().locations_server_tls_policies_delete("name")
28678///              .doit().await;
28679/// # }
28680/// ```
28681pub struct ProjectLocationServerTlsPolicyDeleteCall<'a, C>
28682where
28683    C: 'a,
28684{
28685    hub: &'a NetworkSecurity<C>,
28686    _name: String,
28687    _delegate: Option<&'a mut dyn common::Delegate>,
28688    _additional_params: HashMap<String, String>,
28689    _scopes: BTreeSet<String>,
28690}
28691
28692impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyDeleteCall<'a, C> {}
28693
28694impl<'a, C> ProjectLocationServerTlsPolicyDeleteCall<'a, C>
28695where
28696    C: common::Connector,
28697{
28698    /// Perform the operation you have build so far.
28699    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
28700        use std::borrow::Cow;
28701        use std::io::{Read, Seek};
28702
28703        use common::{url::Params, ToParts};
28704        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28705
28706        let mut dd = common::DefaultDelegate;
28707        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28708        dlg.begin(common::MethodInfo {
28709            id: "networksecurity.projects.locations.serverTlsPolicies.delete",
28710            http_method: hyper::Method::DELETE,
28711        });
28712
28713        for &field in ["alt", "name"].iter() {
28714            if self._additional_params.contains_key(field) {
28715                dlg.finished(false);
28716                return Err(common::Error::FieldClash(field));
28717            }
28718        }
28719
28720        let mut params = Params::with_capacity(3 + self._additional_params.len());
28721        params.push("name", self._name);
28722
28723        params.extend(self._additional_params.iter());
28724
28725        params.push("alt", "json");
28726        let mut url = self.hub._base_url.clone() + "v1/{+name}";
28727        if self._scopes.is_empty() {
28728            self._scopes
28729                .insert(Scope::CloudPlatform.as_ref().to_string());
28730        }
28731
28732        #[allow(clippy::single_element_loop)]
28733        for &(find_this, param_name) in [("{+name}", "name")].iter() {
28734            url = params.uri_replacement(url, param_name, find_this, true);
28735        }
28736        {
28737            let to_remove = ["name"];
28738            params.remove_params(&to_remove);
28739        }
28740
28741        let url = params.parse_with_url(&url);
28742
28743        loop {
28744            let token = match self
28745                .hub
28746                .auth
28747                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28748                .await
28749            {
28750                Ok(token) => token,
28751                Err(e) => match dlg.token(e) {
28752                    Ok(token) => token,
28753                    Err(e) => {
28754                        dlg.finished(false);
28755                        return Err(common::Error::MissingToken(e));
28756                    }
28757                },
28758            };
28759            let mut req_result = {
28760                let client = &self.hub.client;
28761                dlg.pre_request();
28762                let mut req_builder = hyper::Request::builder()
28763                    .method(hyper::Method::DELETE)
28764                    .uri(url.as_str())
28765                    .header(USER_AGENT, self.hub._user_agent.clone());
28766
28767                if let Some(token) = token.as_ref() {
28768                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28769                }
28770
28771                let request = req_builder
28772                    .header(CONTENT_LENGTH, 0_u64)
28773                    .body(common::to_body::<String>(None));
28774
28775                client.request(request.unwrap()).await
28776            };
28777
28778            match req_result {
28779                Err(err) => {
28780                    if let common::Retry::After(d) = dlg.http_error(&err) {
28781                        sleep(d).await;
28782                        continue;
28783                    }
28784                    dlg.finished(false);
28785                    return Err(common::Error::HttpError(err));
28786                }
28787                Ok(res) => {
28788                    let (mut parts, body) = res.into_parts();
28789                    let mut body = common::Body::new(body);
28790                    if !parts.status.is_success() {
28791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28792                        let error = serde_json::from_str(&common::to_string(&bytes));
28793                        let response = common::to_response(parts, bytes.into());
28794
28795                        if let common::Retry::After(d) =
28796                            dlg.http_failure(&response, error.as_ref().ok())
28797                        {
28798                            sleep(d).await;
28799                            continue;
28800                        }
28801
28802                        dlg.finished(false);
28803
28804                        return Err(match error {
28805                            Ok(value) => common::Error::BadRequest(value),
28806                            _ => common::Error::Failure(response),
28807                        });
28808                    }
28809                    let response = {
28810                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28811                        let encoded = common::to_string(&bytes);
28812                        match serde_json::from_str(&encoded) {
28813                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28814                            Err(error) => {
28815                                dlg.response_json_decode_error(&encoded, &error);
28816                                return Err(common::Error::JsonDecodeError(
28817                                    encoded.to_string(),
28818                                    error,
28819                                ));
28820                            }
28821                        }
28822                    };
28823
28824                    dlg.finished(true);
28825                    return Ok(response);
28826                }
28827            }
28828        }
28829    }
28830
28831    /// Required. A name of the ServerTlsPolicy to delete. Must be in the format `projects/*/locations/{location}/serverTlsPolicies/*`.
28832    ///
28833    /// Sets the *name* path property to the given value.
28834    ///
28835    /// Even though the property as already been set when instantiating this call,
28836    /// we provide this method for API completeness.
28837    pub fn name(mut self, new_value: &str) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C> {
28838        self._name = new_value.to_string();
28839        self
28840    }
28841    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28842    /// while executing the actual API request.
28843    ///
28844    /// ````text
28845    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28846    /// ````
28847    ///
28848    /// Sets the *delegate* property to the given value.
28849    pub fn delegate(
28850        mut self,
28851        new_value: &'a mut dyn common::Delegate,
28852    ) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C> {
28853        self._delegate = Some(new_value);
28854        self
28855    }
28856
28857    /// Set any additional parameter of the query string used in the request.
28858    /// It should be used to set parameters which are not yet available through their own
28859    /// setters.
28860    ///
28861    /// Please note that this method must not be used to set any of the known parameters
28862    /// which have their own setter method. If done anyway, the request will fail.
28863    ///
28864    /// # Additional Parameters
28865    ///
28866    /// * *$.xgafv* (query-string) - V1 error format.
28867    /// * *access_token* (query-string) - OAuth access token.
28868    /// * *alt* (query-string) - Data format for response.
28869    /// * *callback* (query-string) - JSONP
28870    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28871    /// * *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.
28872    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28873    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28874    /// * *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.
28875    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28876    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28877    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C>
28878    where
28879        T: AsRef<str>,
28880    {
28881        self._additional_params
28882            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28883        self
28884    }
28885
28886    /// Identifies the authorization scope for the method you are building.
28887    ///
28888    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28889    /// [`Scope::CloudPlatform`].
28890    ///
28891    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28892    /// tokens for more than one scope.
28893    ///
28894    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28895    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28896    /// sufficient, a read-write scope will do as well.
28897    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C>
28898    where
28899        St: AsRef<str>,
28900    {
28901        self._scopes.insert(String::from(scope.as_ref()));
28902        self
28903    }
28904    /// Identifies the authorization scope(s) for the method you are building.
28905    ///
28906    /// See [`Self::add_scope()`] for details.
28907    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C>
28908    where
28909        I: IntoIterator<Item = St>,
28910        St: AsRef<str>,
28911    {
28912        self._scopes
28913            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28914        self
28915    }
28916
28917    /// Removes all scopes, and no default scope will be used either.
28918    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28919    /// for details).
28920    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyDeleteCall<'a, C> {
28921        self._scopes.clear();
28922        self
28923    }
28924}
28925
28926/// Gets details of a single ServerTlsPolicy.
28927///
28928/// A builder for the *locations.serverTlsPolicies.get* method supported by a *project* resource.
28929/// It is not used directly, but through a [`ProjectMethods`] instance.
28930///
28931/// # Example
28932///
28933/// Instantiate a resource method builder
28934///
28935/// ```test_harness,no_run
28936/// # extern crate hyper;
28937/// # extern crate hyper_rustls;
28938/// # extern crate google_networksecurity1 as networksecurity1;
28939/// # async fn dox() {
28940/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28941///
28942/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28943/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28944/// #     secret,
28945/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28946/// # ).build().await.unwrap();
28947///
28948/// # let client = hyper_util::client::legacy::Client::builder(
28949/// #     hyper_util::rt::TokioExecutor::new()
28950/// # )
28951/// # .build(
28952/// #     hyper_rustls::HttpsConnectorBuilder::new()
28953/// #         .with_native_roots()
28954/// #         .unwrap()
28955/// #         .https_or_http()
28956/// #         .enable_http1()
28957/// #         .build()
28958/// # );
28959/// # let mut hub = NetworkSecurity::new(client, auth);
28960/// // You can configure optional parameters by calling the respective setters at will, and
28961/// // execute the final call using `doit()`.
28962/// // Values shown here are possibly random and not representative !
28963/// let result = hub.projects().locations_server_tls_policies_get("name")
28964///              .doit().await;
28965/// # }
28966/// ```
28967pub struct ProjectLocationServerTlsPolicyGetCall<'a, C>
28968where
28969    C: 'a,
28970{
28971    hub: &'a NetworkSecurity<C>,
28972    _name: String,
28973    _delegate: Option<&'a mut dyn common::Delegate>,
28974    _additional_params: HashMap<String, String>,
28975    _scopes: BTreeSet<String>,
28976}
28977
28978impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyGetCall<'a, C> {}
28979
28980impl<'a, C> ProjectLocationServerTlsPolicyGetCall<'a, C>
28981where
28982    C: common::Connector,
28983{
28984    /// Perform the operation you have build so far.
28985    pub async fn doit(mut self) -> common::Result<(common::Response, ServerTlsPolicy)> {
28986        use std::borrow::Cow;
28987        use std::io::{Read, Seek};
28988
28989        use common::{url::Params, ToParts};
28990        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28991
28992        let mut dd = common::DefaultDelegate;
28993        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28994        dlg.begin(common::MethodInfo {
28995            id: "networksecurity.projects.locations.serverTlsPolicies.get",
28996            http_method: hyper::Method::GET,
28997        });
28998
28999        for &field in ["alt", "name"].iter() {
29000            if self._additional_params.contains_key(field) {
29001                dlg.finished(false);
29002                return Err(common::Error::FieldClash(field));
29003            }
29004        }
29005
29006        let mut params = Params::with_capacity(3 + self._additional_params.len());
29007        params.push("name", self._name);
29008
29009        params.extend(self._additional_params.iter());
29010
29011        params.push("alt", "json");
29012        let mut url = self.hub._base_url.clone() + "v1/{+name}";
29013        if self._scopes.is_empty() {
29014            self._scopes
29015                .insert(Scope::CloudPlatform.as_ref().to_string());
29016        }
29017
29018        #[allow(clippy::single_element_loop)]
29019        for &(find_this, param_name) in [("{+name}", "name")].iter() {
29020            url = params.uri_replacement(url, param_name, find_this, true);
29021        }
29022        {
29023            let to_remove = ["name"];
29024            params.remove_params(&to_remove);
29025        }
29026
29027        let url = params.parse_with_url(&url);
29028
29029        loop {
29030            let token = match self
29031                .hub
29032                .auth
29033                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29034                .await
29035            {
29036                Ok(token) => token,
29037                Err(e) => match dlg.token(e) {
29038                    Ok(token) => token,
29039                    Err(e) => {
29040                        dlg.finished(false);
29041                        return Err(common::Error::MissingToken(e));
29042                    }
29043                },
29044            };
29045            let mut req_result = {
29046                let client = &self.hub.client;
29047                dlg.pre_request();
29048                let mut req_builder = hyper::Request::builder()
29049                    .method(hyper::Method::GET)
29050                    .uri(url.as_str())
29051                    .header(USER_AGENT, self.hub._user_agent.clone());
29052
29053                if let Some(token) = token.as_ref() {
29054                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29055                }
29056
29057                let request = req_builder
29058                    .header(CONTENT_LENGTH, 0_u64)
29059                    .body(common::to_body::<String>(None));
29060
29061                client.request(request.unwrap()).await
29062            };
29063
29064            match req_result {
29065                Err(err) => {
29066                    if let common::Retry::After(d) = dlg.http_error(&err) {
29067                        sleep(d).await;
29068                        continue;
29069                    }
29070                    dlg.finished(false);
29071                    return Err(common::Error::HttpError(err));
29072                }
29073                Ok(res) => {
29074                    let (mut parts, body) = res.into_parts();
29075                    let mut body = common::Body::new(body);
29076                    if !parts.status.is_success() {
29077                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29078                        let error = serde_json::from_str(&common::to_string(&bytes));
29079                        let response = common::to_response(parts, bytes.into());
29080
29081                        if let common::Retry::After(d) =
29082                            dlg.http_failure(&response, error.as_ref().ok())
29083                        {
29084                            sleep(d).await;
29085                            continue;
29086                        }
29087
29088                        dlg.finished(false);
29089
29090                        return Err(match error {
29091                            Ok(value) => common::Error::BadRequest(value),
29092                            _ => common::Error::Failure(response),
29093                        });
29094                    }
29095                    let response = {
29096                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29097                        let encoded = common::to_string(&bytes);
29098                        match serde_json::from_str(&encoded) {
29099                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29100                            Err(error) => {
29101                                dlg.response_json_decode_error(&encoded, &error);
29102                                return Err(common::Error::JsonDecodeError(
29103                                    encoded.to_string(),
29104                                    error,
29105                                ));
29106                            }
29107                        }
29108                    };
29109
29110                    dlg.finished(true);
29111                    return Ok(response);
29112                }
29113            }
29114        }
29115    }
29116
29117    /// Required. A name of the ServerTlsPolicy to get. Must be in the format `projects/*/locations/{location}/serverTlsPolicies/*`.
29118    ///
29119    /// Sets the *name* path property to the given value.
29120    ///
29121    /// Even though the property as already been set when instantiating this call,
29122    /// we provide this method for API completeness.
29123    pub fn name(mut self, new_value: &str) -> ProjectLocationServerTlsPolicyGetCall<'a, C> {
29124        self._name = new_value.to_string();
29125        self
29126    }
29127    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29128    /// while executing the actual API request.
29129    ///
29130    /// ````text
29131    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29132    /// ````
29133    ///
29134    /// Sets the *delegate* property to the given value.
29135    pub fn delegate(
29136        mut self,
29137        new_value: &'a mut dyn common::Delegate,
29138    ) -> ProjectLocationServerTlsPolicyGetCall<'a, C> {
29139        self._delegate = Some(new_value);
29140        self
29141    }
29142
29143    /// Set any additional parameter of the query string used in the request.
29144    /// It should be used to set parameters which are not yet available through their own
29145    /// setters.
29146    ///
29147    /// Please note that this method must not be used to set any of the known parameters
29148    /// which have their own setter method. If done anyway, the request will fail.
29149    ///
29150    /// # Additional Parameters
29151    ///
29152    /// * *$.xgafv* (query-string) - V1 error format.
29153    /// * *access_token* (query-string) - OAuth access token.
29154    /// * *alt* (query-string) - Data format for response.
29155    /// * *callback* (query-string) - JSONP
29156    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29157    /// * *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.
29158    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29159    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29160    /// * *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.
29161    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29162    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29163    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServerTlsPolicyGetCall<'a, C>
29164    where
29165        T: AsRef<str>,
29166    {
29167        self._additional_params
29168            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29169        self
29170    }
29171
29172    /// Identifies the authorization scope for the method you are building.
29173    ///
29174    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29175    /// [`Scope::CloudPlatform`].
29176    ///
29177    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29178    /// tokens for more than one scope.
29179    ///
29180    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29181    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29182    /// sufficient, a read-write scope will do as well.
29183    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServerTlsPolicyGetCall<'a, C>
29184    where
29185        St: AsRef<str>,
29186    {
29187        self._scopes.insert(String::from(scope.as_ref()));
29188        self
29189    }
29190    /// Identifies the authorization scope(s) for the method you are building.
29191    ///
29192    /// See [`Self::add_scope()`] for details.
29193    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServerTlsPolicyGetCall<'a, C>
29194    where
29195        I: IntoIterator<Item = St>,
29196        St: AsRef<str>,
29197    {
29198        self._scopes
29199            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29200        self
29201    }
29202
29203    /// Removes all scopes, and no default scope will be used either.
29204    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29205    /// for details).
29206    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyGetCall<'a, C> {
29207        self._scopes.clear();
29208        self
29209    }
29210}
29211
29212/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
29213///
29214/// A builder for the *locations.serverTlsPolicies.getIamPolicy* method supported by a *project* resource.
29215/// It is not used directly, but through a [`ProjectMethods`] instance.
29216///
29217/// # Example
29218///
29219/// Instantiate a resource method builder
29220///
29221/// ```test_harness,no_run
29222/// # extern crate hyper;
29223/// # extern crate hyper_rustls;
29224/// # extern crate google_networksecurity1 as networksecurity1;
29225/// # async fn dox() {
29226/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29227///
29228/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29229/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29230/// #     secret,
29231/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29232/// # ).build().await.unwrap();
29233///
29234/// # let client = hyper_util::client::legacy::Client::builder(
29235/// #     hyper_util::rt::TokioExecutor::new()
29236/// # )
29237/// # .build(
29238/// #     hyper_rustls::HttpsConnectorBuilder::new()
29239/// #         .with_native_roots()
29240/// #         .unwrap()
29241/// #         .https_or_http()
29242/// #         .enable_http1()
29243/// #         .build()
29244/// # );
29245/// # let mut hub = NetworkSecurity::new(client, auth);
29246/// // You can configure optional parameters by calling the respective setters at will, and
29247/// // execute the final call using `doit()`.
29248/// // Values shown here are possibly random and not representative !
29249/// let result = hub.projects().locations_server_tls_policies_get_iam_policy("resource")
29250///              .options_requested_policy_version(-19)
29251///              .doit().await;
29252/// # }
29253/// ```
29254pub struct ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C>
29255where
29256    C: 'a,
29257{
29258    hub: &'a NetworkSecurity<C>,
29259    _resource: String,
29260    _options_requested_policy_version: Option<i32>,
29261    _delegate: Option<&'a mut dyn common::Delegate>,
29262    _additional_params: HashMap<String, String>,
29263    _scopes: BTreeSet<String>,
29264}
29265
29266impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C> {}
29267
29268impl<'a, C> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C>
29269where
29270    C: common::Connector,
29271{
29272    /// Perform the operation you have build so far.
29273    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
29274        use std::borrow::Cow;
29275        use std::io::{Read, Seek};
29276
29277        use common::{url::Params, ToParts};
29278        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29279
29280        let mut dd = common::DefaultDelegate;
29281        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29282        dlg.begin(common::MethodInfo {
29283            id: "networksecurity.projects.locations.serverTlsPolicies.getIamPolicy",
29284            http_method: hyper::Method::GET,
29285        });
29286
29287        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
29288            if self._additional_params.contains_key(field) {
29289                dlg.finished(false);
29290                return Err(common::Error::FieldClash(field));
29291            }
29292        }
29293
29294        let mut params = Params::with_capacity(4 + self._additional_params.len());
29295        params.push("resource", self._resource);
29296        if let Some(value) = self._options_requested_policy_version.as_ref() {
29297            params.push("options.requestedPolicyVersion", value.to_string());
29298        }
29299
29300        params.extend(self._additional_params.iter());
29301
29302        params.push("alt", "json");
29303        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
29304        if self._scopes.is_empty() {
29305            self._scopes
29306                .insert(Scope::CloudPlatform.as_ref().to_string());
29307        }
29308
29309        #[allow(clippy::single_element_loop)]
29310        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
29311            url = params.uri_replacement(url, param_name, find_this, true);
29312        }
29313        {
29314            let to_remove = ["resource"];
29315            params.remove_params(&to_remove);
29316        }
29317
29318        let url = params.parse_with_url(&url);
29319
29320        loop {
29321            let token = match self
29322                .hub
29323                .auth
29324                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29325                .await
29326            {
29327                Ok(token) => token,
29328                Err(e) => match dlg.token(e) {
29329                    Ok(token) => token,
29330                    Err(e) => {
29331                        dlg.finished(false);
29332                        return Err(common::Error::MissingToken(e));
29333                    }
29334                },
29335            };
29336            let mut req_result = {
29337                let client = &self.hub.client;
29338                dlg.pre_request();
29339                let mut req_builder = hyper::Request::builder()
29340                    .method(hyper::Method::GET)
29341                    .uri(url.as_str())
29342                    .header(USER_AGENT, self.hub._user_agent.clone());
29343
29344                if let Some(token) = token.as_ref() {
29345                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29346                }
29347
29348                let request = req_builder
29349                    .header(CONTENT_LENGTH, 0_u64)
29350                    .body(common::to_body::<String>(None));
29351
29352                client.request(request.unwrap()).await
29353            };
29354
29355            match req_result {
29356                Err(err) => {
29357                    if let common::Retry::After(d) = dlg.http_error(&err) {
29358                        sleep(d).await;
29359                        continue;
29360                    }
29361                    dlg.finished(false);
29362                    return Err(common::Error::HttpError(err));
29363                }
29364                Ok(res) => {
29365                    let (mut parts, body) = res.into_parts();
29366                    let mut body = common::Body::new(body);
29367                    if !parts.status.is_success() {
29368                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29369                        let error = serde_json::from_str(&common::to_string(&bytes));
29370                        let response = common::to_response(parts, bytes.into());
29371
29372                        if let common::Retry::After(d) =
29373                            dlg.http_failure(&response, error.as_ref().ok())
29374                        {
29375                            sleep(d).await;
29376                            continue;
29377                        }
29378
29379                        dlg.finished(false);
29380
29381                        return Err(match error {
29382                            Ok(value) => common::Error::BadRequest(value),
29383                            _ => common::Error::Failure(response),
29384                        });
29385                    }
29386                    let response = {
29387                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29388                        let encoded = common::to_string(&bytes);
29389                        match serde_json::from_str(&encoded) {
29390                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29391                            Err(error) => {
29392                                dlg.response_json_decode_error(&encoded, &error);
29393                                return Err(common::Error::JsonDecodeError(
29394                                    encoded.to_string(),
29395                                    error,
29396                                ));
29397                            }
29398                        }
29399                    };
29400
29401                    dlg.finished(true);
29402                    return Ok(response);
29403                }
29404            }
29405        }
29406    }
29407
29408    /// 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.
29409    ///
29410    /// Sets the *resource* path property to the given value.
29411    ///
29412    /// Even though the property as already been set when instantiating this call,
29413    /// we provide this method for API completeness.
29414    pub fn resource(
29415        mut self,
29416        new_value: &str,
29417    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C> {
29418        self._resource = new_value.to_string();
29419        self
29420    }
29421    /// 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).
29422    ///
29423    /// Sets the *options.requested policy version* query property to the given value.
29424    pub fn options_requested_policy_version(
29425        mut self,
29426        new_value: i32,
29427    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C> {
29428        self._options_requested_policy_version = Some(new_value);
29429        self
29430    }
29431    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29432    /// while executing the actual API request.
29433    ///
29434    /// ````text
29435    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29436    /// ````
29437    ///
29438    /// Sets the *delegate* property to the given value.
29439    pub fn delegate(
29440        mut self,
29441        new_value: &'a mut dyn common::Delegate,
29442    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C> {
29443        self._delegate = Some(new_value);
29444        self
29445    }
29446
29447    /// Set any additional parameter of the query string used in the request.
29448    /// It should be used to set parameters which are not yet available through their own
29449    /// setters.
29450    ///
29451    /// Please note that this method must not be used to set any of the known parameters
29452    /// which have their own setter method. If done anyway, the request will fail.
29453    ///
29454    /// # Additional Parameters
29455    ///
29456    /// * *$.xgafv* (query-string) - V1 error format.
29457    /// * *access_token* (query-string) - OAuth access token.
29458    /// * *alt* (query-string) - Data format for response.
29459    /// * *callback* (query-string) - JSONP
29460    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29461    /// * *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.
29462    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29463    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29464    /// * *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.
29465    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29466    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29467    pub fn param<T>(
29468        mut self,
29469        name: T,
29470        value: T,
29471    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C>
29472    where
29473        T: AsRef<str>,
29474    {
29475        self._additional_params
29476            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29477        self
29478    }
29479
29480    /// Identifies the authorization scope for the method you are building.
29481    ///
29482    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29483    /// [`Scope::CloudPlatform`].
29484    ///
29485    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29486    /// tokens for more than one scope.
29487    ///
29488    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29489    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29490    /// sufficient, a read-write scope will do as well.
29491    pub fn add_scope<St>(
29492        mut self,
29493        scope: St,
29494    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C>
29495    where
29496        St: AsRef<str>,
29497    {
29498        self._scopes.insert(String::from(scope.as_ref()));
29499        self
29500    }
29501    /// Identifies the authorization scope(s) for the method you are building.
29502    ///
29503    /// See [`Self::add_scope()`] for details.
29504    pub fn add_scopes<I, St>(
29505        mut self,
29506        scopes: I,
29507    ) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C>
29508    where
29509        I: IntoIterator<Item = St>,
29510        St: AsRef<str>,
29511    {
29512        self._scopes
29513            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29514        self
29515    }
29516
29517    /// Removes all scopes, and no default scope will be used either.
29518    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29519    /// for details).
29520    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyGetIamPolicyCall<'a, C> {
29521        self._scopes.clear();
29522        self
29523    }
29524}
29525
29526/// Lists ServerTlsPolicies in a given project and location.
29527///
29528/// A builder for the *locations.serverTlsPolicies.list* method supported by a *project* resource.
29529/// It is not used directly, but through a [`ProjectMethods`] instance.
29530///
29531/// # Example
29532///
29533/// Instantiate a resource method builder
29534///
29535/// ```test_harness,no_run
29536/// # extern crate hyper;
29537/// # extern crate hyper_rustls;
29538/// # extern crate google_networksecurity1 as networksecurity1;
29539/// # async fn dox() {
29540/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29541///
29542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29544/// #     secret,
29545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29546/// # ).build().await.unwrap();
29547///
29548/// # let client = hyper_util::client::legacy::Client::builder(
29549/// #     hyper_util::rt::TokioExecutor::new()
29550/// # )
29551/// # .build(
29552/// #     hyper_rustls::HttpsConnectorBuilder::new()
29553/// #         .with_native_roots()
29554/// #         .unwrap()
29555/// #         .https_or_http()
29556/// #         .enable_http1()
29557/// #         .build()
29558/// # );
29559/// # let mut hub = NetworkSecurity::new(client, auth);
29560/// // You can configure optional parameters by calling the respective setters at will, and
29561/// // execute the final call using `doit()`.
29562/// // Values shown here are possibly random and not representative !
29563/// let result = hub.projects().locations_server_tls_policies_list("parent")
29564///              .page_token("et")
29565///              .page_size(-10)
29566///              .doit().await;
29567/// # }
29568/// ```
29569pub struct ProjectLocationServerTlsPolicyListCall<'a, C>
29570where
29571    C: 'a,
29572{
29573    hub: &'a NetworkSecurity<C>,
29574    _parent: String,
29575    _page_token: Option<String>,
29576    _page_size: Option<i32>,
29577    _delegate: Option<&'a mut dyn common::Delegate>,
29578    _additional_params: HashMap<String, String>,
29579    _scopes: BTreeSet<String>,
29580}
29581
29582impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyListCall<'a, C> {}
29583
29584impl<'a, C> ProjectLocationServerTlsPolicyListCall<'a, C>
29585where
29586    C: common::Connector,
29587{
29588    /// Perform the operation you have build so far.
29589    pub async fn doit(
29590        mut self,
29591    ) -> common::Result<(common::Response, ListServerTlsPoliciesResponse)> {
29592        use std::borrow::Cow;
29593        use std::io::{Read, Seek};
29594
29595        use common::{url::Params, ToParts};
29596        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29597
29598        let mut dd = common::DefaultDelegate;
29599        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29600        dlg.begin(common::MethodInfo {
29601            id: "networksecurity.projects.locations.serverTlsPolicies.list",
29602            http_method: hyper::Method::GET,
29603        });
29604
29605        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
29606            if self._additional_params.contains_key(field) {
29607                dlg.finished(false);
29608                return Err(common::Error::FieldClash(field));
29609            }
29610        }
29611
29612        let mut params = Params::with_capacity(5 + self._additional_params.len());
29613        params.push("parent", self._parent);
29614        if let Some(value) = self._page_token.as_ref() {
29615            params.push("pageToken", value);
29616        }
29617        if let Some(value) = self._page_size.as_ref() {
29618            params.push("pageSize", value.to_string());
29619        }
29620
29621        params.extend(self._additional_params.iter());
29622
29623        params.push("alt", "json");
29624        let mut url = self.hub._base_url.clone() + "v1/{+parent}/serverTlsPolicies";
29625        if self._scopes.is_empty() {
29626            self._scopes
29627                .insert(Scope::CloudPlatform.as_ref().to_string());
29628        }
29629
29630        #[allow(clippy::single_element_loop)]
29631        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
29632            url = params.uri_replacement(url, param_name, find_this, true);
29633        }
29634        {
29635            let to_remove = ["parent"];
29636            params.remove_params(&to_remove);
29637        }
29638
29639        let url = params.parse_with_url(&url);
29640
29641        loop {
29642            let token = match self
29643                .hub
29644                .auth
29645                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29646                .await
29647            {
29648                Ok(token) => token,
29649                Err(e) => match dlg.token(e) {
29650                    Ok(token) => token,
29651                    Err(e) => {
29652                        dlg.finished(false);
29653                        return Err(common::Error::MissingToken(e));
29654                    }
29655                },
29656            };
29657            let mut req_result = {
29658                let client = &self.hub.client;
29659                dlg.pre_request();
29660                let mut req_builder = hyper::Request::builder()
29661                    .method(hyper::Method::GET)
29662                    .uri(url.as_str())
29663                    .header(USER_AGENT, self.hub._user_agent.clone());
29664
29665                if let Some(token) = token.as_ref() {
29666                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29667                }
29668
29669                let request = req_builder
29670                    .header(CONTENT_LENGTH, 0_u64)
29671                    .body(common::to_body::<String>(None));
29672
29673                client.request(request.unwrap()).await
29674            };
29675
29676            match req_result {
29677                Err(err) => {
29678                    if let common::Retry::After(d) = dlg.http_error(&err) {
29679                        sleep(d).await;
29680                        continue;
29681                    }
29682                    dlg.finished(false);
29683                    return Err(common::Error::HttpError(err));
29684                }
29685                Ok(res) => {
29686                    let (mut parts, body) = res.into_parts();
29687                    let mut body = common::Body::new(body);
29688                    if !parts.status.is_success() {
29689                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29690                        let error = serde_json::from_str(&common::to_string(&bytes));
29691                        let response = common::to_response(parts, bytes.into());
29692
29693                        if let common::Retry::After(d) =
29694                            dlg.http_failure(&response, error.as_ref().ok())
29695                        {
29696                            sleep(d).await;
29697                            continue;
29698                        }
29699
29700                        dlg.finished(false);
29701
29702                        return Err(match error {
29703                            Ok(value) => common::Error::BadRequest(value),
29704                            _ => common::Error::Failure(response),
29705                        });
29706                    }
29707                    let response = {
29708                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29709                        let encoded = common::to_string(&bytes);
29710                        match serde_json::from_str(&encoded) {
29711                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29712                            Err(error) => {
29713                                dlg.response_json_decode_error(&encoded, &error);
29714                                return Err(common::Error::JsonDecodeError(
29715                                    encoded.to_string(),
29716                                    error,
29717                                ));
29718                            }
29719                        }
29720                    };
29721
29722                    dlg.finished(true);
29723                    return Ok(response);
29724                }
29725            }
29726        }
29727    }
29728
29729    /// Required. The project and location from which the ServerTlsPolicies should be listed, specified in the format `projects/*/locations/{location}`.
29730    ///
29731    /// Sets the *parent* path property to the given value.
29732    ///
29733    /// Even though the property as already been set when instantiating this call,
29734    /// we provide this method for API completeness.
29735    pub fn parent(mut self, new_value: &str) -> ProjectLocationServerTlsPolicyListCall<'a, C> {
29736        self._parent = new_value.to_string();
29737        self
29738    }
29739    /// The value returned by the last `ListServerTlsPoliciesResponse` Indicates that this is a continuation of a prior `ListServerTlsPolicies` call, and that the system should return the next page of data.
29740    ///
29741    /// Sets the *page token* query property to the given value.
29742    pub fn page_token(mut self, new_value: &str) -> ProjectLocationServerTlsPolicyListCall<'a, C> {
29743        self._page_token = Some(new_value.to_string());
29744        self
29745    }
29746    /// Maximum number of ServerTlsPolicies to return per call.
29747    ///
29748    /// Sets the *page size* query property to the given value.
29749    pub fn page_size(mut self, new_value: i32) -> ProjectLocationServerTlsPolicyListCall<'a, C> {
29750        self._page_size = Some(new_value);
29751        self
29752    }
29753    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29754    /// while executing the actual API request.
29755    ///
29756    /// ````text
29757    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29758    /// ````
29759    ///
29760    /// Sets the *delegate* property to the given value.
29761    pub fn delegate(
29762        mut self,
29763        new_value: &'a mut dyn common::Delegate,
29764    ) -> ProjectLocationServerTlsPolicyListCall<'a, C> {
29765        self._delegate = Some(new_value);
29766        self
29767    }
29768
29769    /// Set any additional parameter of the query string used in the request.
29770    /// It should be used to set parameters which are not yet available through their own
29771    /// setters.
29772    ///
29773    /// Please note that this method must not be used to set any of the known parameters
29774    /// which have their own setter method. If done anyway, the request will fail.
29775    ///
29776    /// # Additional Parameters
29777    ///
29778    /// * *$.xgafv* (query-string) - V1 error format.
29779    /// * *access_token* (query-string) - OAuth access token.
29780    /// * *alt* (query-string) - Data format for response.
29781    /// * *callback* (query-string) - JSONP
29782    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29783    /// * *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.
29784    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29785    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29786    /// * *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.
29787    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29788    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29789    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServerTlsPolicyListCall<'a, C>
29790    where
29791        T: AsRef<str>,
29792    {
29793        self._additional_params
29794            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29795        self
29796    }
29797
29798    /// Identifies the authorization scope for the method you are building.
29799    ///
29800    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29801    /// [`Scope::CloudPlatform`].
29802    ///
29803    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29804    /// tokens for more than one scope.
29805    ///
29806    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29807    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29808    /// sufficient, a read-write scope will do as well.
29809    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServerTlsPolicyListCall<'a, C>
29810    where
29811        St: AsRef<str>,
29812    {
29813        self._scopes.insert(String::from(scope.as_ref()));
29814        self
29815    }
29816    /// Identifies the authorization scope(s) for the method you are building.
29817    ///
29818    /// See [`Self::add_scope()`] for details.
29819    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServerTlsPolicyListCall<'a, C>
29820    where
29821        I: IntoIterator<Item = St>,
29822        St: AsRef<str>,
29823    {
29824        self._scopes
29825            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29826        self
29827    }
29828
29829    /// Removes all scopes, and no default scope will be used either.
29830    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29831    /// for details).
29832    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyListCall<'a, C> {
29833        self._scopes.clear();
29834        self
29835    }
29836}
29837
29838/// Updates the parameters of a single ServerTlsPolicy.
29839///
29840/// A builder for the *locations.serverTlsPolicies.patch* method supported by a *project* resource.
29841/// It is not used directly, but through a [`ProjectMethods`] instance.
29842///
29843/// # Example
29844///
29845/// Instantiate a resource method builder
29846///
29847/// ```test_harness,no_run
29848/// # extern crate hyper;
29849/// # extern crate hyper_rustls;
29850/// # extern crate google_networksecurity1 as networksecurity1;
29851/// use networksecurity1::api::ServerTlsPolicy;
29852/// # async fn dox() {
29853/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29854///
29855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29857/// #     secret,
29858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29859/// # ).build().await.unwrap();
29860///
29861/// # let client = hyper_util::client::legacy::Client::builder(
29862/// #     hyper_util::rt::TokioExecutor::new()
29863/// # )
29864/// # .build(
29865/// #     hyper_rustls::HttpsConnectorBuilder::new()
29866/// #         .with_native_roots()
29867/// #         .unwrap()
29868/// #         .https_or_http()
29869/// #         .enable_http1()
29870/// #         .build()
29871/// # );
29872/// # let mut hub = NetworkSecurity::new(client, auth);
29873/// // As the method needs a request, you would usually fill it with the desired information
29874/// // into the respective structure. Some of the parts shown here might not be applicable !
29875/// // Values shown here are possibly random and not representative !
29876/// let mut req = ServerTlsPolicy::default();
29877///
29878/// // You can configure optional parameters by calling the respective setters at will, and
29879/// // execute the final call using `doit()`.
29880/// // Values shown here are possibly random and not representative !
29881/// let result = hub.projects().locations_server_tls_policies_patch(req, "name")
29882///              .update_mask(FieldMask::new::<&str>(&[]))
29883///              .doit().await;
29884/// # }
29885/// ```
29886pub struct ProjectLocationServerTlsPolicyPatchCall<'a, C>
29887where
29888    C: 'a,
29889{
29890    hub: &'a NetworkSecurity<C>,
29891    _request: ServerTlsPolicy,
29892    _name: String,
29893    _update_mask: Option<common::FieldMask>,
29894    _delegate: Option<&'a mut dyn common::Delegate>,
29895    _additional_params: HashMap<String, String>,
29896    _scopes: BTreeSet<String>,
29897}
29898
29899impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyPatchCall<'a, C> {}
29900
29901impl<'a, C> ProjectLocationServerTlsPolicyPatchCall<'a, C>
29902where
29903    C: common::Connector,
29904{
29905    /// Perform the operation you have build so far.
29906    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29907        use std::borrow::Cow;
29908        use std::io::{Read, Seek};
29909
29910        use common::{url::Params, ToParts};
29911        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29912
29913        let mut dd = common::DefaultDelegate;
29914        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29915        dlg.begin(common::MethodInfo {
29916            id: "networksecurity.projects.locations.serverTlsPolicies.patch",
29917            http_method: hyper::Method::PATCH,
29918        });
29919
29920        for &field in ["alt", "name", "updateMask"].iter() {
29921            if self._additional_params.contains_key(field) {
29922                dlg.finished(false);
29923                return Err(common::Error::FieldClash(field));
29924            }
29925        }
29926
29927        let mut params = Params::with_capacity(5 + self._additional_params.len());
29928        params.push("name", self._name);
29929        if let Some(value) = self._update_mask.as_ref() {
29930            params.push("updateMask", value.to_string());
29931        }
29932
29933        params.extend(self._additional_params.iter());
29934
29935        params.push("alt", "json");
29936        let mut url = self.hub._base_url.clone() + "v1/{+name}";
29937        if self._scopes.is_empty() {
29938            self._scopes
29939                .insert(Scope::CloudPlatform.as_ref().to_string());
29940        }
29941
29942        #[allow(clippy::single_element_loop)]
29943        for &(find_this, param_name) in [("{+name}", "name")].iter() {
29944            url = params.uri_replacement(url, param_name, find_this, true);
29945        }
29946        {
29947            let to_remove = ["name"];
29948            params.remove_params(&to_remove);
29949        }
29950
29951        let url = params.parse_with_url(&url);
29952
29953        let mut json_mime_type = mime::APPLICATION_JSON;
29954        let mut request_value_reader = {
29955            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29956            common::remove_json_null_values(&mut value);
29957            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29958            serde_json::to_writer(&mut dst, &value).unwrap();
29959            dst
29960        };
29961        let request_size = request_value_reader
29962            .seek(std::io::SeekFrom::End(0))
29963            .unwrap();
29964        request_value_reader
29965            .seek(std::io::SeekFrom::Start(0))
29966            .unwrap();
29967
29968        loop {
29969            let token = match self
29970                .hub
29971                .auth
29972                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29973                .await
29974            {
29975                Ok(token) => token,
29976                Err(e) => match dlg.token(e) {
29977                    Ok(token) => token,
29978                    Err(e) => {
29979                        dlg.finished(false);
29980                        return Err(common::Error::MissingToken(e));
29981                    }
29982                },
29983            };
29984            request_value_reader
29985                .seek(std::io::SeekFrom::Start(0))
29986                .unwrap();
29987            let mut req_result = {
29988                let client = &self.hub.client;
29989                dlg.pre_request();
29990                let mut req_builder = hyper::Request::builder()
29991                    .method(hyper::Method::PATCH)
29992                    .uri(url.as_str())
29993                    .header(USER_AGENT, self.hub._user_agent.clone());
29994
29995                if let Some(token) = token.as_ref() {
29996                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29997                }
29998
29999                let request = req_builder
30000                    .header(CONTENT_TYPE, json_mime_type.to_string())
30001                    .header(CONTENT_LENGTH, request_size as u64)
30002                    .body(common::to_body(
30003                        request_value_reader.get_ref().clone().into(),
30004                    ));
30005
30006                client.request(request.unwrap()).await
30007            };
30008
30009            match req_result {
30010                Err(err) => {
30011                    if let common::Retry::After(d) = dlg.http_error(&err) {
30012                        sleep(d).await;
30013                        continue;
30014                    }
30015                    dlg.finished(false);
30016                    return Err(common::Error::HttpError(err));
30017                }
30018                Ok(res) => {
30019                    let (mut parts, body) = res.into_parts();
30020                    let mut body = common::Body::new(body);
30021                    if !parts.status.is_success() {
30022                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30023                        let error = serde_json::from_str(&common::to_string(&bytes));
30024                        let response = common::to_response(parts, bytes.into());
30025
30026                        if let common::Retry::After(d) =
30027                            dlg.http_failure(&response, error.as_ref().ok())
30028                        {
30029                            sleep(d).await;
30030                            continue;
30031                        }
30032
30033                        dlg.finished(false);
30034
30035                        return Err(match error {
30036                            Ok(value) => common::Error::BadRequest(value),
30037                            _ => common::Error::Failure(response),
30038                        });
30039                    }
30040                    let response = {
30041                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30042                        let encoded = common::to_string(&bytes);
30043                        match serde_json::from_str(&encoded) {
30044                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30045                            Err(error) => {
30046                                dlg.response_json_decode_error(&encoded, &error);
30047                                return Err(common::Error::JsonDecodeError(
30048                                    encoded.to_string(),
30049                                    error,
30050                                ));
30051                            }
30052                        }
30053                    };
30054
30055                    dlg.finished(true);
30056                    return Ok(response);
30057                }
30058            }
30059        }
30060    }
30061
30062    ///
30063    /// Sets the *request* property to the given value.
30064    ///
30065    /// Even though the property as already been set when instantiating this call,
30066    /// we provide this method for API completeness.
30067    pub fn request(
30068        mut self,
30069        new_value: ServerTlsPolicy,
30070    ) -> ProjectLocationServerTlsPolicyPatchCall<'a, C> {
30071        self._request = new_value;
30072        self
30073    }
30074    /// Required. Name of the ServerTlsPolicy resource. It matches the pattern `projects/*/locations/{location}/serverTlsPolicies/{server_tls_policy}`
30075    ///
30076    /// Sets the *name* path property to the given value.
30077    ///
30078    /// Even though the property as already been set when instantiating this call,
30079    /// we provide this method for API completeness.
30080    pub fn name(mut self, new_value: &str) -> ProjectLocationServerTlsPolicyPatchCall<'a, C> {
30081        self._name = new_value.to_string();
30082        self
30083    }
30084    /// Optional. Field mask is used to specify the fields to be overwritten in the ServerTlsPolicy 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.
30085    ///
30086    /// Sets the *update mask* query property to the given value.
30087    pub fn update_mask(
30088        mut self,
30089        new_value: common::FieldMask,
30090    ) -> ProjectLocationServerTlsPolicyPatchCall<'a, C> {
30091        self._update_mask = Some(new_value);
30092        self
30093    }
30094    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30095    /// while executing the actual API request.
30096    ///
30097    /// ````text
30098    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30099    /// ````
30100    ///
30101    /// Sets the *delegate* property to the given value.
30102    pub fn delegate(
30103        mut self,
30104        new_value: &'a mut dyn common::Delegate,
30105    ) -> ProjectLocationServerTlsPolicyPatchCall<'a, C> {
30106        self._delegate = Some(new_value);
30107        self
30108    }
30109
30110    /// Set any additional parameter of the query string used in the request.
30111    /// It should be used to set parameters which are not yet available through their own
30112    /// setters.
30113    ///
30114    /// Please note that this method must not be used to set any of the known parameters
30115    /// which have their own setter method. If done anyway, the request will fail.
30116    ///
30117    /// # Additional Parameters
30118    ///
30119    /// * *$.xgafv* (query-string) - V1 error format.
30120    /// * *access_token* (query-string) - OAuth access token.
30121    /// * *alt* (query-string) - Data format for response.
30122    /// * *callback* (query-string) - JSONP
30123    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30124    /// * *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.
30125    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30126    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30127    /// * *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.
30128    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30129    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30130    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServerTlsPolicyPatchCall<'a, C>
30131    where
30132        T: AsRef<str>,
30133    {
30134        self._additional_params
30135            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30136        self
30137    }
30138
30139    /// Identifies the authorization scope for the method you are building.
30140    ///
30141    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30142    /// [`Scope::CloudPlatform`].
30143    ///
30144    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30145    /// tokens for more than one scope.
30146    ///
30147    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30148    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30149    /// sufficient, a read-write scope will do as well.
30150    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServerTlsPolicyPatchCall<'a, C>
30151    where
30152        St: AsRef<str>,
30153    {
30154        self._scopes.insert(String::from(scope.as_ref()));
30155        self
30156    }
30157    /// Identifies the authorization scope(s) for the method you are building.
30158    ///
30159    /// See [`Self::add_scope()`] for details.
30160    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServerTlsPolicyPatchCall<'a, C>
30161    where
30162        I: IntoIterator<Item = St>,
30163        St: AsRef<str>,
30164    {
30165        self._scopes
30166            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30167        self
30168    }
30169
30170    /// Removes all scopes, and no default scope will be used either.
30171    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30172    /// for details).
30173    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyPatchCall<'a, C> {
30174        self._scopes.clear();
30175        self
30176    }
30177}
30178
30179/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
30180///
30181/// A builder for the *locations.serverTlsPolicies.setIamPolicy* method supported by a *project* resource.
30182/// It is not used directly, but through a [`ProjectMethods`] instance.
30183///
30184/// # Example
30185///
30186/// Instantiate a resource method builder
30187///
30188/// ```test_harness,no_run
30189/// # extern crate hyper;
30190/// # extern crate hyper_rustls;
30191/// # extern crate google_networksecurity1 as networksecurity1;
30192/// use networksecurity1::api::GoogleIamV1SetIamPolicyRequest;
30193/// # async fn dox() {
30194/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30195///
30196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30197/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30198/// #     secret,
30199/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30200/// # ).build().await.unwrap();
30201///
30202/// # let client = hyper_util::client::legacy::Client::builder(
30203/// #     hyper_util::rt::TokioExecutor::new()
30204/// # )
30205/// # .build(
30206/// #     hyper_rustls::HttpsConnectorBuilder::new()
30207/// #         .with_native_roots()
30208/// #         .unwrap()
30209/// #         .https_or_http()
30210/// #         .enable_http1()
30211/// #         .build()
30212/// # );
30213/// # let mut hub = NetworkSecurity::new(client, auth);
30214/// // As the method needs a request, you would usually fill it with the desired information
30215/// // into the respective structure. Some of the parts shown here might not be applicable !
30216/// // Values shown here are possibly random and not representative !
30217/// let mut req = GoogleIamV1SetIamPolicyRequest::default();
30218///
30219/// // You can configure optional parameters by calling the respective setters at will, and
30220/// // execute the final call using `doit()`.
30221/// // Values shown here are possibly random and not representative !
30222/// let result = hub.projects().locations_server_tls_policies_set_iam_policy(req, "resource")
30223///              .doit().await;
30224/// # }
30225/// ```
30226pub struct ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C>
30227where
30228    C: 'a,
30229{
30230    hub: &'a NetworkSecurity<C>,
30231    _request: GoogleIamV1SetIamPolicyRequest,
30232    _resource: String,
30233    _delegate: Option<&'a mut dyn common::Delegate>,
30234    _additional_params: HashMap<String, String>,
30235    _scopes: BTreeSet<String>,
30236}
30237
30238impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C> {}
30239
30240impl<'a, C> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C>
30241where
30242    C: common::Connector,
30243{
30244    /// Perform the operation you have build so far.
30245    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1Policy)> {
30246        use std::borrow::Cow;
30247        use std::io::{Read, Seek};
30248
30249        use common::{url::Params, ToParts};
30250        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30251
30252        let mut dd = common::DefaultDelegate;
30253        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30254        dlg.begin(common::MethodInfo {
30255            id: "networksecurity.projects.locations.serverTlsPolicies.setIamPolicy",
30256            http_method: hyper::Method::POST,
30257        });
30258
30259        for &field in ["alt", "resource"].iter() {
30260            if self._additional_params.contains_key(field) {
30261                dlg.finished(false);
30262                return Err(common::Error::FieldClash(field));
30263            }
30264        }
30265
30266        let mut params = Params::with_capacity(4 + self._additional_params.len());
30267        params.push("resource", self._resource);
30268
30269        params.extend(self._additional_params.iter());
30270
30271        params.push("alt", "json");
30272        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
30273        if self._scopes.is_empty() {
30274            self._scopes
30275                .insert(Scope::CloudPlatform.as_ref().to_string());
30276        }
30277
30278        #[allow(clippy::single_element_loop)]
30279        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
30280            url = params.uri_replacement(url, param_name, find_this, true);
30281        }
30282        {
30283            let to_remove = ["resource"];
30284            params.remove_params(&to_remove);
30285        }
30286
30287        let url = params.parse_with_url(&url);
30288
30289        let mut json_mime_type = mime::APPLICATION_JSON;
30290        let mut request_value_reader = {
30291            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30292            common::remove_json_null_values(&mut value);
30293            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30294            serde_json::to_writer(&mut dst, &value).unwrap();
30295            dst
30296        };
30297        let request_size = request_value_reader
30298            .seek(std::io::SeekFrom::End(0))
30299            .unwrap();
30300        request_value_reader
30301            .seek(std::io::SeekFrom::Start(0))
30302            .unwrap();
30303
30304        loop {
30305            let token = match self
30306                .hub
30307                .auth
30308                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30309                .await
30310            {
30311                Ok(token) => token,
30312                Err(e) => match dlg.token(e) {
30313                    Ok(token) => token,
30314                    Err(e) => {
30315                        dlg.finished(false);
30316                        return Err(common::Error::MissingToken(e));
30317                    }
30318                },
30319            };
30320            request_value_reader
30321                .seek(std::io::SeekFrom::Start(0))
30322                .unwrap();
30323            let mut req_result = {
30324                let client = &self.hub.client;
30325                dlg.pre_request();
30326                let mut req_builder = hyper::Request::builder()
30327                    .method(hyper::Method::POST)
30328                    .uri(url.as_str())
30329                    .header(USER_AGENT, self.hub._user_agent.clone());
30330
30331                if let Some(token) = token.as_ref() {
30332                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30333                }
30334
30335                let request = req_builder
30336                    .header(CONTENT_TYPE, json_mime_type.to_string())
30337                    .header(CONTENT_LENGTH, request_size as u64)
30338                    .body(common::to_body(
30339                        request_value_reader.get_ref().clone().into(),
30340                    ));
30341
30342                client.request(request.unwrap()).await
30343            };
30344
30345            match req_result {
30346                Err(err) => {
30347                    if let common::Retry::After(d) = dlg.http_error(&err) {
30348                        sleep(d).await;
30349                        continue;
30350                    }
30351                    dlg.finished(false);
30352                    return Err(common::Error::HttpError(err));
30353                }
30354                Ok(res) => {
30355                    let (mut parts, body) = res.into_parts();
30356                    let mut body = common::Body::new(body);
30357                    if !parts.status.is_success() {
30358                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30359                        let error = serde_json::from_str(&common::to_string(&bytes));
30360                        let response = common::to_response(parts, bytes.into());
30361
30362                        if let common::Retry::After(d) =
30363                            dlg.http_failure(&response, error.as_ref().ok())
30364                        {
30365                            sleep(d).await;
30366                            continue;
30367                        }
30368
30369                        dlg.finished(false);
30370
30371                        return Err(match error {
30372                            Ok(value) => common::Error::BadRequest(value),
30373                            _ => common::Error::Failure(response),
30374                        });
30375                    }
30376                    let response = {
30377                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30378                        let encoded = common::to_string(&bytes);
30379                        match serde_json::from_str(&encoded) {
30380                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30381                            Err(error) => {
30382                                dlg.response_json_decode_error(&encoded, &error);
30383                                return Err(common::Error::JsonDecodeError(
30384                                    encoded.to_string(),
30385                                    error,
30386                                ));
30387                            }
30388                        }
30389                    };
30390
30391                    dlg.finished(true);
30392                    return Ok(response);
30393                }
30394            }
30395        }
30396    }
30397
30398    ///
30399    /// Sets the *request* property to the given value.
30400    ///
30401    /// Even though the property as already been set when instantiating this call,
30402    /// we provide this method for API completeness.
30403    pub fn request(
30404        mut self,
30405        new_value: GoogleIamV1SetIamPolicyRequest,
30406    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C> {
30407        self._request = new_value;
30408        self
30409    }
30410    /// 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.
30411    ///
30412    /// Sets the *resource* path property to the given value.
30413    ///
30414    /// Even though the property as already been set when instantiating this call,
30415    /// we provide this method for API completeness.
30416    pub fn resource(
30417        mut self,
30418        new_value: &str,
30419    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C> {
30420        self._resource = new_value.to_string();
30421        self
30422    }
30423    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30424    /// while executing the actual API request.
30425    ///
30426    /// ````text
30427    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30428    /// ````
30429    ///
30430    /// Sets the *delegate* property to the given value.
30431    pub fn delegate(
30432        mut self,
30433        new_value: &'a mut dyn common::Delegate,
30434    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C> {
30435        self._delegate = Some(new_value);
30436        self
30437    }
30438
30439    /// Set any additional parameter of the query string used in the request.
30440    /// It should be used to set parameters which are not yet available through their own
30441    /// setters.
30442    ///
30443    /// Please note that this method must not be used to set any of the known parameters
30444    /// which have their own setter method. If done anyway, the request will fail.
30445    ///
30446    /// # Additional Parameters
30447    ///
30448    /// * *$.xgafv* (query-string) - V1 error format.
30449    /// * *access_token* (query-string) - OAuth access token.
30450    /// * *alt* (query-string) - Data format for response.
30451    /// * *callback* (query-string) - JSONP
30452    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30453    /// * *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.
30454    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30455    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30456    /// * *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.
30457    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30458    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30459    pub fn param<T>(
30460        mut self,
30461        name: T,
30462        value: T,
30463    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C>
30464    where
30465        T: AsRef<str>,
30466    {
30467        self._additional_params
30468            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30469        self
30470    }
30471
30472    /// Identifies the authorization scope for the method you are building.
30473    ///
30474    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30475    /// [`Scope::CloudPlatform`].
30476    ///
30477    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30478    /// tokens for more than one scope.
30479    ///
30480    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30481    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30482    /// sufficient, a read-write scope will do as well.
30483    pub fn add_scope<St>(
30484        mut self,
30485        scope: St,
30486    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C>
30487    where
30488        St: AsRef<str>,
30489    {
30490        self._scopes.insert(String::from(scope.as_ref()));
30491        self
30492    }
30493    /// Identifies the authorization scope(s) for the method you are building.
30494    ///
30495    /// See [`Self::add_scope()`] for details.
30496    pub fn add_scopes<I, St>(
30497        mut self,
30498        scopes: I,
30499    ) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C>
30500    where
30501        I: IntoIterator<Item = St>,
30502        St: AsRef<str>,
30503    {
30504        self._scopes
30505            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30506        self
30507    }
30508
30509    /// Removes all scopes, and no default scope will be used either.
30510    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30511    /// for details).
30512    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicySetIamPolicyCall<'a, C> {
30513        self._scopes.clear();
30514        self
30515    }
30516}
30517
30518/// 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.
30519///
30520/// A builder for the *locations.serverTlsPolicies.testIamPermissions* method supported by a *project* resource.
30521/// It is not used directly, but through a [`ProjectMethods`] instance.
30522///
30523/// # Example
30524///
30525/// Instantiate a resource method builder
30526///
30527/// ```test_harness,no_run
30528/// # extern crate hyper;
30529/// # extern crate hyper_rustls;
30530/// # extern crate google_networksecurity1 as networksecurity1;
30531/// use networksecurity1::api::GoogleIamV1TestIamPermissionsRequest;
30532/// # async fn dox() {
30533/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30534///
30535/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30536/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30537/// #     secret,
30538/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30539/// # ).build().await.unwrap();
30540///
30541/// # let client = hyper_util::client::legacy::Client::builder(
30542/// #     hyper_util::rt::TokioExecutor::new()
30543/// # )
30544/// # .build(
30545/// #     hyper_rustls::HttpsConnectorBuilder::new()
30546/// #         .with_native_roots()
30547/// #         .unwrap()
30548/// #         .https_or_http()
30549/// #         .enable_http1()
30550/// #         .build()
30551/// # );
30552/// # let mut hub = NetworkSecurity::new(client, auth);
30553/// // As the method needs a request, you would usually fill it with the desired information
30554/// // into the respective structure. Some of the parts shown here might not be applicable !
30555/// // Values shown here are possibly random and not representative !
30556/// let mut req = GoogleIamV1TestIamPermissionsRequest::default();
30557///
30558/// // You can configure optional parameters by calling the respective setters at will, and
30559/// // execute the final call using `doit()`.
30560/// // Values shown here are possibly random and not representative !
30561/// let result = hub.projects().locations_server_tls_policies_test_iam_permissions(req, "resource")
30562///              .doit().await;
30563/// # }
30564/// ```
30565pub struct ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C>
30566where
30567    C: 'a,
30568{
30569    hub: &'a NetworkSecurity<C>,
30570    _request: GoogleIamV1TestIamPermissionsRequest,
30571    _resource: String,
30572    _delegate: Option<&'a mut dyn common::Delegate>,
30573    _additional_params: HashMap<String, String>,
30574    _scopes: BTreeSet<String>,
30575}
30576
30577impl<'a, C> common::CallBuilder for ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C> {}
30578
30579impl<'a, C> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C>
30580where
30581    C: common::Connector,
30582{
30583    /// Perform the operation you have build so far.
30584    pub async fn doit(
30585        mut self,
30586    ) -> common::Result<(common::Response, GoogleIamV1TestIamPermissionsResponse)> {
30587        use std::borrow::Cow;
30588        use std::io::{Read, Seek};
30589
30590        use common::{url::Params, ToParts};
30591        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30592
30593        let mut dd = common::DefaultDelegate;
30594        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30595        dlg.begin(common::MethodInfo {
30596            id: "networksecurity.projects.locations.serverTlsPolicies.testIamPermissions",
30597            http_method: hyper::Method::POST,
30598        });
30599
30600        for &field in ["alt", "resource"].iter() {
30601            if self._additional_params.contains_key(field) {
30602                dlg.finished(false);
30603                return Err(common::Error::FieldClash(field));
30604            }
30605        }
30606
30607        let mut params = Params::with_capacity(4 + self._additional_params.len());
30608        params.push("resource", self._resource);
30609
30610        params.extend(self._additional_params.iter());
30611
30612        params.push("alt", "json");
30613        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
30614        if self._scopes.is_empty() {
30615            self._scopes
30616                .insert(Scope::CloudPlatform.as_ref().to_string());
30617        }
30618
30619        #[allow(clippy::single_element_loop)]
30620        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
30621            url = params.uri_replacement(url, param_name, find_this, true);
30622        }
30623        {
30624            let to_remove = ["resource"];
30625            params.remove_params(&to_remove);
30626        }
30627
30628        let url = params.parse_with_url(&url);
30629
30630        let mut json_mime_type = mime::APPLICATION_JSON;
30631        let mut request_value_reader = {
30632            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30633            common::remove_json_null_values(&mut value);
30634            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30635            serde_json::to_writer(&mut dst, &value).unwrap();
30636            dst
30637        };
30638        let request_size = request_value_reader
30639            .seek(std::io::SeekFrom::End(0))
30640            .unwrap();
30641        request_value_reader
30642            .seek(std::io::SeekFrom::Start(0))
30643            .unwrap();
30644
30645        loop {
30646            let token = match self
30647                .hub
30648                .auth
30649                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30650                .await
30651            {
30652                Ok(token) => token,
30653                Err(e) => match dlg.token(e) {
30654                    Ok(token) => token,
30655                    Err(e) => {
30656                        dlg.finished(false);
30657                        return Err(common::Error::MissingToken(e));
30658                    }
30659                },
30660            };
30661            request_value_reader
30662                .seek(std::io::SeekFrom::Start(0))
30663                .unwrap();
30664            let mut req_result = {
30665                let client = &self.hub.client;
30666                dlg.pre_request();
30667                let mut req_builder = hyper::Request::builder()
30668                    .method(hyper::Method::POST)
30669                    .uri(url.as_str())
30670                    .header(USER_AGENT, self.hub._user_agent.clone());
30671
30672                if let Some(token) = token.as_ref() {
30673                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30674                }
30675
30676                let request = req_builder
30677                    .header(CONTENT_TYPE, json_mime_type.to_string())
30678                    .header(CONTENT_LENGTH, request_size as u64)
30679                    .body(common::to_body(
30680                        request_value_reader.get_ref().clone().into(),
30681                    ));
30682
30683                client.request(request.unwrap()).await
30684            };
30685
30686            match req_result {
30687                Err(err) => {
30688                    if let common::Retry::After(d) = dlg.http_error(&err) {
30689                        sleep(d).await;
30690                        continue;
30691                    }
30692                    dlg.finished(false);
30693                    return Err(common::Error::HttpError(err));
30694                }
30695                Ok(res) => {
30696                    let (mut parts, body) = res.into_parts();
30697                    let mut body = common::Body::new(body);
30698                    if !parts.status.is_success() {
30699                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30700                        let error = serde_json::from_str(&common::to_string(&bytes));
30701                        let response = common::to_response(parts, bytes.into());
30702
30703                        if let common::Retry::After(d) =
30704                            dlg.http_failure(&response, error.as_ref().ok())
30705                        {
30706                            sleep(d).await;
30707                            continue;
30708                        }
30709
30710                        dlg.finished(false);
30711
30712                        return Err(match error {
30713                            Ok(value) => common::Error::BadRequest(value),
30714                            _ => common::Error::Failure(response),
30715                        });
30716                    }
30717                    let response = {
30718                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30719                        let encoded = common::to_string(&bytes);
30720                        match serde_json::from_str(&encoded) {
30721                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30722                            Err(error) => {
30723                                dlg.response_json_decode_error(&encoded, &error);
30724                                return Err(common::Error::JsonDecodeError(
30725                                    encoded.to_string(),
30726                                    error,
30727                                ));
30728                            }
30729                        }
30730                    };
30731
30732                    dlg.finished(true);
30733                    return Ok(response);
30734                }
30735            }
30736        }
30737    }
30738
30739    ///
30740    /// Sets the *request* property to the given value.
30741    ///
30742    /// Even though the property as already been set when instantiating this call,
30743    /// we provide this method for API completeness.
30744    pub fn request(
30745        mut self,
30746        new_value: GoogleIamV1TestIamPermissionsRequest,
30747    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C> {
30748        self._request = new_value;
30749        self
30750    }
30751    /// 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.
30752    ///
30753    /// Sets the *resource* path property to the given value.
30754    ///
30755    /// Even though the property as already been set when instantiating this call,
30756    /// we provide this method for API completeness.
30757    pub fn resource(
30758        mut self,
30759        new_value: &str,
30760    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C> {
30761        self._resource = new_value.to_string();
30762        self
30763    }
30764    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30765    /// while executing the actual API request.
30766    ///
30767    /// ````text
30768    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30769    /// ````
30770    ///
30771    /// Sets the *delegate* property to the given value.
30772    pub fn delegate(
30773        mut self,
30774        new_value: &'a mut dyn common::Delegate,
30775    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C> {
30776        self._delegate = Some(new_value);
30777        self
30778    }
30779
30780    /// Set any additional parameter of the query string used in the request.
30781    /// It should be used to set parameters which are not yet available through their own
30782    /// setters.
30783    ///
30784    /// Please note that this method must not be used to set any of the known parameters
30785    /// which have their own setter method. If done anyway, the request will fail.
30786    ///
30787    /// # Additional Parameters
30788    ///
30789    /// * *$.xgafv* (query-string) - V1 error format.
30790    /// * *access_token* (query-string) - OAuth access token.
30791    /// * *alt* (query-string) - Data format for response.
30792    /// * *callback* (query-string) - JSONP
30793    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30794    /// * *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.
30795    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30796    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30797    /// * *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.
30798    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30799    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30800    pub fn param<T>(
30801        mut self,
30802        name: T,
30803        value: T,
30804    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C>
30805    where
30806        T: AsRef<str>,
30807    {
30808        self._additional_params
30809            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30810        self
30811    }
30812
30813    /// Identifies the authorization scope for the method you are building.
30814    ///
30815    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30816    /// [`Scope::CloudPlatform`].
30817    ///
30818    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30819    /// tokens for more than one scope.
30820    ///
30821    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30822    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30823    /// sufficient, a read-write scope will do as well.
30824    pub fn add_scope<St>(
30825        mut self,
30826        scope: St,
30827    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C>
30828    where
30829        St: AsRef<str>,
30830    {
30831        self._scopes.insert(String::from(scope.as_ref()));
30832        self
30833    }
30834    /// Identifies the authorization scope(s) for the method you are building.
30835    ///
30836    /// See [`Self::add_scope()`] for details.
30837    pub fn add_scopes<I, St>(
30838        mut self,
30839        scopes: I,
30840    ) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C>
30841    where
30842        I: IntoIterator<Item = St>,
30843        St: AsRef<str>,
30844    {
30845        self._scopes
30846            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30847        self
30848    }
30849
30850    /// Removes all scopes, and no default scope will be used either.
30851    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30852    /// for details).
30853    pub fn clear_scopes(mut self) -> ProjectLocationServerTlsPolicyTestIamPermissionCall<'a, C> {
30854        self._scopes.clear();
30855        self
30856    }
30857}
30858
30859/// Creates a new TlsInspectionPolicy in a given project and location.
30860///
30861/// A builder for the *locations.tlsInspectionPolicies.create* method supported by a *project* resource.
30862/// It is not used directly, but through a [`ProjectMethods`] instance.
30863///
30864/// # Example
30865///
30866/// Instantiate a resource method builder
30867///
30868/// ```test_harness,no_run
30869/// # extern crate hyper;
30870/// # extern crate hyper_rustls;
30871/// # extern crate google_networksecurity1 as networksecurity1;
30872/// use networksecurity1::api::TlsInspectionPolicy;
30873/// # async fn dox() {
30874/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30875///
30876/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30877/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30878/// #     secret,
30879/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30880/// # ).build().await.unwrap();
30881///
30882/// # let client = hyper_util::client::legacy::Client::builder(
30883/// #     hyper_util::rt::TokioExecutor::new()
30884/// # )
30885/// # .build(
30886/// #     hyper_rustls::HttpsConnectorBuilder::new()
30887/// #         .with_native_roots()
30888/// #         .unwrap()
30889/// #         .https_or_http()
30890/// #         .enable_http1()
30891/// #         .build()
30892/// # );
30893/// # let mut hub = NetworkSecurity::new(client, auth);
30894/// // As the method needs a request, you would usually fill it with the desired information
30895/// // into the respective structure. Some of the parts shown here might not be applicable !
30896/// // Values shown here are possibly random and not representative !
30897/// let mut req = TlsInspectionPolicy::default();
30898///
30899/// // You can configure optional parameters by calling the respective setters at will, and
30900/// // execute the final call using `doit()`.
30901/// // Values shown here are possibly random and not representative !
30902/// let result = hub.projects().locations_tls_inspection_policies_create(req, "parent")
30903///              .tls_inspection_policy_id("Lorem")
30904///              .doit().await;
30905/// # }
30906/// ```
30907pub struct ProjectLocationTlsInspectionPolicyCreateCall<'a, C>
30908where
30909    C: 'a,
30910{
30911    hub: &'a NetworkSecurity<C>,
30912    _request: TlsInspectionPolicy,
30913    _parent: String,
30914    _tls_inspection_policy_id: Option<String>,
30915    _delegate: Option<&'a mut dyn common::Delegate>,
30916    _additional_params: HashMap<String, String>,
30917    _scopes: BTreeSet<String>,
30918}
30919
30920impl<'a, C> common::CallBuilder for ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {}
30921
30922impl<'a, C> ProjectLocationTlsInspectionPolicyCreateCall<'a, C>
30923where
30924    C: common::Connector,
30925{
30926    /// Perform the operation you have build so far.
30927    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
30928        use std::borrow::Cow;
30929        use std::io::{Read, Seek};
30930
30931        use common::{url::Params, ToParts};
30932        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30933
30934        let mut dd = common::DefaultDelegate;
30935        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30936        dlg.begin(common::MethodInfo {
30937            id: "networksecurity.projects.locations.tlsInspectionPolicies.create",
30938            http_method: hyper::Method::POST,
30939        });
30940
30941        for &field in ["alt", "parent", "tlsInspectionPolicyId"].iter() {
30942            if self._additional_params.contains_key(field) {
30943                dlg.finished(false);
30944                return Err(common::Error::FieldClash(field));
30945            }
30946        }
30947
30948        let mut params = Params::with_capacity(5 + self._additional_params.len());
30949        params.push("parent", self._parent);
30950        if let Some(value) = self._tls_inspection_policy_id.as_ref() {
30951            params.push("tlsInspectionPolicyId", value);
30952        }
30953
30954        params.extend(self._additional_params.iter());
30955
30956        params.push("alt", "json");
30957        let mut url = self.hub._base_url.clone() + "v1/{+parent}/tlsInspectionPolicies";
30958        if self._scopes.is_empty() {
30959            self._scopes
30960                .insert(Scope::CloudPlatform.as_ref().to_string());
30961        }
30962
30963        #[allow(clippy::single_element_loop)]
30964        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
30965            url = params.uri_replacement(url, param_name, find_this, true);
30966        }
30967        {
30968            let to_remove = ["parent"];
30969            params.remove_params(&to_remove);
30970        }
30971
30972        let url = params.parse_with_url(&url);
30973
30974        let mut json_mime_type = mime::APPLICATION_JSON;
30975        let mut request_value_reader = {
30976            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30977            common::remove_json_null_values(&mut value);
30978            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30979            serde_json::to_writer(&mut dst, &value).unwrap();
30980            dst
30981        };
30982        let request_size = request_value_reader
30983            .seek(std::io::SeekFrom::End(0))
30984            .unwrap();
30985        request_value_reader
30986            .seek(std::io::SeekFrom::Start(0))
30987            .unwrap();
30988
30989        loop {
30990            let token = match self
30991                .hub
30992                .auth
30993                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30994                .await
30995            {
30996                Ok(token) => token,
30997                Err(e) => match dlg.token(e) {
30998                    Ok(token) => token,
30999                    Err(e) => {
31000                        dlg.finished(false);
31001                        return Err(common::Error::MissingToken(e));
31002                    }
31003                },
31004            };
31005            request_value_reader
31006                .seek(std::io::SeekFrom::Start(0))
31007                .unwrap();
31008            let mut req_result = {
31009                let client = &self.hub.client;
31010                dlg.pre_request();
31011                let mut req_builder = hyper::Request::builder()
31012                    .method(hyper::Method::POST)
31013                    .uri(url.as_str())
31014                    .header(USER_AGENT, self.hub._user_agent.clone());
31015
31016                if let Some(token) = token.as_ref() {
31017                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31018                }
31019
31020                let request = req_builder
31021                    .header(CONTENT_TYPE, json_mime_type.to_string())
31022                    .header(CONTENT_LENGTH, request_size as u64)
31023                    .body(common::to_body(
31024                        request_value_reader.get_ref().clone().into(),
31025                    ));
31026
31027                client.request(request.unwrap()).await
31028            };
31029
31030            match req_result {
31031                Err(err) => {
31032                    if let common::Retry::After(d) = dlg.http_error(&err) {
31033                        sleep(d).await;
31034                        continue;
31035                    }
31036                    dlg.finished(false);
31037                    return Err(common::Error::HttpError(err));
31038                }
31039                Ok(res) => {
31040                    let (mut parts, body) = res.into_parts();
31041                    let mut body = common::Body::new(body);
31042                    if !parts.status.is_success() {
31043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31044                        let error = serde_json::from_str(&common::to_string(&bytes));
31045                        let response = common::to_response(parts, bytes.into());
31046
31047                        if let common::Retry::After(d) =
31048                            dlg.http_failure(&response, error.as_ref().ok())
31049                        {
31050                            sleep(d).await;
31051                            continue;
31052                        }
31053
31054                        dlg.finished(false);
31055
31056                        return Err(match error {
31057                            Ok(value) => common::Error::BadRequest(value),
31058                            _ => common::Error::Failure(response),
31059                        });
31060                    }
31061                    let response = {
31062                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31063                        let encoded = common::to_string(&bytes);
31064                        match serde_json::from_str(&encoded) {
31065                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31066                            Err(error) => {
31067                                dlg.response_json_decode_error(&encoded, &error);
31068                                return Err(common::Error::JsonDecodeError(
31069                                    encoded.to_string(),
31070                                    error,
31071                                ));
31072                            }
31073                        }
31074                    };
31075
31076                    dlg.finished(true);
31077                    return Ok(response);
31078                }
31079            }
31080        }
31081    }
31082
31083    ///
31084    /// Sets the *request* property to the given value.
31085    ///
31086    /// Even though the property as already been set when instantiating this call,
31087    /// we provide this method for API completeness.
31088    pub fn request(
31089        mut self,
31090        new_value: TlsInspectionPolicy,
31091    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {
31092        self._request = new_value;
31093        self
31094    }
31095    /// Required. The parent resource of the TlsInspectionPolicy. Must be in the format `projects/{project}/locations/{location}`.
31096    ///
31097    /// Sets the *parent* path property to the given value.
31098    ///
31099    /// Even though the property as already been set when instantiating this call,
31100    /// we provide this method for API completeness.
31101    pub fn parent(
31102        mut self,
31103        new_value: &str,
31104    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {
31105        self._parent = new_value.to_string();
31106        self
31107    }
31108    /// Required. Short name of the TlsInspectionPolicy resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "tls_inspection_policy1".
31109    ///
31110    /// Sets the *tls inspection policy id* query property to the given value.
31111    pub fn tls_inspection_policy_id(
31112        mut self,
31113        new_value: &str,
31114    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {
31115        self._tls_inspection_policy_id = Some(new_value.to_string());
31116        self
31117    }
31118    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31119    /// while executing the actual API request.
31120    ///
31121    /// ````text
31122    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31123    /// ````
31124    ///
31125    /// Sets the *delegate* property to the given value.
31126    pub fn delegate(
31127        mut self,
31128        new_value: &'a mut dyn common::Delegate,
31129    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {
31130        self._delegate = Some(new_value);
31131        self
31132    }
31133
31134    /// Set any additional parameter of the query string used in the request.
31135    /// It should be used to set parameters which are not yet available through their own
31136    /// setters.
31137    ///
31138    /// Please note that this method must not be used to set any of the known parameters
31139    /// which have their own setter method. If done anyway, the request will fail.
31140    ///
31141    /// # Additional Parameters
31142    ///
31143    /// * *$.xgafv* (query-string) - V1 error format.
31144    /// * *access_token* (query-string) - OAuth access token.
31145    /// * *alt* (query-string) - Data format for response.
31146    /// * *callback* (query-string) - JSONP
31147    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31148    /// * *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.
31149    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31150    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31151    /// * *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.
31152    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31153    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31154    pub fn param<T>(
31155        mut self,
31156        name: T,
31157        value: T,
31158    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C>
31159    where
31160        T: AsRef<str>,
31161    {
31162        self._additional_params
31163            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31164        self
31165    }
31166
31167    /// Identifies the authorization scope for the method you are building.
31168    ///
31169    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31170    /// [`Scope::CloudPlatform`].
31171    ///
31172    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31173    /// tokens for more than one scope.
31174    ///
31175    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31176    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31177    /// sufficient, a read-write scope will do as well.
31178    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C>
31179    where
31180        St: AsRef<str>,
31181    {
31182        self._scopes.insert(String::from(scope.as_ref()));
31183        self
31184    }
31185    /// Identifies the authorization scope(s) for the method you are building.
31186    ///
31187    /// See [`Self::add_scope()`] for details.
31188    pub fn add_scopes<I, St>(
31189        mut self,
31190        scopes: I,
31191    ) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C>
31192    where
31193        I: IntoIterator<Item = St>,
31194        St: AsRef<str>,
31195    {
31196        self._scopes
31197            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31198        self
31199    }
31200
31201    /// Removes all scopes, and no default scope will be used either.
31202    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31203    /// for details).
31204    pub fn clear_scopes(mut self) -> ProjectLocationTlsInspectionPolicyCreateCall<'a, C> {
31205        self._scopes.clear();
31206        self
31207    }
31208}
31209
31210/// Deletes a single TlsInspectionPolicy.
31211///
31212/// A builder for the *locations.tlsInspectionPolicies.delete* method supported by a *project* resource.
31213/// It is not used directly, but through a [`ProjectMethods`] instance.
31214///
31215/// # Example
31216///
31217/// Instantiate a resource method builder
31218///
31219/// ```test_harness,no_run
31220/// # extern crate hyper;
31221/// # extern crate hyper_rustls;
31222/// # extern crate google_networksecurity1 as networksecurity1;
31223/// # async fn dox() {
31224/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31225///
31226/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31227/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31228/// #     secret,
31229/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31230/// # ).build().await.unwrap();
31231///
31232/// # let client = hyper_util::client::legacy::Client::builder(
31233/// #     hyper_util::rt::TokioExecutor::new()
31234/// # )
31235/// # .build(
31236/// #     hyper_rustls::HttpsConnectorBuilder::new()
31237/// #         .with_native_roots()
31238/// #         .unwrap()
31239/// #         .https_or_http()
31240/// #         .enable_http1()
31241/// #         .build()
31242/// # );
31243/// # let mut hub = NetworkSecurity::new(client, auth);
31244/// // You can configure optional parameters by calling the respective setters at will, and
31245/// // execute the final call using `doit()`.
31246/// // Values shown here are possibly random and not representative !
31247/// let result = hub.projects().locations_tls_inspection_policies_delete("name")
31248///              .force(true)
31249///              .doit().await;
31250/// # }
31251/// ```
31252pub struct ProjectLocationTlsInspectionPolicyDeleteCall<'a, C>
31253where
31254    C: 'a,
31255{
31256    hub: &'a NetworkSecurity<C>,
31257    _name: String,
31258    _force: Option<bool>,
31259    _delegate: Option<&'a mut dyn common::Delegate>,
31260    _additional_params: HashMap<String, String>,
31261    _scopes: BTreeSet<String>,
31262}
31263
31264impl<'a, C> common::CallBuilder for ProjectLocationTlsInspectionPolicyDeleteCall<'a, C> {}
31265
31266impl<'a, C> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C>
31267where
31268    C: common::Connector,
31269{
31270    /// Perform the operation you have build so far.
31271    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
31272        use std::borrow::Cow;
31273        use std::io::{Read, Seek};
31274
31275        use common::{url::Params, ToParts};
31276        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31277
31278        let mut dd = common::DefaultDelegate;
31279        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31280        dlg.begin(common::MethodInfo {
31281            id: "networksecurity.projects.locations.tlsInspectionPolicies.delete",
31282            http_method: hyper::Method::DELETE,
31283        });
31284
31285        for &field in ["alt", "name", "force"].iter() {
31286            if self._additional_params.contains_key(field) {
31287                dlg.finished(false);
31288                return Err(common::Error::FieldClash(field));
31289            }
31290        }
31291
31292        let mut params = Params::with_capacity(4 + self._additional_params.len());
31293        params.push("name", self._name);
31294        if let Some(value) = self._force.as_ref() {
31295            params.push("force", value.to_string());
31296        }
31297
31298        params.extend(self._additional_params.iter());
31299
31300        params.push("alt", "json");
31301        let mut url = self.hub._base_url.clone() + "v1/{+name}";
31302        if self._scopes.is_empty() {
31303            self._scopes
31304                .insert(Scope::CloudPlatform.as_ref().to_string());
31305        }
31306
31307        #[allow(clippy::single_element_loop)]
31308        for &(find_this, param_name) in [("{+name}", "name")].iter() {
31309            url = params.uri_replacement(url, param_name, find_this, true);
31310        }
31311        {
31312            let to_remove = ["name"];
31313            params.remove_params(&to_remove);
31314        }
31315
31316        let url = params.parse_with_url(&url);
31317
31318        loop {
31319            let token = match self
31320                .hub
31321                .auth
31322                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31323                .await
31324            {
31325                Ok(token) => token,
31326                Err(e) => match dlg.token(e) {
31327                    Ok(token) => token,
31328                    Err(e) => {
31329                        dlg.finished(false);
31330                        return Err(common::Error::MissingToken(e));
31331                    }
31332                },
31333            };
31334            let mut req_result = {
31335                let client = &self.hub.client;
31336                dlg.pre_request();
31337                let mut req_builder = hyper::Request::builder()
31338                    .method(hyper::Method::DELETE)
31339                    .uri(url.as_str())
31340                    .header(USER_AGENT, self.hub._user_agent.clone());
31341
31342                if let Some(token) = token.as_ref() {
31343                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31344                }
31345
31346                let request = req_builder
31347                    .header(CONTENT_LENGTH, 0_u64)
31348                    .body(common::to_body::<String>(None));
31349
31350                client.request(request.unwrap()).await
31351            };
31352
31353            match req_result {
31354                Err(err) => {
31355                    if let common::Retry::After(d) = dlg.http_error(&err) {
31356                        sleep(d).await;
31357                        continue;
31358                    }
31359                    dlg.finished(false);
31360                    return Err(common::Error::HttpError(err));
31361                }
31362                Ok(res) => {
31363                    let (mut parts, body) = res.into_parts();
31364                    let mut body = common::Body::new(body);
31365                    if !parts.status.is_success() {
31366                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31367                        let error = serde_json::from_str(&common::to_string(&bytes));
31368                        let response = common::to_response(parts, bytes.into());
31369
31370                        if let common::Retry::After(d) =
31371                            dlg.http_failure(&response, error.as_ref().ok())
31372                        {
31373                            sleep(d).await;
31374                            continue;
31375                        }
31376
31377                        dlg.finished(false);
31378
31379                        return Err(match error {
31380                            Ok(value) => common::Error::BadRequest(value),
31381                            _ => common::Error::Failure(response),
31382                        });
31383                    }
31384                    let response = {
31385                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31386                        let encoded = common::to_string(&bytes);
31387                        match serde_json::from_str(&encoded) {
31388                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31389                            Err(error) => {
31390                                dlg.response_json_decode_error(&encoded, &error);
31391                                return Err(common::Error::JsonDecodeError(
31392                                    encoded.to_string(),
31393                                    error,
31394                                ));
31395                            }
31396                        }
31397                    };
31398
31399                    dlg.finished(true);
31400                    return Ok(response);
31401                }
31402            }
31403        }
31404    }
31405
31406    /// Required. A name of the TlsInspectionPolicy to delete. Must be in the format `projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy}`.
31407    ///
31408    /// Sets the *name* path property to the given value.
31409    ///
31410    /// Even though the property as already been set when instantiating this call,
31411    /// we provide this method for API completeness.
31412    pub fn name(mut self, new_value: &str) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C> {
31413        self._name = new_value.to_string();
31414        self
31415    }
31416    /// If set to true, any rules for this TlsInspectionPolicy will also be deleted. (Otherwise, the request will only work if the TlsInspectionPolicy has no rules.)
31417    ///
31418    /// Sets the *force* query property to the given value.
31419    pub fn force(mut self, new_value: bool) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C> {
31420        self._force = Some(new_value);
31421        self
31422    }
31423    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31424    /// while executing the actual API request.
31425    ///
31426    /// ````text
31427    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31428    /// ````
31429    ///
31430    /// Sets the *delegate* property to the given value.
31431    pub fn delegate(
31432        mut self,
31433        new_value: &'a mut dyn common::Delegate,
31434    ) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C> {
31435        self._delegate = Some(new_value);
31436        self
31437    }
31438
31439    /// Set any additional parameter of the query string used in the request.
31440    /// It should be used to set parameters which are not yet available through their own
31441    /// setters.
31442    ///
31443    /// Please note that this method must not be used to set any of the known parameters
31444    /// which have their own setter method. If done anyway, the request will fail.
31445    ///
31446    /// # Additional Parameters
31447    ///
31448    /// * *$.xgafv* (query-string) - V1 error format.
31449    /// * *access_token* (query-string) - OAuth access token.
31450    /// * *alt* (query-string) - Data format for response.
31451    /// * *callback* (query-string) - JSONP
31452    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31453    /// * *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.
31454    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31455    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31456    /// * *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.
31457    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31458    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31459    pub fn param<T>(
31460        mut self,
31461        name: T,
31462        value: T,
31463    ) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C>
31464    where
31465        T: AsRef<str>,
31466    {
31467        self._additional_params
31468            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31469        self
31470    }
31471
31472    /// Identifies the authorization scope for the method you are building.
31473    ///
31474    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31475    /// [`Scope::CloudPlatform`].
31476    ///
31477    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31478    /// tokens for more than one scope.
31479    ///
31480    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31481    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31482    /// sufficient, a read-write scope will do as well.
31483    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C>
31484    where
31485        St: AsRef<str>,
31486    {
31487        self._scopes.insert(String::from(scope.as_ref()));
31488        self
31489    }
31490    /// Identifies the authorization scope(s) for the method you are building.
31491    ///
31492    /// See [`Self::add_scope()`] for details.
31493    pub fn add_scopes<I, St>(
31494        mut self,
31495        scopes: I,
31496    ) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C>
31497    where
31498        I: IntoIterator<Item = St>,
31499        St: AsRef<str>,
31500    {
31501        self._scopes
31502            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31503        self
31504    }
31505
31506    /// Removes all scopes, and no default scope will be used either.
31507    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31508    /// for details).
31509    pub fn clear_scopes(mut self) -> ProjectLocationTlsInspectionPolicyDeleteCall<'a, C> {
31510        self._scopes.clear();
31511        self
31512    }
31513}
31514
31515/// Gets details of a single TlsInspectionPolicy.
31516///
31517/// A builder for the *locations.tlsInspectionPolicies.get* method supported by a *project* resource.
31518/// It is not used directly, but through a [`ProjectMethods`] instance.
31519///
31520/// # Example
31521///
31522/// Instantiate a resource method builder
31523///
31524/// ```test_harness,no_run
31525/// # extern crate hyper;
31526/// # extern crate hyper_rustls;
31527/// # extern crate google_networksecurity1 as networksecurity1;
31528/// # async fn dox() {
31529/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31530///
31531/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31532/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31533/// #     secret,
31534/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31535/// # ).build().await.unwrap();
31536///
31537/// # let client = hyper_util::client::legacy::Client::builder(
31538/// #     hyper_util::rt::TokioExecutor::new()
31539/// # )
31540/// # .build(
31541/// #     hyper_rustls::HttpsConnectorBuilder::new()
31542/// #         .with_native_roots()
31543/// #         .unwrap()
31544/// #         .https_or_http()
31545/// #         .enable_http1()
31546/// #         .build()
31547/// # );
31548/// # let mut hub = NetworkSecurity::new(client, auth);
31549/// // You can configure optional parameters by calling the respective setters at will, and
31550/// // execute the final call using `doit()`.
31551/// // Values shown here are possibly random and not representative !
31552/// let result = hub.projects().locations_tls_inspection_policies_get("name")
31553///              .doit().await;
31554/// # }
31555/// ```
31556pub struct ProjectLocationTlsInspectionPolicyGetCall<'a, C>
31557where
31558    C: 'a,
31559{
31560    hub: &'a NetworkSecurity<C>,
31561    _name: String,
31562    _delegate: Option<&'a mut dyn common::Delegate>,
31563    _additional_params: HashMap<String, String>,
31564    _scopes: BTreeSet<String>,
31565}
31566
31567impl<'a, C> common::CallBuilder for ProjectLocationTlsInspectionPolicyGetCall<'a, C> {}
31568
31569impl<'a, C> ProjectLocationTlsInspectionPolicyGetCall<'a, C>
31570where
31571    C: common::Connector,
31572{
31573    /// Perform the operation you have build so far.
31574    pub async fn doit(mut self) -> common::Result<(common::Response, TlsInspectionPolicy)> {
31575        use std::borrow::Cow;
31576        use std::io::{Read, Seek};
31577
31578        use common::{url::Params, ToParts};
31579        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31580
31581        let mut dd = common::DefaultDelegate;
31582        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31583        dlg.begin(common::MethodInfo {
31584            id: "networksecurity.projects.locations.tlsInspectionPolicies.get",
31585            http_method: hyper::Method::GET,
31586        });
31587
31588        for &field in ["alt", "name"].iter() {
31589            if self._additional_params.contains_key(field) {
31590                dlg.finished(false);
31591                return Err(common::Error::FieldClash(field));
31592            }
31593        }
31594
31595        let mut params = Params::with_capacity(3 + self._additional_params.len());
31596        params.push("name", self._name);
31597
31598        params.extend(self._additional_params.iter());
31599
31600        params.push("alt", "json");
31601        let mut url = self.hub._base_url.clone() + "v1/{+name}";
31602        if self._scopes.is_empty() {
31603            self._scopes
31604                .insert(Scope::CloudPlatform.as_ref().to_string());
31605        }
31606
31607        #[allow(clippy::single_element_loop)]
31608        for &(find_this, param_name) in [("{+name}", "name")].iter() {
31609            url = params.uri_replacement(url, param_name, find_this, true);
31610        }
31611        {
31612            let to_remove = ["name"];
31613            params.remove_params(&to_remove);
31614        }
31615
31616        let url = params.parse_with_url(&url);
31617
31618        loop {
31619            let token = match self
31620                .hub
31621                .auth
31622                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31623                .await
31624            {
31625                Ok(token) => token,
31626                Err(e) => match dlg.token(e) {
31627                    Ok(token) => token,
31628                    Err(e) => {
31629                        dlg.finished(false);
31630                        return Err(common::Error::MissingToken(e));
31631                    }
31632                },
31633            };
31634            let mut req_result = {
31635                let client = &self.hub.client;
31636                dlg.pre_request();
31637                let mut req_builder = hyper::Request::builder()
31638                    .method(hyper::Method::GET)
31639                    .uri(url.as_str())
31640                    .header(USER_AGENT, self.hub._user_agent.clone());
31641
31642                if let Some(token) = token.as_ref() {
31643                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31644                }
31645
31646                let request = req_builder
31647                    .header(CONTENT_LENGTH, 0_u64)
31648                    .body(common::to_body::<String>(None));
31649
31650                client.request(request.unwrap()).await
31651            };
31652
31653            match req_result {
31654                Err(err) => {
31655                    if let common::Retry::After(d) = dlg.http_error(&err) {
31656                        sleep(d).await;
31657                        continue;
31658                    }
31659                    dlg.finished(false);
31660                    return Err(common::Error::HttpError(err));
31661                }
31662                Ok(res) => {
31663                    let (mut parts, body) = res.into_parts();
31664                    let mut body = common::Body::new(body);
31665                    if !parts.status.is_success() {
31666                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31667                        let error = serde_json::from_str(&common::to_string(&bytes));
31668                        let response = common::to_response(parts, bytes.into());
31669
31670                        if let common::Retry::After(d) =
31671                            dlg.http_failure(&response, error.as_ref().ok())
31672                        {
31673                            sleep(d).await;
31674                            continue;
31675                        }
31676
31677                        dlg.finished(false);
31678
31679                        return Err(match error {
31680                            Ok(value) => common::Error::BadRequest(value),
31681                            _ => common::Error::Failure(response),
31682                        });
31683                    }
31684                    let response = {
31685                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31686                        let encoded = common::to_string(&bytes);
31687                        match serde_json::from_str(&encoded) {
31688                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31689                            Err(error) => {
31690                                dlg.response_json_decode_error(&encoded, &error);
31691                                return Err(common::Error::JsonDecodeError(
31692                                    encoded.to_string(),
31693                                    error,
31694                                ));
31695                            }
31696                        }
31697                    };
31698
31699                    dlg.finished(true);
31700                    return Ok(response);
31701                }
31702            }
31703        }
31704    }
31705
31706    /// Required. A name of the TlsInspectionPolicy to get. Must be in the format `projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy}`.
31707    ///
31708    /// Sets the *name* path property to the given value.
31709    ///
31710    /// Even though the property as already been set when instantiating this call,
31711    /// we provide this method for API completeness.
31712    pub fn name(mut self, new_value: &str) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C> {
31713        self._name = new_value.to_string();
31714        self
31715    }
31716    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31717    /// while executing the actual API request.
31718    ///
31719    /// ````text
31720    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31721    /// ````
31722    ///
31723    /// Sets the *delegate* property to the given value.
31724    pub fn delegate(
31725        mut self,
31726        new_value: &'a mut dyn common::Delegate,
31727    ) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C> {
31728        self._delegate = Some(new_value);
31729        self
31730    }
31731
31732    /// Set any additional parameter of the query string used in the request.
31733    /// It should be used to set parameters which are not yet available through their own
31734    /// setters.
31735    ///
31736    /// Please note that this method must not be used to set any of the known parameters
31737    /// which have their own setter method. If done anyway, the request will fail.
31738    ///
31739    /// # Additional Parameters
31740    ///
31741    /// * *$.xgafv* (query-string) - V1 error format.
31742    /// * *access_token* (query-string) - OAuth access token.
31743    /// * *alt* (query-string) - Data format for response.
31744    /// * *callback* (query-string) - JSONP
31745    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31746    /// * *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.
31747    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31748    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31749    /// * *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.
31750    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31751    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31752    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C>
31753    where
31754        T: AsRef<str>,
31755    {
31756        self._additional_params
31757            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31758        self
31759    }
31760
31761    /// Identifies the authorization scope for the method you are building.
31762    ///
31763    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31764    /// [`Scope::CloudPlatform`].
31765    ///
31766    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31767    /// tokens for more than one scope.
31768    ///
31769    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31770    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31771    /// sufficient, a read-write scope will do as well.
31772    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C>
31773    where
31774        St: AsRef<str>,
31775    {
31776        self._scopes.insert(String::from(scope.as_ref()));
31777        self
31778    }
31779    /// Identifies the authorization scope(s) for the method you are building.
31780    ///
31781    /// See [`Self::add_scope()`] for details.
31782    pub fn add_scopes<I, St>(
31783        mut self,
31784        scopes: I,
31785    ) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C>
31786    where
31787        I: IntoIterator<Item = St>,
31788        St: AsRef<str>,
31789    {
31790        self._scopes
31791            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31792        self
31793    }
31794
31795    /// Removes all scopes, and no default scope will be used either.
31796    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31797    /// for details).
31798    pub fn clear_scopes(mut self) -> ProjectLocationTlsInspectionPolicyGetCall<'a, C> {
31799        self._scopes.clear();
31800        self
31801    }
31802}
31803
31804/// Lists TlsInspectionPolicies in a given project and location.
31805///
31806/// A builder for the *locations.tlsInspectionPolicies.list* method supported by a *project* resource.
31807/// It is not used directly, but through a [`ProjectMethods`] instance.
31808///
31809/// # Example
31810///
31811/// Instantiate a resource method builder
31812///
31813/// ```test_harness,no_run
31814/// # extern crate hyper;
31815/// # extern crate hyper_rustls;
31816/// # extern crate google_networksecurity1 as networksecurity1;
31817/// # async fn dox() {
31818/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31819///
31820/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31822/// #     secret,
31823/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31824/// # ).build().await.unwrap();
31825///
31826/// # let client = hyper_util::client::legacy::Client::builder(
31827/// #     hyper_util::rt::TokioExecutor::new()
31828/// # )
31829/// # .build(
31830/// #     hyper_rustls::HttpsConnectorBuilder::new()
31831/// #         .with_native_roots()
31832/// #         .unwrap()
31833/// #         .https_or_http()
31834/// #         .enable_http1()
31835/// #         .build()
31836/// # );
31837/// # let mut hub = NetworkSecurity::new(client, auth);
31838/// // You can configure optional parameters by calling the respective setters at will, and
31839/// // execute the final call using `doit()`.
31840/// // Values shown here are possibly random and not representative !
31841/// let result = hub.projects().locations_tls_inspection_policies_list("parent")
31842///              .page_token("erat")
31843///              .page_size(-73)
31844///              .doit().await;
31845/// # }
31846/// ```
31847pub struct ProjectLocationTlsInspectionPolicyListCall<'a, C>
31848where
31849    C: 'a,
31850{
31851    hub: &'a NetworkSecurity<C>,
31852    _parent: String,
31853    _page_token: Option<String>,
31854    _page_size: Option<i32>,
31855    _delegate: Option<&'a mut dyn common::Delegate>,
31856    _additional_params: HashMap<String, String>,
31857    _scopes: BTreeSet<String>,
31858}
31859
31860impl<'a, C> common::CallBuilder for ProjectLocationTlsInspectionPolicyListCall<'a, C> {}
31861
31862impl<'a, C> ProjectLocationTlsInspectionPolicyListCall<'a, C>
31863where
31864    C: common::Connector,
31865{
31866    /// Perform the operation you have build so far.
31867    pub async fn doit(
31868        mut self,
31869    ) -> common::Result<(common::Response, ListTlsInspectionPoliciesResponse)> {
31870        use std::borrow::Cow;
31871        use std::io::{Read, Seek};
31872
31873        use common::{url::Params, ToParts};
31874        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31875
31876        let mut dd = common::DefaultDelegate;
31877        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31878        dlg.begin(common::MethodInfo {
31879            id: "networksecurity.projects.locations.tlsInspectionPolicies.list",
31880            http_method: hyper::Method::GET,
31881        });
31882
31883        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
31884            if self._additional_params.contains_key(field) {
31885                dlg.finished(false);
31886                return Err(common::Error::FieldClash(field));
31887            }
31888        }
31889
31890        let mut params = Params::with_capacity(5 + self._additional_params.len());
31891        params.push("parent", self._parent);
31892        if let Some(value) = self._page_token.as_ref() {
31893            params.push("pageToken", value);
31894        }
31895        if let Some(value) = self._page_size.as_ref() {
31896            params.push("pageSize", value.to_string());
31897        }
31898
31899        params.extend(self._additional_params.iter());
31900
31901        params.push("alt", "json");
31902        let mut url = self.hub._base_url.clone() + "v1/{+parent}/tlsInspectionPolicies";
31903        if self._scopes.is_empty() {
31904            self._scopes
31905                .insert(Scope::CloudPlatform.as_ref().to_string());
31906        }
31907
31908        #[allow(clippy::single_element_loop)]
31909        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
31910            url = params.uri_replacement(url, param_name, find_this, true);
31911        }
31912        {
31913            let to_remove = ["parent"];
31914            params.remove_params(&to_remove);
31915        }
31916
31917        let url = params.parse_with_url(&url);
31918
31919        loop {
31920            let token = match self
31921                .hub
31922                .auth
31923                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31924                .await
31925            {
31926                Ok(token) => token,
31927                Err(e) => match dlg.token(e) {
31928                    Ok(token) => token,
31929                    Err(e) => {
31930                        dlg.finished(false);
31931                        return Err(common::Error::MissingToken(e));
31932                    }
31933                },
31934            };
31935            let mut req_result = {
31936                let client = &self.hub.client;
31937                dlg.pre_request();
31938                let mut req_builder = hyper::Request::builder()
31939                    .method(hyper::Method::GET)
31940                    .uri(url.as_str())
31941                    .header(USER_AGENT, self.hub._user_agent.clone());
31942
31943                if let Some(token) = token.as_ref() {
31944                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31945                }
31946
31947                let request = req_builder
31948                    .header(CONTENT_LENGTH, 0_u64)
31949                    .body(common::to_body::<String>(None));
31950
31951                client.request(request.unwrap()).await
31952            };
31953
31954            match req_result {
31955                Err(err) => {
31956                    if let common::Retry::After(d) = dlg.http_error(&err) {
31957                        sleep(d).await;
31958                        continue;
31959                    }
31960                    dlg.finished(false);
31961                    return Err(common::Error::HttpError(err));
31962                }
31963                Ok(res) => {
31964                    let (mut parts, body) = res.into_parts();
31965                    let mut body = common::Body::new(body);
31966                    if !parts.status.is_success() {
31967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31968                        let error = serde_json::from_str(&common::to_string(&bytes));
31969                        let response = common::to_response(parts, bytes.into());
31970
31971                        if let common::Retry::After(d) =
31972                            dlg.http_failure(&response, error.as_ref().ok())
31973                        {
31974                            sleep(d).await;
31975                            continue;
31976                        }
31977
31978                        dlg.finished(false);
31979
31980                        return Err(match error {
31981                            Ok(value) => common::Error::BadRequest(value),
31982                            _ => common::Error::Failure(response),
31983                        });
31984                    }
31985                    let response = {
31986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31987                        let encoded = common::to_string(&bytes);
31988                        match serde_json::from_str(&encoded) {
31989                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31990                            Err(error) => {
31991                                dlg.response_json_decode_error(&encoded, &error);
31992                                return Err(common::Error::JsonDecodeError(
31993                                    encoded.to_string(),
31994                                    error,
31995                                ));
31996                            }
31997                        }
31998                    };
31999
32000                    dlg.finished(true);
32001                    return Ok(response);
32002                }
32003            }
32004        }
32005    }
32006
32007    /// Required. The project and location from which the TlsInspectionPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
32008    ///
32009    /// Sets the *parent* path property to the given value.
32010    ///
32011    /// Even though the property as already been set when instantiating this call,
32012    /// we provide this method for API completeness.
32013    pub fn parent(mut self, new_value: &str) -> ProjectLocationTlsInspectionPolicyListCall<'a, C> {
32014        self._parent = new_value.to_string();
32015        self
32016    }
32017    /// The value returned by the last 'ListTlsInspectionPoliciesResponse' Indicates that this is a continuation of a prior 'ListTlsInspectionPolicies' call, and that the system should return the next page of data.
32018    ///
32019    /// Sets the *page token* query property to the given value.
32020    pub fn page_token(
32021        mut self,
32022        new_value: &str,
32023    ) -> ProjectLocationTlsInspectionPolicyListCall<'a, C> {
32024        self._page_token = Some(new_value.to_string());
32025        self
32026    }
32027    /// Maximum number of TlsInspectionPolicies to return per call.
32028    ///
32029    /// Sets the *page size* query property to the given value.
32030    pub fn page_size(
32031        mut self,
32032        new_value: i32,
32033    ) -> ProjectLocationTlsInspectionPolicyListCall<'a, C> {
32034        self._page_size = Some(new_value);
32035        self
32036    }
32037    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32038    /// while executing the actual API request.
32039    ///
32040    /// ````text
32041    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32042    /// ````
32043    ///
32044    /// Sets the *delegate* property to the given value.
32045    pub fn delegate(
32046        mut self,
32047        new_value: &'a mut dyn common::Delegate,
32048    ) -> ProjectLocationTlsInspectionPolicyListCall<'a, C> {
32049        self._delegate = Some(new_value);
32050        self
32051    }
32052
32053    /// Set any additional parameter of the query string used in the request.
32054    /// It should be used to set parameters which are not yet available through their own
32055    /// setters.
32056    ///
32057    /// Please note that this method must not be used to set any of the known parameters
32058    /// which have their own setter method. If done anyway, the request will fail.
32059    ///
32060    /// # Additional Parameters
32061    ///
32062    /// * *$.xgafv* (query-string) - V1 error format.
32063    /// * *access_token* (query-string) - OAuth access token.
32064    /// * *alt* (query-string) - Data format for response.
32065    /// * *callback* (query-string) - JSONP
32066    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32067    /// * *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.
32068    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32069    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32070    /// * *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.
32071    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32072    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32073    pub fn param<T>(
32074        mut self,
32075        name: T,
32076        value: T,
32077    ) -> ProjectLocationTlsInspectionPolicyListCall<'a, C>
32078    where
32079        T: AsRef<str>,
32080    {
32081        self._additional_params
32082            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32083        self
32084    }
32085
32086    /// Identifies the authorization scope for the method you are building.
32087    ///
32088    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32089    /// [`Scope::CloudPlatform`].
32090    ///
32091    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32092    /// tokens for more than one scope.
32093    ///
32094    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32095    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32096    /// sufficient, a read-write scope will do as well.
32097    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsInspectionPolicyListCall<'a, C>
32098    where
32099        St: AsRef<str>,
32100    {
32101        self._scopes.insert(String::from(scope.as_ref()));
32102        self
32103    }
32104    /// Identifies the authorization scope(s) for the method you are building.
32105    ///
32106    /// See [`Self::add_scope()`] for details.
32107    pub fn add_scopes<I, St>(
32108        mut self,
32109        scopes: I,
32110    ) -> ProjectLocationTlsInspectionPolicyListCall<'a, C>
32111    where
32112        I: IntoIterator<Item = St>,
32113        St: AsRef<str>,
32114    {
32115        self._scopes
32116            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32117        self
32118    }
32119
32120    /// Removes all scopes, and no default scope will be used either.
32121    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32122    /// for details).
32123    pub fn clear_scopes(mut self) -> ProjectLocationTlsInspectionPolicyListCall<'a, C> {
32124        self._scopes.clear();
32125        self
32126    }
32127}
32128
32129/// Updates the parameters of a single TlsInspectionPolicy.
32130///
32131/// A builder for the *locations.tlsInspectionPolicies.patch* method supported by a *project* resource.
32132/// It is not used directly, but through a [`ProjectMethods`] instance.
32133///
32134/// # Example
32135///
32136/// Instantiate a resource method builder
32137///
32138/// ```test_harness,no_run
32139/// # extern crate hyper;
32140/// # extern crate hyper_rustls;
32141/// # extern crate google_networksecurity1 as networksecurity1;
32142/// use networksecurity1::api::TlsInspectionPolicy;
32143/// # async fn dox() {
32144/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32145///
32146/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32147/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32148/// #     secret,
32149/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32150/// # ).build().await.unwrap();
32151///
32152/// # let client = hyper_util::client::legacy::Client::builder(
32153/// #     hyper_util::rt::TokioExecutor::new()
32154/// # )
32155/// # .build(
32156/// #     hyper_rustls::HttpsConnectorBuilder::new()
32157/// #         .with_native_roots()
32158/// #         .unwrap()
32159/// #         .https_or_http()
32160/// #         .enable_http1()
32161/// #         .build()
32162/// # );
32163/// # let mut hub = NetworkSecurity::new(client, auth);
32164/// // As the method needs a request, you would usually fill it with the desired information
32165/// // into the respective structure. Some of the parts shown here might not be applicable !
32166/// // Values shown here are possibly random and not representative !
32167/// let mut req = TlsInspectionPolicy::default();
32168///
32169/// // You can configure optional parameters by calling the respective setters at will, and
32170/// // execute the final call using `doit()`.
32171/// // Values shown here are possibly random and not representative !
32172/// let result = hub.projects().locations_tls_inspection_policies_patch(req, "name")
32173///              .update_mask(FieldMask::new::<&str>(&[]))
32174///              .doit().await;
32175/// # }
32176/// ```
32177pub struct ProjectLocationTlsInspectionPolicyPatchCall<'a, C>
32178where
32179    C: 'a,
32180{
32181    hub: &'a NetworkSecurity<C>,
32182    _request: TlsInspectionPolicy,
32183    _name: String,
32184    _update_mask: Option<common::FieldMask>,
32185    _delegate: Option<&'a mut dyn common::Delegate>,
32186    _additional_params: HashMap<String, String>,
32187    _scopes: BTreeSet<String>,
32188}
32189
32190impl<'a, C> common::CallBuilder for ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {}
32191
32192impl<'a, C> ProjectLocationTlsInspectionPolicyPatchCall<'a, C>
32193where
32194    C: common::Connector,
32195{
32196    /// Perform the operation you have build so far.
32197    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
32198        use std::borrow::Cow;
32199        use std::io::{Read, Seek};
32200
32201        use common::{url::Params, ToParts};
32202        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32203
32204        let mut dd = common::DefaultDelegate;
32205        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32206        dlg.begin(common::MethodInfo {
32207            id: "networksecurity.projects.locations.tlsInspectionPolicies.patch",
32208            http_method: hyper::Method::PATCH,
32209        });
32210
32211        for &field in ["alt", "name", "updateMask"].iter() {
32212            if self._additional_params.contains_key(field) {
32213                dlg.finished(false);
32214                return Err(common::Error::FieldClash(field));
32215            }
32216        }
32217
32218        let mut params = Params::with_capacity(5 + self._additional_params.len());
32219        params.push("name", self._name);
32220        if let Some(value) = self._update_mask.as_ref() {
32221            params.push("updateMask", value.to_string());
32222        }
32223
32224        params.extend(self._additional_params.iter());
32225
32226        params.push("alt", "json");
32227        let mut url = self.hub._base_url.clone() + "v1/{+name}";
32228        if self._scopes.is_empty() {
32229            self._scopes
32230                .insert(Scope::CloudPlatform.as_ref().to_string());
32231        }
32232
32233        #[allow(clippy::single_element_loop)]
32234        for &(find_this, param_name) in [("{+name}", "name")].iter() {
32235            url = params.uri_replacement(url, param_name, find_this, true);
32236        }
32237        {
32238            let to_remove = ["name"];
32239            params.remove_params(&to_remove);
32240        }
32241
32242        let url = params.parse_with_url(&url);
32243
32244        let mut json_mime_type = mime::APPLICATION_JSON;
32245        let mut request_value_reader = {
32246            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32247            common::remove_json_null_values(&mut value);
32248            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32249            serde_json::to_writer(&mut dst, &value).unwrap();
32250            dst
32251        };
32252        let request_size = request_value_reader
32253            .seek(std::io::SeekFrom::End(0))
32254            .unwrap();
32255        request_value_reader
32256            .seek(std::io::SeekFrom::Start(0))
32257            .unwrap();
32258
32259        loop {
32260            let token = match self
32261                .hub
32262                .auth
32263                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32264                .await
32265            {
32266                Ok(token) => token,
32267                Err(e) => match dlg.token(e) {
32268                    Ok(token) => token,
32269                    Err(e) => {
32270                        dlg.finished(false);
32271                        return Err(common::Error::MissingToken(e));
32272                    }
32273                },
32274            };
32275            request_value_reader
32276                .seek(std::io::SeekFrom::Start(0))
32277                .unwrap();
32278            let mut req_result = {
32279                let client = &self.hub.client;
32280                dlg.pre_request();
32281                let mut req_builder = hyper::Request::builder()
32282                    .method(hyper::Method::PATCH)
32283                    .uri(url.as_str())
32284                    .header(USER_AGENT, self.hub._user_agent.clone());
32285
32286                if let Some(token) = token.as_ref() {
32287                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32288                }
32289
32290                let request = req_builder
32291                    .header(CONTENT_TYPE, json_mime_type.to_string())
32292                    .header(CONTENT_LENGTH, request_size as u64)
32293                    .body(common::to_body(
32294                        request_value_reader.get_ref().clone().into(),
32295                    ));
32296
32297                client.request(request.unwrap()).await
32298            };
32299
32300            match req_result {
32301                Err(err) => {
32302                    if let common::Retry::After(d) = dlg.http_error(&err) {
32303                        sleep(d).await;
32304                        continue;
32305                    }
32306                    dlg.finished(false);
32307                    return Err(common::Error::HttpError(err));
32308                }
32309                Ok(res) => {
32310                    let (mut parts, body) = res.into_parts();
32311                    let mut body = common::Body::new(body);
32312                    if !parts.status.is_success() {
32313                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32314                        let error = serde_json::from_str(&common::to_string(&bytes));
32315                        let response = common::to_response(parts, bytes.into());
32316
32317                        if let common::Retry::After(d) =
32318                            dlg.http_failure(&response, error.as_ref().ok())
32319                        {
32320                            sleep(d).await;
32321                            continue;
32322                        }
32323
32324                        dlg.finished(false);
32325
32326                        return Err(match error {
32327                            Ok(value) => common::Error::BadRequest(value),
32328                            _ => common::Error::Failure(response),
32329                        });
32330                    }
32331                    let response = {
32332                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32333                        let encoded = common::to_string(&bytes);
32334                        match serde_json::from_str(&encoded) {
32335                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32336                            Err(error) => {
32337                                dlg.response_json_decode_error(&encoded, &error);
32338                                return Err(common::Error::JsonDecodeError(
32339                                    encoded.to_string(),
32340                                    error,
32341                                ));
32342                            }
32343                        }
32344                    };
32345
32346                    dlg.finished(true);
32347                    return Ok(response);
32348                }
32349            }
32350        }
32351    }
32352
32353    ///
32354    /// Sets the *request* property to the given value.
32355    ///
32356    /// Even though the property as already been set when instantiating this call,
32357    /// we provide this method for API completeness.
32358    pub fn request(
32359        mut self,
32360        new_value: TlsInspectionPolicy,
32361    ) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {
32362        self._request = new_value;
32363        self
32364    }
32365    /// Required. Name of the resource. Name is of the form projects/{project}/locations/{location}/tlsInspectionPolicies/{tls_inspection_policy} tls_inspection_policy should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
32366    ///
32367    /// Sets the *name* path property to the given value.
32368    ///
32369    /// Even though the property as already been set when instantiating this call,
32370    /// we provide this method for API completeness.
32371    pub fn name(mut self, new_value: &str) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {
32372        self._name = new_value.to_string();
32373        self
32374    }
32375    /// Optional. Field mask is used to specify the fields to be overwritten in the TlsInspectionPolicy 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.
32376    ///
32377    /// Sets the *update mask* query property to the given value.
32378    pub fn update_mask(
32379        mut self,
32380        new_value: common::FieldMask,
32381    ) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {
32382        self._update_mask = Some(new_value);
32383        self
32384    }
32385    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32386    /// while executing the actual API request.
32387    ///
32388    /// ````text
32389    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32390    /// ````
32391    ///
32392    /// Sets the *delegate* property to the given value.
32393    pub fn delegate(
32394        mut self,
32395        new_value: &'a mut dyn common::Delegate,
32396    ) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {
32397        self._delegate = Some(new_value);
32398        self
32399    }
32400
32401    /// Set any additional parameter of the query string used in the request.
32402    /// It should be used to set parameters which are not yet available through their own
32403    /// setters.
32404    ///
32405    /// Please note that this method must not be used to set any of the known parameters
32406    /// which have their own setter method. If done anyway, the request will fail.
32407    ///
32408    /// # Additional Parameters
32409    ///
32410    /// * *$.xgafv* (query-string) - V1 error format.
32411    /// * *access_token* (query-string) - OAuth access token.
32412    /// * *alt* (query-string) - Data format for response.
32413    /// * *callback* (query-string) - JSONP
32414    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32415    /// * *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.
32416    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32417    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32418    /// * *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.
32419    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32420    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32421    pub fn param<T>(
32422        mut self,
32423        name: T,
32424        value: T,
32425    ) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C>
32426    where
32427        T: AsRef<str>,
32428    {
32429        self._additional_params
32430            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32431        self
32432    }
32433
32434    /// Identifies the authorization scope for the method you are building.
32435    ///
32436    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32437    /// [`Scope::CloudPlatform`].
32438    ///
32439    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32440    /// tokens for more than one scope.
32441    ///
32442    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32443    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32444    /// sufficient, a read-write scope will do as well.
32445    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C>
32446    where
32447        St: AsRef<str>,
32448    {
32449        self._scopes.insert(String::from(scope.as_ref()));
32450        self
32451    }
32452    /// Identifies the authorization scope(s) for the method you are building.
32453    ///
32454    /// See [`Self::add_scope()`] for details.
32455    pub fn add_scopes<I, St>(
32456        mut self,
32457        scopes: I,
32458    ) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C>
32459    where
32460        I: IntoIterator<Item = St>,
32461        St: AsRef<str>,
32462    {
32463        self._scopes
32464            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32465        self
32466    }
32467
32468    /// Removes all scopes, and no default scope will be used either.
32469    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32470    /// for details).
32471    pub fn clear_scopes(mut self) -> ProjectLocationTlsInspectionPolicyPatchCall<'a, C> {
32472        self._scopes.clear();
32473        self
32474    }
32475}
32476
32477/// Creates a new UrlList in a given project and location.
32478///
32479/// A builder for the *locations.urlLists.create* method supported by a *project* resource.
32480/// It is not used directly, but through a [`ProjectMethods`] instance.
32481///
32482/// # Example
32483///
32484/// Instantiate a resource method builder
32485///
32486/// ```test_harness,no_run
32487/// # extern crate hyper;
32488/// # extern crate hyper_rustls;
32489/// # extern crate google_networksecurity1 as networksecurity1;
32490/// use networksecurity1::api::UrlList;
32491/// # async fn dox() {
32492/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32493///
32494/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32495/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32496/// #     secret,
32497/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32498/// # ).build().await.unwrap();
32499///
32500/// # let client = hyper_util::client::legacy::Client::builder(
32501/// #     hyper_util::rt::TokioExecutor::new()
32502/// # )
32503/// # .build(
32504/// #     hyper_rustls::HttpsConnectorBuilder::new()
32505/// #         .with_native_roots()
32506/// #         .unwrap()
32507/// #         .https_or_http()
32508/// #         .enable_http1()
32509/// #         .build()
32510/// # );
32511/// # let mut hub = NetworkSecurity::new(client, auth);
32512/// // As the method needs a request, you would usually fill it with the desired information
32513/// // into the respective structure. Some of the parts shown here might not be applicable !
32514/// // Values shown here are possibly random and not representative !
32515/// let mut req = UrlList::default();
32516///
32517/// // You can configure optional parameters by calling the respective setters at will, and
32518/// // execute the final call using `doit()`.
32519/// // Values shown here are possibly random and not representative !
32520/// let result = hub.projects().locations_url_lists_create(req, "parent")
32521///              .url_list_id("Lorem")
32522///              .doit().await;
32523/// # }
32524/// ```
32525pub struct ProjectLocationUrlListCreateCall<'a, C>
32526where
32527    C: 'a,
32528{
32529    hub: &'a NetworkSecurity<C>,
32530    _request: UrlList,
32531    _parent: String,
32532    _url_list_id: Option<String>,
32533    _delegate: Option<&'a mut dyn common::Delegate>,
32534    _additional_params: HashMap<String, String>,
32535    _scopes: BTreeSet<String>,
32536}
32537
32538impl<'a, C> common::CallBuilder for ProjectLocationUrlListCreateCall<'a, C> {}
32539
32540impl<'a, C> ProjectLocationUrlListCreateCall<'a, C>
32541where
32542    C: common::Connector,
32543{
32544    /// Perform the operation you have build so far.
32545    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
32546        use std::borrow::Cow;
32547        use std::io::{Read, Seek};
32548
32549        use common::{url::Params, ToParts};
32550        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32551
32552        let mut dd = common::DefaultDelegate;
32553        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32554        dlg.begin(common::MethodInfo {
32555            id: "networksecurity.projects.locations.urlLists.create",
32556            http_method: hyper::Method::POST,
32557        });
32558
32559        for &field in ["alt", "parent", "urlListId"].iter() {
32560            if self._additional_params.contains_key(field) {
32561                dlg.finished(false);
32562                return Err(common::Error::FieldClash(field));
32563            }
32564        }
32565
32566        let mut params = Params::with_capacity(5 + self._additional_params.len());
32567        params.push("parent", self._parent);
32568        if let Some(value) = self._url_list_id.as_ref() {
32569            params.push("urlListId", value);
32570        }
32571
32572        params.extend(self._additional_params.iter());
32573
32574        params.push("alt", "json");
32575        let mut url = self.hub._base_url.clone() + "v1/{+parent}/urlLists";
32576        if self._scopes.is_empty() {
32577            self._scopes
32578                .insert(Scope::CloudPlatform.as_ref().to_string());
32579        }
32580
32581        #[allow(clippy::single_element_loop)]
32582        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
32583            url = params.uri_replacement(url, param_name, find_this, true);
32584        }
32585        {
32586            let to_remove = ["parent"];
32587            params.remove_params(&to_remove);
32588        }
32589
32590        let url = params.parse_with_url(&url);
32591
32592        let mut json_mime_type = mime::APPLICATION_JSON;
32593        let mut request_value_reader = {
32594            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32595            common::remove_json_null_values(&mut value);
32596            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32597            serde_json::to_writer(&mut dst, &value).unwrap();
32598            dst
32599        };
32600        let request_size = request_value_reader
32601            .seek(std::io::SeekFrom::End(0))
32602            .unwrap();
32603        request_value_reader
32604            .seek(std::io::SeekFrom::Start(0))
32605            .unwrap();
32606
32607        loop {
32608            let token = match self
32609                .hub
32610                .auth
32611                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32612                .await
32613            {
32614                Ok(token) => token,
32615                Err(e) => match dlg.token(e) {
32616                    Ok(token) => token,
32617                    Err(e) => {
32618                        dlg.finished(false);
32619                        return Err(common::Error::MissingToken(e));
32620                    }
32621                },
32622            };
32623            request_value_reader
32624                .seek(std::io::SeekFrom::Start(0))
32625                .unwrap();
32626            let mut req_result = {
32627                let client = &self.hub.client;
32628                dlg.pre_request();
32629                let mut req_builder = hyper::Request::builder()
32630                    .method(hyper::Method::POST)
32631                    .uri(url.as_str())
32632                    .header(USER_AGENT, self.hub._user_agent.clone());
32633
32634                if let Some(token) = token.as_ref() {
32635                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32636                }
32637
32638                let request = req_builder
32639                    .header(CONTENT_TYPE, json_mime_type.to_string())
32640                    .header(CONTENT_LENGTH, request_size as u64)
32641                    .body(common::to_body(
32642                        request_value_reader.get_ref().clone().into(),
32643                    ));
32644
32645                client.request(request.unwrap()).await
32646            };
32647
32648            match req_result {
32649                Err(err) => {
32650                    if let common::Retry::After(d) = dlg.http_error(&err) {
32651                        sleep(d).await;
32652                        continue;
32653                    }
32654                    dlg.finished(false);
32655                    return Err(common::Error::HttpError(err));
32656                }
32657                Ok(res) => {
32658                    let (mut parts, body) = res.into_parts();
32659                    let mut body = common::Body::new(body);
32660                    if !parts.status.is_success() {
32661                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32662                        let error = serde_json::from_str(&common::to_string(&bytes));
32663                        let response = common::to_response(parts, bytes.into());
32664
32665                        if let common::Retry::After(d) =
32666                            dlg.http_failure(&response, error.as_ref().ok())
32667                        {
32668                            sleep(d).await;
32669                            continue;
32670                        }
32671
32672                        dlg.finished(false);
32673
32674                        return Err(match error {
32675                            Ok(value) => common::Error::BadRequest(value),
32676                            _ => common::Error::Failure(response),
32677                        });
32678                    }
32679                    let response = {
32680                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32681                        let encoded = common::to_string(&bytes);
32682                        match serde_json::from_str(&encoded) {
32683                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32684                            Err(error) => {
32685                                dlg.response_json_decode_error(&encoded, &error);
32686                                return Err(common::Error::JsonDecodeError(
32687                                    encoded.to_string(),
32688                                    error,
32689                                ));
32690                            }
32691                        }
32692                    };
32693
32694                    dlg.finished(true);
32695                    return Ok(response);
32696                }
32697            }
32698        }
32699    }
32700
32701    ///
32702    /// Sets the *request* property to the given value.
32703    ///
32704    /// Even though the property as already been set when instantiating this call,
32705    /// we provide this method for API completeness.
32706    pub fn request(mut self, new_value: UrlList) -> ProjectLocationUrlListCreateCall<'a, C> {
32707        self._request = new_value;
32708        self
32709    }
32710    /// Required. The parent resource of the UrlList. Must be in the format `projects/*/locations/{location}`.
32711    ///
32712    /// Sets the *parent* path property to the given value.
32713    ///
32714    /// Even though the property as already been set when instantiating this call,
32715    /// we provide this method for API completeness.
32716    pub fn parent(mut self, new_value: &str) -> ProjectLocationUrlListCreateCall<'a, C> {
32717        self._parent = new_value.to_string();
32718        self
32719    }
32720    /// Required. Short name of the UrlList resource to be created. This value should be 1-63 characters long, containing only letters, numbers, hyphens, and underscores, and should not start with a number. E.g. "url_list".
32721    ///
32722    /// Sets the *url list id* query property to the given value.
32723    pub fn url_list_id(mut self, new_value: &str) -> ProjectLocationUrlListCreateCall<'a, C> {
32724        self._url_list_id = Some(new_value.to_string());
32725        self
32726    }
32727    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32728    /// while executing the actual API request.
32729    ///
32730    /// ````text
32731    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32732    /// ````
32733    ///
32734    /// Sets the *delegate* property to the given value.
32735    pub fn delegate(
32736        mut self,
32737        new_value: &'a mut dyn common::Delegate,
32738    ) -> ProjectLocationUrlListCreateCall<'a, C> {
32739        self._delegate = Some(new_value);
32740        self
32741    }
32742
32743    /// Set any additional parameter of the query string used in the request.
32744    /// It should be used to set parameters which are not yet available through their own
32745    /// setters.
32746    ///
32747    /// Please note that this method must not be used to set any of the known parameters
32748    /// which have their own setter method. If done anyway, the request will fail.
32749    ///
32750    /// # Additional Parameters
32751    ///
32752    /// * *$.xgafv* (query-string) - V1 error format.
32753    /// * *access_token* (query-string) - OAuth access token.
32754    /// * *alt* (query-string) - Data format for response.
32755    /// * *callback* (query-string) - JSONP
32756    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32757    /// * *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.
32758    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32759    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32760    /// * *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.
32761    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32762    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32763    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUrlListCreateCall<'a, C>
32764    where
32765        T: AsRef<str>,
32766    {
32767        self._additional_params
32768            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32769        self
32770    }
32771
32772    /// Identifies the authorization scope for the method you are building.
32773    ///
32774    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32775    /// [`Scope::CloudPlatform`].
32776    ///
32777    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32778    /// tokens for more than one scope.
32779    ///
32780    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32781    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32782    /// sufficient, a read-write scope will do as well.
32783    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUrlListCreateCall<'a, C>
32784    where
32785        St: AsRef<str>,
32786    {
32787        self._scopes.insert(String::from(scope.as_ref()));
32788        self
32789    }
32790    /// Identifies the authorization scope(s) for the method you are building.
32791    ///
32792    /// See [`Self::add_scope()`] for details.
32793    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUrlListCreateCall<'a, C>
32794    where
32795        I: IntoIterator<Item = St>,
32796        St: AsRef<str>,
32797    {
32798        self._scopes
32799            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32800        self
32801    }
32802
32803    /// Removes all scopes, and no default scope will be used either.
32804    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32805    /// for details).
32806    pub fn clear_scopes(mut self) -> ProjectLocationUrlListCreateCall<'a, C> {
32807        self._scopes.clear();
32808        self
32809    }
32810}
32811
32812/// Deletes a single UrlList.
32813///
32814/// A builder for the *locations.urlLists.delete* method supported by a *project* resource.
32815/// It is not used directly, but through a [`ProjectMethods`] instance.
32816///
32817/// # Example
32818///
32819/// Instantiate a resource method builder
32820///
32821/// ```test_harness,no_run
32822/// # extern crate hyper;
32823/// # extern crate hyper_rustls;
32824/// # extern crate google_networksecurity1 as networksecurity1;
32825/// # async fn dox() {
32826/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32827///
32828/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32829/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32830/// #     secret,
32831/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32832/// # ).build().await.unwrap();
32833///
32834/// # let client = hyper_util::client::legacy::Client::builder(
32835/// #     hyper_util::rt::TokioExecutor::new()
32836/// # )
32837/// # .build(
32838/// #     hyper_rustls::HttpsConnectorBuilder::new()
32839/// #         .with_native_roots()
32840/// #         .unwrap()
32841/// #         .https_or_http()
32842/// #         .enable_http1()
32843/// #         .build()
32844/// # );
32845/// # let mut hub = NetworkSecurity::new(client, auth);
32846/// // You can configure optional parameters by calling the respective setters at will, and
32847/// // execute the final call using `doit()`.
32848/// // Values shown here are possibly random and not representative !
32849/// let result = hub.projects().locations_url_lists_delete("name")
32850///              .doit().await;
32851/// # }
32852/// ```
32853pub struct ProjectLocationUrlListDeleteCall<'a, C>
32854where
32855    C: 'a,
32856{
32857    hub: &'a NetworkSecurity<C>,
32858    _name: String,
32859    _delegate: Option<&'a mut dyn common::Delegate>,
32860    _additional_params: HashMap<String, String>,
32861    _scopes: BTreeSet<String>,
32862}
32863
32864impl<'a, C> common::CallBuilder for ProjectLocationUrlListDeleteCall<'a, C> {}
32865
32866impl<'a, C> ProjectLocationUrlListDeleteCall<'a, C>
32867where
32868    C: common::Connector,
32869{
32870    /// Perform the operation you have build so far.
32871    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
32872        use std::borrow::Cow;
32873        use std::io::{Read, Seek};
32874
32875        use common::{url::Params, ToParts};
32876        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32877
32878        let mut dd = common::DefaultDelegate;
32879        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32880        dlg.begin(common::MethodInfo {
32881            id: "networksecurity.projects.locations.urlLists.delete",
32882            http_method: hyper::Method::DELETE,
32883        });
32884
32885        for &field in ["alt", "name"].iter() {
32886            if self._additional_params.contains_key(field) {
32887                dlg.finished(false);
32888                return Err(common::Error::FieldClash(field));
32889            }
32890        }
32891
32892        let mut params = Params::with_capacity(3 + self._additional_params.len());
32893        params.push("name", self._name);
32894
32895        params.extend(self._additional_params.iter());
32896
32897        params.push("alt", "json");
32898        let mut url = self.hub._base_url.clone() + "v1/{+name}";
32899        if self._scopes.is_empty() {
32900            self._scopes
32901                .insert(Scope::CloudPlatform.as_ref().to_string());
32902        }
32903
32904        #[allow(clippy::single_element_loop)]
32905        for &(find_this, param_name) in [("{+name}", "name")].iter() {
32906            url = params.uri_replacement(url, param_name, find_this, true);
32907        }
32908        {
32909            let to_remove = ["name"];
32910            params.remove_params(&to_remove);
32911        }
32912
32913        let url = params.parse_with_url(&url);
32914
32915        loop {
32916            let token = match self
32917                .hub
32918                .auth
32919                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32920                .await
32921            {
32922                Ok(token) => token,
32923                Err(e) => match dlg.token(e) {
32924                    Ok(token) => token,
32925                    Err(e) => {
32926                        dlg.finished(false);
32927                        return Err(common::Error::MissingToken(e));
32928                    }
32929                },
32930            };
32931            let mut req_result = {
32932                let client = &self.hub.client;
32933                dlg.pre_request();
32934                let mut req_builder = hyper::Request::builder()
32935                    .method(hyper::Method::DELETE)
32936                    .uri(url.as_str())
32937                    .header(USER_AGENT, self.hub._user_agent.clone());
32938
32939                if let Some(token) = token.as_ref() {
32940                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32941                }
32942
32943                let request = req_builder
32944                    .header(CONTENT_LENGTH, 0_u64)
32945                    .body(common::to_body::<String>(None));
32946
32947                client.request(request.unwrap()).await
32948            };
32949
32950            match req_result {
32951                Err(err) => {
32952                    if let common::Retry::After(d) = dlg.http_error(&err) {
32953                        sleep(d).await;
32954                        continue;
32955                    }
32956                    dlg.finished(false);
32957                    return Err(common::Error::HttpError(err));
32958                }
32959                Ok(res) => {
32960                    let (mut parts, body) = res.into_parts();
32961                    let mut body = common::Body::new(body);
32962                    if !parts.status.is_success() {
32963                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32964                        let error = serde_json::from_str(&common::to_string(&bytes));
32965                        let response = common::to_response(parts, bytes.into());
32966
32967                        if let common::Retry::After(d) =
32968                            dlg.http_failure(&response, error.as_ref().ok())
32969                        {
32970                            sleep(d).await;
32971                            continue;
32972                        }
32973
32974                        dlg.finished(false);
32975
32976                        return Err(match error {
32977                            Ok(value) => common::Error::BadRequest(value),
32978                            _ => common::Error::Failure(response),
32979                        });
32980                    }
32981                    let response = {
32982                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32983                        let encoded = common::to_string(&bytes);
32984                        match serde_json::from_str(&encoded) {
32985                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32986                            Err(error) => {
32987                                dlg.response_json_decode_error(&encoded, &error);
32988                                return Err(common::Error::JsonDecodeError(
32989                                    encoded.to_string(),
32990                                    error,
32991                                ));
32992                            }
32993                        }
32994                    };
32995
32996                    dlg.finished(true);
32997                    return Ok(response);
32998                }
32999            }
33000        }
33001    }
33002
33003    /// Required. A name of the UrlList to delete. Must be in the format `projects/*/locations/{location}/urlLists/*`.
33004    ///
33005    /// Sets the *name* path property to the given value.
33006    ///
33007    /// Even though the property as already been set when instantiating this call,
33008    /// we provide this method for API completeness.
33009    pub fn name(mut self, new_value: &str) -> ProjectLocationUrlListDeleteCall<'a, C> {
33010        self._name = new_value.to_string();
33011        self
33012    }
33013    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33014    /// while executing the actual API request.
33015    ///
33016    /// ````text
33017    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33018    /// ````
33019    ///
33020    /// Sets the *delegate* property to the given value.
33021    pub fn delegate(
33022        mut self,
33023        new_value: &'a mut dyn common::Delegate,
33024    ) -> ProjectLocationUrlListDeleteCall<'a, C> {
33025        self._delegate = Some(new_value);
33026        self
33027    }
33028
33029    /// Set any additional parameter of the query string used in the request.
33030    /// It should be used to set parameters which are not yet available through their own
33031    /// setters.
33032    ///
33033    /// Please note that this method must not be used to set any of the known parameters
33034    /// which have their own setter method. If done anyway, the request will fail.
33035    ///
33036    /// # Additional Parameters
33037    ///
33038    /// * *$.xgafv* (query-string) - V1 error format.
33039    /// * *access_token* (query-string) - OAuth access token.
33040    /// * *alt* (query-string) - Data format for response.
33041    /// * *callback* (query-string) - JSONP
33042    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33043    /// * *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.
33044    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33045    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33046    /// * *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.
33047    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33048    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33049    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUrlListDeleteCall<'a, C>
33050    where
33051        T: AsRef<str>,
33052    {
33053        self._additional_params
33054            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33055        self
33056    }
33057
33058    /// Identifies the authorization scope for the method you are building.
33059    ///
33060    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33061    /// [`Scope::CloudPlatform`].
33062    ///
33063    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33064    /// tokens for more than one scope.
33065    ///
33066    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33067    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33068    /// sufficient, a read-write scope will do as well.
33069    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUrlListDeleteCall<'a, C>
33070    where
33071        St: AsRef<str>,
33072    {
33073        self._scopes.insert(String::from(scope.as_ref()));
33074        self
33075    }
33076    /// Identifies the authorization scope(s) for the method you are building.
33077    ///
33078    /// See [`Self::add_scope()`] for details.
33079    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUrlListDeleteCall<'a, C>
33080    where
33081        I: IntoIterator<Item = St>,
33082        St: AsRef<str>,
33083    {
33084        self._scopes
33085            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33086        self
33087    }
33088
33089    /// Removes all scopes, and no default scope will be used either.
33090    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33091    /// for details).
33092    pub fn clear_scopes(mut self) -> ProjectLocationUrlListDeleteCall<'a, C> {
33093        self._scopes.clear();
33094        self
33095    }
33096}
33097
33098/// Gets details of a single UrlList.
33099///
33100/// A builder for the *locations.urlLists.get* method supported by a *project* resource.
33101/// It is not used directly, but through a [`ProjectMethods`] instance.
33102///
33103/// # Example
33104///
33105/// Instantiate a resource method builder
33106///
33107/// ```test_harness,no_run
33108/// # extern crate hyper;
33109/// # extern crate hyper_rustls;
33110/// # extern crate google_networksecurity1 as networksecurity1;
33111/// # async fn dox() {
33112/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33113///
33114/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33115/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33116/// #     secret,
33117/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33118/// # ).build().await.unwrap();
33119///
33120/// # let client = hyper_util::client::legacy::Client::builder(
33121/// #     hyper_util::rt::TokioExecutor::new()
33122/// # )
33123/// # .build(
33124/// #     hyper_rustls::HttpsConnectorBuilder::new()
33125/// #         .with_native_roots()
33126/// #         .unwrap()
33127/// #         .https_or_http()
33128/// #         .enable_http1()
33129/// #         .build()
33130/// # );
33131/// # let mut hub = NetworkSecurity::new(client, auth);
33132/// // You can configure optional parameters by calling the respective setters at will, and
33133/// // execute the final call using `doit()`.
33134/// // Values shown here are possibly random and not representative !
33135/// let result = hub.projects().locations_url_lists_get("name")
33136///              .doit().await;
33137/// # }
33138/// ```
33139pub struct ProjectLocationUrlListGetCall<'a, C>
33140where
33141    C: 'a,
33142{
33143    hub: &'a NetworkSecurity<C>,
33144    _name: String,
33145    _delegate: Option<&'a mut dyn common::Delegate>,
33146    _additional_params: HashMap<String, String>,
33147    _scopes: BTreeSet<String>,
33148}
33149
33150impl<'a, C> common::CallBuilder for ProjectLocationUrlListGetCall<'a, C> {}
33151
33152impl<'a, C> ProjectLocationUrlListGetCall<'a, C>
33153where
33154    C: common::Connector,
33155{
33156    /// Perform the operation you have build so far.
33157    pub async fn doit(mut self) -> common::Result<(common::Response, UrlList)> {
33158        use std::borrow::Cow;
33159        use std::io::{Read, Seek};
33160
33161        use common::{url::Params, ToParts};
33162        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33163
33164        let mut dd = common::DefaultDelegate;
33165        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33166        dlg.begin(common::MethodInfo {
33167            id: "networksecurity.projects.locations.urlLists.get",
33168            http_method: hyper::Method::GET,
33169        });
33170
33171        for &field in ["alt", "name"].iter() {
33172            if self._additional_params.contains_key(field) {
33173                dlg.finished(false);
33174                return Err(common::Error::FieldClash(field));
33175            }
33176        }
33177
33178        let mut params = Params::with_capacity(3 + self._additional_params.len());
33179        params.push("name", self._name);
33180
33181        params.extend(self._additional_params.iter());
33182
33183        params.push("alt", "json");
33184        let mut url = self.hub._base_url.clone() + "v1/{+name}";
33185        if self._scopes.is_empty() {
33186            self._scopes
33187                .insert(Scope::CloudPlatform.as_ref().to_string());
33188        }
33189
33190        #[allow(clippy::single_element_loop)]
33191        for &(find_this, param_name) in [("{+name}", "name")].iter() {
33192            url = params.uri_replacement(url, param_name, find_this, true);
33193        }
33194        {
33195            let to_remove = ["name"];
33196            params.remove_params(&to_remove);
33197        }
33198
33199        let url = params.parse_with_url(&url);
33200
33201        loop {
33202            let token = match self
33203                .hub
33204                .auth
33205                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33206                .await
33207            {
33208                Ok(token) => token,
33209                Err(e) => match dlg.token(e) {
33210                    Ok(token) => token,
33211                    Err(e) => {
33212                        dlg.finished(false);
33213                        return Err(common::Error::MissingToken(e));
33214                    }
33215                },
33216            };
33217            let mut req_result = {
33218                let client = &self.hub.client;
33219                dlg.pre_request();
33220                let mut req_builder = hyper::Request::builder()
33221                    .method(hyper::Method::GET)
33222                    .uri(url.as_str())
33223                    .header(USER_AGENT, self.hub._user_agent.clone());
33224
33225                if let Some(token) = token.as_ref() {
33226                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33227                }
33228
33229                let request = req_builder
33230                    .header(CONTENT_LENGTH, 0_u64)
33231                    .body(common::to_body::<String>(None));
33232
33233                client.request(request.unwrap()).await
33234            };
33235
33236            match req_result {
33237                Err(err) => {
33238                    if let common::Retry::After(d) = dlg.http_error(&err) {
33239                        sleep(d).await;
33240                        continue;
33241                    }
33242                    dlg.finished(false);
33243                    return Err(common::Error::HttpError(err));
33244                }
33245                Ok(res) => {
33246                    let (mut parts, body) = res.into_parts();
33247                    let mut body = common::Body::new(body);
33248                    if !parts.status.is_success() {
33249                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33250                        let error = serde_json::from_str(&common::to_string(&bytes));
33251                        let response = common::to_response(parts, bytes.into());
33252
33253                        if let common::Retry::After(d) =
33254                            dlg.http_failure(&response, error.as_ref().ok())
33255                        {
33256                            sleep(d).await;
33257                            continue;
33258                        }
33259
33260                        dlg.finished(false);
33261
33262                        return Err(match error {
33263                            Ok(value) => common::Error::BadRequest(value),
33264                            _ => common::Error::Failure(response),
33265                        });
33266                    }
33267                    let response = {
33268                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33269                        let encoded = common::to_string(&bytes);
33270                        match serde_json::from_str(&encoded) {
33271                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33272                            Err(error) => {
33273                                dlg.response_json_decode_error(&encoded, &error);
33274                                return Err(common::Error::JsonDecodeError(
33275                                    encoded.to_string(),
33276                                    error,
33277                                ));
33278                            }
33279                        }
33280                    };
33281
33282                    dlg.finished(true);
33283                    return Ok(response);
33284                }
33285            }
33286        }
33287    }
33288
33289    /// Required. A name of the UrlList to get. Must be in the format `projects/*/locations/{location}/urlLists/*`.
33290    ///
33291    /// Sets the *name* path property to the given value.
33292    ///
33293    /// Even though the property as already been set when instantiating this call,
33294    /// we provide this method for API completeness.
33295    pub fn name(mut self, new_value: &str) -> ProjectLocationUrlListGetCall<'a, C> {
33296        self._name = new_value.to_string();
33297        self
33298    }
33299    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33300    /// while executing the actual API request.
33301    ///
33302    /// ````text
33303    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33304    /// ````
33305    ///
33306    /// Sets the *delegate* property to the given value.
33307    pub fn delegate(
33308        mut self,
33309        new_value: &'a mut dyn common::Delegate,
33310    ) -> ProjectLocationUrlListGetCall<'a, C> {
33311        self._delegate = Some(new_value);
33312        self
33313    }
33314
33315    /// Set any additional parameter of the query string used in the request.
33316    /// It should be used to set parameters which are not yet available through their own
33317    /// setters.
33318    ///
33319    /// Please note that this method must not be used to set any of the known parameters
33320    /// which have their own setter method. If done anyway, the request will fail.
33321    ///
33322    /// # Additional Parameters
33323    ///
33324    /// * *$.xgafv* (query-string) - V1 error format.
33325    /// * *access_token* (query-string) - OAuth access token.
33326    /// * *alt* (query-string) - Data format for response.
33327    /// * *callback* (query-string) - JSONP
33328    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33329    /// * *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.
33330    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33331    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33332    /// * *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.
33333    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33334    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33335    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUrlListGetCall<'a, C>
33336    where
33337        T: AsRef<str>,
33338    {
33339        self._additional_params
33340            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33341        self
33342    }
33343
33344    /// Identifies the authorization scope for the method you are building.
33345    ///
33346    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33347    /// [`Scope::CloudPlatform`].
33348    ///
33349    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33350    /// tokens for more than one scope.
33351    ///
33352    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33353    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33354    /// sufficient, a read-write scope will do as well.
33355    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUrlListGetCall<'a, C>
33356    where
33357        St: AsRef<str>,
33358    {
33359        self._scopes.insert(String::from(scope.as_ref()));
33360        self
33361    }
33362    /// Identifies the authorization scope(s) for the method you are building.
33363    ///
33364    /// See [`Self::add_scope()`] for details.
33365    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUrlListGetCall<'a, C>
33366    where
33367        I: IntoIterator<Item = St>,
33368        St: AsRef<str>,
33369    {
33370        self._scopes
33371            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33372        self
33373    }
33374
33375    /// Removes all scopes, and no default scope will be used either.
33376    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33377    /// for details).
33378    pub fn clear_scopes(mut self) -> ProjectLocationUrlListGetCall<'a, C> {
33379        self._scopes.clear();
33380        self
33381    }
33382}
33383
33384/// Lists UrlLists in a given project and location.
33385///
33386/// A builder for the *locations.urlLists.list* method supported by a *project* resource.
33387/// It is not used directly, but through a [`ProjectMethods`] instance.
33388///
33389/// # Example
33390///
33391/// Instantiate a resource method builder
33392///
33393/// ```test_harness,no_run
33394/// # extern crate hyper;
33395/// # extern crate hyper_rustls;
33396/// # extern crate google_networksecurity1 as networksecurity1;
33397/// # async fn dox() {
33398/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33399///
33400/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33402/// #     secret,
33403/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33404/// # ).build().await.unwrap();
33405///
33406/// # let client = hyper_util::client::legacy::Client::builder(
33407/// #     hyper_util::rt::TokioExecutor::new()
33408/// # )
33409/// # .build(
33410/// #     hyper_rustls::HttpsConnectorBuilder::new()
33411/// #         .with_native_roots()
33412/// #         .unwrap()
33413/// #         .https_or_http()
33414/// #         .enable_http1()
33415/// #         .build()
33416/// # );
33417/// # let mut hub = NetworkSecurity::new(client, auth);
33418/// // You can configure optional parameters by calling the respective setters at will, and
33419/// // execute the final call using `doit()`.
33420/// // Values shown here are possibly random and not representative !
33421/// let result = hub.projects().locations_url_lists_list("parent")
33422///              .page_token("et")
33423///              .page_size(-48)
33424///              .doit().await;
33425/// # }
33426/// ```
33427pub struct ProjectLocationUrlListListCall<'a, C>
33428where
33429    C: 'a,
33430{
33431    hub: &'a NetworkSecurity<C>,
33432    _parent: String,
33433    _page_token: Option<String>,
33434    _page_size: Option<i32>,
33435    _delegate: Option<&'a mut dyn common::Delegate>,
33436    _additional_params: HashMap<String, String>,
33437    _scopes: BTreeSet<String>,
33438}
33439
33440impl<'a, C> common::CallBuilder for ProjectLocationUrlListListCall<'a, C> {}
33441
33442impl<'a, C> ProjectLocationUrlListListCall<'a, C>
33443where
33444    C: common::Connector,
33445{
33446    /// Perform the operation you have build so far.
33447    pub async fn doit(mut self) -> common::Result<(common::Response, ListUrlListsResponse)> {
33448        use std::borrow::Cow;
33449        use std::io::{Read, Seek};
33450
33451        use common::{url::Params, ToParts};
33452        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33453
33454        let mut dd = common::DefaultDelegate;
33455        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33456        dlg.begin(common::MethodInfo {
33457            id: "networksecurity.projects.locations.urlLists.list",
33458            http_method: hyper::Method::GET,
33459        });
33460
33461        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
33462            if self._additional_params.contains_key(field) {
33463                dlg.finished(false);
33464                return Err(common::Error::FieldClash(field));
33465            }
33466        }
33467
33468        let mut params = Params::with_capacity(5 + self._additional_params.len());
33469        params.push("parent", self._parent);
33470        if let Some(value) = self._page_token.as_ref() {
33471            params.push("pageToken", value);
33472        }
33473        if let Some(value) = self._page_size.as_ref() {
33474            params.push("pageSize", value.to_string());
33475        }
33476
33477        params.extend(self._additional_params.iter());
33478
33479        params.push("alt", "json");
33480        let mut url = self.hub._base_url.clone() + "v1/{+parent}/urlLists";
33481        if self._scopes.is_empty() {
33482            self._scopes
33483                .insert(Scope::CloudPlatform.as_ref().to_string());
33484        }
33485
33486        #[allow(clippy::single_element_loop)]
33487        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
33488            url = params.uri_replacement(url, param_name, find_this, true);
33489        }
33490        {
33491            let to_remove = ["parent"];
33492            params.remove_params(&to_remove);
33493        }
33494
33495        let url = params.parse_with_url(&url);
33496
33497        loop {
33498            let token = match self
33499                .hub
33500                .auth
33501                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33502                .await
33503            {
33504                Ok(token) => token,
33505                Err(e) => match dlg.token(e) {
33506                    Ok(token) => token,
33507                    Err(e) => {
33508                        dlg.finished(false);
33509                        return Err(common::Error::MissingToken(e));
33510                    }
33511                },
33512            };
33513            let mut req_result = {
33514                let client = &self.hub.client;
33515                dlg.pre_request();
33516                let mut req_builder = hyper::Request::builder()
33517                    .method(hyper::Method::GET)
33518                    .uri(url.as_str())
33519                    .header(USER_AGENT, self.hub._user_agent.clone());
33520
33521                if let Some(token) = token.as_ref() {
33522                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33523                }
33524
33525                let request = req_builder
33526                    .header(CONTENT_LENGTH, 0_u64)
33527                    .body(common::to_body::<String>(None));
33528
33529                client.request(request.unwrap()).await
33530            };
33531
33532            match req_result {
33533                Err(err) => {
33534                    if let common::Retry::After(d) = dlg.http_error(&err) {
33535                        sleep(d).await;
33536                        continue;
33537                    }
33538                    dlg.finished(false);
33539                    return Err(common::Error::HttpError(err));
33540                }
33541                Ok(res) => {
33542                    let (mut parts, body) = res.into_parts();
33543                    let mut body = common::Body::new(body);
33544                    if !parts.status.is_success() {
33545                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33546                        let error = serde_json::from_str(&common::to_string(&bytes));
33547                        let response = common::to_response(parts, bytes.into());
33548
33549                        if let common::Retry::After(d) =
33550                            dlg.http_failure(&response, error.as_ref().ok())
33551                        {
33552                            sleep(d).await;
33553                            continue;
33554                        }
33555
33556                        dlg.finished(false);
33557
33558                        return Err(match error {
33559                            Ok(value) => common::Error::BadRequest(value),
33560                            _ => common::Error::Failure(response),
33561                        });
33562                    }
33563                    let response = {
33564                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33565                        let encoded = common::to_string(&bytes);
33566                        match serde_json::from_str(&encoded) {
33567                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33568                            Err(error) => {
33569                                dlg.response_json_decode_error(&encoded, &error);
33570                                return Err(common::Error::JsonDecodeError(
33571                                    encoded.to_string(),
33572                                    error,
33573                                ));
33574                            }
33575                        }
33576                    };
33577
33578                    dlg.finished(true);
33579                    return Ok(response);
33580                }
33581            }
33582        }
33583    }
33584
33585    /// Required. The project and location from which the UrlLists should be listed, specified in the format `projects/{project}/locations/{location}`.
33586    ///
33587    /// Sets the *parent* path property to the given value.
33588    ///
33589    /// Even though the property as already been set when instantiating this call,
33590    /// we provide this method for API completeness.
33591    pub fn parent(mut self, new_value: &str) -> ProjectLocationUrlListListCall<'a, C> {
33592        self._parent = new_value.to_string();
33593        self
33594    }
33595    /// The value returned by the last `ListUrlListsResponse` Indicates that this is a continuation of a prior `ListUrlLists` call, and that the system should return the next page of data.
33596    ///
33597    /// Sets the *page token* query property to the given value.
33598    pub fn page_token(mut self, new_value: &str) -> ProjectLocationUrlListListCall<'a, C> {
33599        self._page_token = Some(new_value.to_string());
33600        self
33601    }
33602    /// Maximum number of UrlLists to return per call.
33603    ///
33604    /// Sets the *page size* query property to the given value.
33605    pub fn page_size(mut self, new_value: i32) -> ProjectLocationUrlListListCall<'a, C> {
33606        self._page_size = Some(new_value);
33607        self
33608    }
33609    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33610    /// while executing the actual API request.
33611    ///
33612    /// ````text
33613    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33614    /// ````
33615    ///
33616    /// Sets the *delegate* property to the given value.
33617    pub fn delegate(
33618        mut self,
33619        new_value: &'a mut dyn common::Delegate,
33620    ) -> ProjectLocationUrlListListCall<'a, C> {
33621        self._delegate = Some(new_value);
33622        self
33623    }
33624
33625    /// Set any additional parameter of the query string used in the request.
33626    /// It should be used to set parameters which are not yet available through their own
33627    /// setters.
33628    ///
33629    /// Please note that this method must not be used to set any of the known parameters
33630    /// which have their own setter method. If done anyway, the request will fail.
33631    ///
33632    /// # Additional Parameters
33633    ///
33634    /// * *$.xgafv* (query-string) - V1 error format.
33635    /// * *access_token* (query-string) - OAuth access token.
33636    /// * *alt* (query-string) - Data format for response.
33637    /// * *callback* (query-string) - JSONP
33638    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33639    /// * *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.
33640    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33641    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33642    /// * *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.
33643    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33644    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33645    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUrlListListCall<'a, C>
33646    where
33647        T: AsRef<str>,
33648    {
33649        self._additional_params
33650            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33651        self
33652    }
33653
33654    /// Identifies the authorization scope for the method you are building.
33655    ///
33656    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33657    /// [`Scope::CloudPlatform`].
33658    ///
33659    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33660    /// tokens for more than one scope.
33661    ///
33662    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33663    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33664    /// sufficient, a read-write scope will do as well.
33665    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUrlListListCall<'a, C>
33666    where
33667        St: AsRef<str>,
33668    {
33669        self._scopes.insert(String::from(scope.as_ref()));
33670        self
33671    }
33672    /// Identifies the authorization scope(s) for the method you are building.
33673    ///
33674    /// See [`Self::add_scope()`] for details.
33675    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUrlListListCall<'a, C>
33676    where
33677        I: IntoIterator<Item = St>,
33678        St: AsRef<str>,
33679    {
33680        self._scopes
33681            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33682        self
33683    }
33684
33685    /// Removes all scopes, and no default scope will be used either.
33686    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33687    /// for details).
33688    pub fn clear_scopes(mut self) -> ProjectLocationUrlListListCall<'a, C> {
33689        self._scopes.clear();
33690        self
33691    }
33692}
33693
33694/// Updates the parameters of a single UrlList.
33695///
33696/// A builder for the *locations.urlLists.patch* method supported by a *project* resource.
33697/// It is not used directly, but through a [`ProjectMethods`] instance.
33698///
33699/// # Example
33700///
33701/// Instantiate a resource method builder
33702///
33703/// ```test_harness,no_run
33704/// # extern crate hyper;
33705/// # extern crate hyper_rustls;
33706/// # extern crate google_networksecurity1 as networksecurity1;
33707/// use networksecurity1::api::UrlList;
33708/// # async fn dox() {
33709/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33710///
33711/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33712/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33713/// #     secret,
33714/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33715/// # ).build().await.unwrap();
33716///
33717/// # let client = hyper_util::client::legacy::Client::builder(
33718/// #     hyper_util::rt::TokioExecutor::new()
33719/// # )
33720/// # .build(
33721/// #     hyper_rustls::HttpsConnectorBuilder::new()
33722/// #         .with_native_roots()
33723/// #         .unwrap()
33724/// #         .https_or_http()
33725/// #         .enable_http1()
33726/// #         .build()
33727/// # );
33728/// # let mut hub = NetworkSecurity::new(client, auth);
33729/// // As the method needs a request, you would usually fill it with the desired information
33730/// // into the respective structure. Some of the parts shown here might not be applicable !
33731/// // Values shown here are possibly random and not representative !
33732/// let mut req = UrlList::default();
33733///
33734/// // You can configure optional parameters by calling the respective setters at will, and
33735/// // execute the final call using `doit()`.
33736/// // Values shown here are possibly random and not representative !
33737/// let result = hub.projects().locations_url_lists_patch(req, "name")
33738///              .update_mask(FieldMask::new::<&str>(&[]))
33739///              .doit().await;
33740/// # }
33741/// ```
33742pub struct ProjectLocationUrlListPatchCall<'a, C>
33743where
33744    C: 'a,
33745{
33746    hub: &'a NetworkSecurity<C>,
33747    _request: UrlList,
33748    _name: String,
33749    _update_mask: Option<common::FieldMask>,
33750    _delegate: Option<&'a mut dyn common::Delegate>,
33751    _additional_params: HashMap<String, String>,
33752    _scopes: BTreeSet<String>,
33753}
33754
33755impl<'a, C> common::CallBuilder for ProjectLocationUrlListPatchCall<'a, C> {}
33756
33757impl<'a, C> ProjectLocationUrlListPatchCall<'a, C>
33758where
33759    C: common::Connector,
33760{
33761    /// Perform the operation you have build so far.
33762    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
33763        use std::borrow::Cow;
33764        use std::io::{Read, Seek};
33765
33766        use common::{url::Params, ToParts};
33767        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33768
33769        let mut dd = common::DefaultDelegate;
33770        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33771        dlg.begin(common::MethodInfo {
33772            id: "networksecurity.projects.locations.urlLists.patch",
33773            http_method: hyper::Method::PATCH,
33774        });
33775
33776        for &field in ["alt", "name", "updateMask"].iter() {
33777            if self._additional_params.contains_key(field) {
33778                dlg.finished(false);
33779                return Err(common::Error::FieldClash(field));
33780            }
33781        }
33782
33783        let mut params = Params::with_capacity(5 + self._additional_params.len());
33784        params.push("name", self._name);
33785        if let Some(value) = self._update_mask.as_ref() {
33786            params.push("updateMask", value.to_string());
33787        }
33788
33789        params.extend(self._additional_params.iter());
33790
33791        params.push("alt", "json");
33792        let mut url = self.hub._base_url.clone() + "v1/{+name}";
33793        if self._scopes.is_empty() {
33794            self._scopes
33795                .insert(Scope::CloudPlatform.as_ref().to_string());
33796        }
33797
33798        #[allow(clippy::single_element_loop)]
33799        for &(find_this, param_name) in [("{+name}", "name")].iter() {
33800            url = params.uri_replacement(url, param_name, find_this, true);
33801        }
33802        {
33803            let to_remove = ["name"];
33804            params.remove_params(&to_remove);
33805        }
33806
33807        let url = params.parse_with_url(&url);
33808
33809        let mut json_mime_type = mime::APPLICATION_JSON;
33810        let mut request_value_reader = {
33811            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33812            common::remove_json_null_values(&mut value);
33813            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33814            serde_json::to_writer(&mut dst, &value).unwrap();
33815            dst
33816        };
33817        let request_size = request_value_reader
33818            .seek(std::io::SeekFrom::End(0))
33819            .unwrap();
33820        request_value_reader
33821            .seek(std::io::SeekFrom::Start(0))
33822            .unwrap();
33823
33824        loop {
33825            let token = match self
33826                .hub
33827                .auth
33828                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33829                .await
33830            {
33831                Ok(token) => token,
33832                Err(e) => match dlg.token(e) {
33833                    Ok(token) => token,
33834                    Err(e) => {
33835                        dlg.finished(false);
33836                        return Err(common::Error::MissingToken(e));
33837                    }
33838                },
33839            };
33840            request_value_reader
33841                .seek(std::io::SeekFrom::Start(0))
33842                .unwrap();
33843            let mut req_result = {
33844                let client = &self.hub.client;
33845                dlg.pre_request();
33846                let mut req_builder = hyper::Request::builder()
33847                    .method(hyper::Method::PATCH)
33848                    .uri(url.as_str())
33849                    .header(USER_AGENT, self.hub._user_agent.clone());
33850
33851                if let Some(token) = token.as_ref() {
33852                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33853                }
33854
33855                let request = req_builder
33856                    .header(CONTENT_TYPE, json_mime_type.to_string())
33857                    .header(CONTENT_LENGTH, request_size as u64)
33858                    .body(common::to_body(
33859                        request_value_reader.get_ref().clone().into(),
33860                    ));
33861
33862                client.request(request.unwrap()).await
33863            };
33864
33865            match req_result {
33866                Err(err) => {
33867                    if let common::Retry::After(d) = dlg.http_error(&err) {
33868                        sleep(d).await;
33869                        continue;
33870                    }
33871                    dlg.finished(false);
33872                    return Err(common::Error::HttpError(err));
33873                }
33874                Ok(res) => {
33875                    let (mut parts, body) = res.into_parts();
33876                    let mut body = common::Body::new(body);
33877                    if !parts.status.is_success() {
33878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33879                        let error = serde_json::from_str(&common::to_string(&bytes));
33880                        let response = common::to_response(parts, bytes.into());
33881
33882                        if let common::Retry::After(d) =
33883                            dlg.http_failure(&response, error.as_ref().ok())
33884                        {
33885                            sleep(d).await;
33886                            continue;
33887                        }
33888
33889                        dlg.finished(false);
33890
33891                        return Err(match error {
33892                            Ok(value) => common::Error::BadRequest(value),
33893                            _ => common::Error::Failure(response),
33894                        });
33895                    }
33896                    let response = {
33897                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33898                        let encoded = common::to_string(&bytes);
33899                        match serde_json::from_str(&encoded) {
33900                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33901                            Err(error) => {
33902                                dlg.response_json_decode_error(&encoded, &error);
33903                                return Err(common::Error::JsonDecodeError(
33904                                    encoded.to_string(),
33905                                    error,
33906                                ));
33907                            }
33908                        }
33909                    };
33910
33911                    dlg.finished(true);
33912                    return Ok(response);
33913                }
33914            }
33915        }
33916    }
33917
33918    ///
33919    /// Sets the *request* property to the given value.
33920    ///
33921    /// Even though the property as already been set when instantiating this call,
33922    /// we provide this method for API completeness.
33923    pub fn request(mut self, new_value: UrlList) -> ProjectLocationUrlListPatchCall<'a, C> {
33924        self._request = new_value;
33925        self
33926    }
33927    /// Required. Name of the resource provided by the user. Name is of the form projects/{project}/locations/{location}/urlLists/{url_list} url_list should match the pattern:(^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$).
33928    ///
33929    /// Sets the *name* path property to the given value.
33930    ///
33931    /// Even though the property as already been set when instantiating this call,
33932    /// we provide this method for API completeness.
33933    pub fn name(mut self, new_value: &str) -> ProjectLocationUrlListPatchCall<'a, C> {
33934        self._name = new_value.to_string();
33935        self
33936    }
33937    /// Optional. Field mask is used to specify the fields to be overwritten in the UrlList 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.
33938    ///
33939    /// Sets the *update mask* query property to the given value.
33940    pub fn update_mask(
33941        mut self,
33942        new_value: common::FieldMask,
33943    ) -> ProjectLocationUrlListPatchCall<'a, C> {
33944        self._update_mask = Some(new_value);
33945        self
33946    }
33947    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33948    /// while executing the actual API request.
33949    ///
33950    /// ````text
33951    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33952    /// ````
33953    ///
33954    /// Sets the *delegate* property to the given value.
33955    pub fn delegate(
33956        mut self,
33957        new_value: &'a mut dyn common::Delegate,
33958    ) -> ProjectLocationUrlListPatchCall<'a, C> {
33959        self._delegate = Some(new_value);
33960        self
33961    }
33962
33963    /// Set any additional parameter of the query string used in the request.
33964    /// It should be used to set parameters which are not yet available through their own
33965    /// setters.
33966    ///
33967    /// Please note that this method must not be used to set any of the known parameters
33968    /// which have their own setter method. If done anyway, the request will fail.
33969    ///
33970    /// # Additional Parameters
33971    ///
33972    /// * *$.xgafv* (query-string) - V1 error format.
33973    /// * *access_token* (query-string) - OAuth access token.
33974    /// * *alt* (query-string) - Data format for response.
33975    /// * *callback* (query-string) - JSONP
33976    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33977    /// * *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.
33978    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33979    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33980    /// * *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.
33981    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33982    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33983    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUrlListPatchCall<'a, C>
33984    where
33985        T: AsRef<str>,
33986    {
33987        self._additional_params
33988            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33989        self
33990    }
33991
33992    /// Identifies the authorization scope for the method you are building.
33993    ///
33994    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33995    /// [`Scope::CloudPlatform`].
33996    ///
33997    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33998    /// tokens for more than one scope.
33999    ///
34000    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34001    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34002    /// sufficient, a read-write scope will do as well.
34003    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUrlListPatchCall<'a, C>
34004    where
34005        St: AsRef<str>,
34006    {
34007        self._scopes.insert(String::from(scope.as_ref()));
34008        self
34009    }
34010    /// Identifies the authorization scope(s) for the method you are building.
34011    ///
34012    /// See [`Self::add_scope()`] for details.
34013    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUrlListPatchCall<'a, C>
34014    where
34015        I: IntoIterator<Item = St>,
34016        St: AsRef<str>,
34017    {
34018        self._scopes
34019            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34020        self
34021    }
34022
34023    /// Removes all scopes, and no default scope will be used either.
34024    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34025    /// for details).
34026    pub fn clear_scopes(mut self) -> ProjectLocationUrlListPatchCall<'a, C> {
34027        self._scopes.clear();
34028        self
34029    }
34030}
34031
34032/// Gets information about a location.
34033///
34034/// A builder for the *locations.get* method supported by a *project* resource.
34035/// It is not used directly, but through a [`ProjectMethods`] instance.
34036///
34037/// # Example
34038///
34039/// Instantiate a resource method builder
34040///
34041/// ```test_harness,no_run
34042/// # extern crate hyper;
34043/// # extern crate hyper_rustls;
34044/// # extern crate google_networksecurity1 as networksecurity1;
34045/// # async fn dox() {
34046/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34047///
34048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34049/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34050/// #     secret,
34051/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34052/// # ).build().await.unwrap();
34053///
34054/// # let client = hyper_util::client::legacy::Client::builder(
34055/// #     hyper_util::rt::TokioExecutor::new()
34056/// # )
34057/// # .build(
34058/// #     hyper_rustls::HttpsConnectorBuilder::new()
34059/// #         .with_native_roots()
34060/// #         .unwrap()
34061/// #         .https_or_http()
34062/// #         .enable_http1()
34063/// #         .build()
34064/// # );
34065/// # let mut hub = NetworkSecurity::new(client, auth);
34066/// // You can configure optional parameters by calling the respective setters at will, and
34067/// // execute the final call using `doit()`.
34068/// // Values shown here are possibly random and not representative !
34069/// let result = hub.projects().locations_get("name")
34070///              .doit().await;
34071/// # }
34072/// ```
34073pub struct ProjectLocationGetCall<'a, C>
34074where
34075    C: 'a,
34076{
34077    hub: &'a NetworkSecurity<C>,
34078    _name: String,
34079    _delegate: Option<&'a mut dyn common::Delegate>,
34080    _additional_params: HashMap<String, String>,
34081    _scopes: BTreeSet<String>,
34082}
34083
34084impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
34085
34086impl<'a, C> ProjectLocationGetCall<'a, C>
34087where
34088    C: common::Connector,
34089{
34090    /// Perform the operation you have build so far.
34091    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
34092        use std::borrow::Cow;
34093        use std::io::{Read, Seek};
34094
34095        use common::{url::Params, ToParts};
34096        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34097
34098        let mut dd = common::DefaultDelegate;
34099        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34100        dlg.begin(common::MethodInfo {
34101            id: "networksecurity.projects.locations.get",
34102            http_method: hyper::Method::GET,
34103        });
34104
34105        for &field in ["alt", "name"].iter() {
34106            if self._additional_params.contains_key(field) {
34107                dlg.finished(false);
34108                return Err(common::Error::FieldClash(field));
34109            }
34110        }
34111
34112        let mut params = Params::with_capacity(3 + self._additional_params.len());
34113        params.push("name", self._name);
34114
34115        params.extend(self._additional_params.iter());
34116
34117        params.push("alt", "json");
34118        let mut url = self.hub._base_url.clone() + "v1/{+name}";
34119        if self._scopes.is_empty() {
34120            self._scopes
34121                .insert(Scope::CloudPlatform.as_ref().to_string());
34122        }
34123
34124        #[allow(clippy::single_element_loop)]
34125        for &(find_this, param_name) in [("{+name}", "name")].iter() {
34126            url = params.uri_replacement(url, param_name, find_this, true);
34127        }
34128        {
34129            let to_remove = ["name"];
34130            params.remove_params(&to_remove);
34131        }
34132
34133        let url = params.parse_with_url(&url);
34134
34135        loop {
34136            let token = match self
34137                .hub
34138                .auth
34139                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34140                .await
34141            {
34142                Ok(token) => token,
34143                Err(e) => match dlg.token(e) {
34144                    Ok(token) => token,
34145                    Err(e) => {
34146                        dlg.finished(false);
34147                        return Err(common::Error::MissingToken(e));
34148                    }
34149                },
34150            };
34151            let mut req_result = {
34152                let client = &self.hub.client;
34153                dlg.pre_request();
34154                let mut req_builder = hyper::Request::builder()
34155                    .method(hyper::Method::GET)
34156                    .uri(url.as_str())
34157                    .header(USER_AGENT, self.hub._user_agent.clone());
34158
34159                if let Some(token) = token.as_ref() {
34160                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34161                }
34162
34163                let request = req_builder
34164                    .header(CONTENT_LENGTH, 0_u64)
34165                    .body(common::to_body::<String>(None));
34166
34167                client.request(request.unwrap()).await
34168            };
34169
34170            match req_result {
34171                Err(err) => {
34172                    if let common::Retry::After(d) = dlg.http_error(&err) {
34173                        sleep(d).await;
34174                        continue;
34175                    }
34176                    dlg.finished(false);
34177                    return Err(common::Error::HttpError(err));
34178                }
34179                Ok(res) => {
34180                    let (mut parts, body) = res.into_parts();
34181                    let mut body = common::Body::new(body);
34182                    if !parts.status.is_success() {
34183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34184                        let error = serde_json::from_str(&common::to_string(&bytes));
34185                        let response = common::to_response(parts, bytes.into());
34186
34187                        if let common::Retry::After(d) =
34188                            dlg.http_failure(&response, error.as_ref().ok())
34189                        {
34190                            sleep(d).await;
34191                            continue;
34192                        }
34193
34194                        dlg.finished(false);
34195
34196                        return Err(match error {
34197                            Ok(value) => common::Error::BadRequest(value),
34198                            _ => common::Error::Failure(response),
34199                        });
34200                    }
34201                    let response = {
34202                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34203                        let encoded = common::to_string(&bytes);
34204                        match serde_json::from_str(&encoded) {
34205                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34206                            Err(error) => {
34207                                dlg.response_json_decode_error(&encoded, &error);
34208                                return Err(common::Error::JsonDecodeError(
34209                                    encoded.to_string(),
34210                                    error,
34211                                ));
34212                            }
34213                        }
34214                    };
34215
34216                    dlg.finished(true);
34217                    return Ok(response);
34218                }
34219            }
34220        }
34221    }
34222
34223    /// Resource name for the location.
34224    ///
34225    /// Sets the *name* path property to the given value.
34226    ///
34227    /// Even though the property as already been set when instantiating this call,
34228    /// we provide this method for API completeness.
34229    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
34230        self._name = new_value.to_string();
34231        self
34232    }
34233    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34234    /// while executing the actual API request.
34235    ///
34236    /// ````text
34237    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34238    /// ````
34239    ///
34240    /// Sets the *delegate* property to the given value.
34241    pub fn delegate(
34242        mut self,
34243        new_value: &'a mut dyn common::Delegate,
34244    ) -> ProjectLocationGetCall<'a, C> {
34245        self._delegate = Some(new_value);
34246        self
34247    }
34248
34249    /// Set any additional parameter of the query string used in the request.
34250    /// It should be used to set parameters which are not yet available through their own
34251    /// setters.
34252    ///
34253    /// Please note that this method must not be used to set any of the known parameters
34254    /// which have their own setter method. If done anyway, the request will fail.
34255    ///
34256    /// # Additional Parameters
34257    ///
34258    /// * *$.xgafv* (query-string) - V1 error format.
34259    /// * *access_token* (query-string) - OAuth access token.
34260    /// * *alt* (query-string) - Data format for response.
34261    /// * *callback* (query-string) - JSONP
34262    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34263    /// * *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.
34264    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34265    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34266    /// * *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.
34267    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34268    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34269    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
34270    where
34271        T: AsRef<str>,
34272    {
34273        self._additional_params
34274            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34275        self
34276    }
34277
34278    /// Identifies the authorization scope for the method you are building.
34279    ///
34280    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34281    /// [`Scope::CloudPlatform`].
34282    ///
34283    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34284    /// tokens for more than one scope.
34285    ///
34286    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34287    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34288    /// sufficient, a read-write scope will do as well.
34289    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
34290    where
34291        St: AsRef<str>,
34292    {
34293        self._scopes.insert(String::from(scope.as_ref()));
34294        self
34295    }
34296    /// Identifies the authorization scope(s) for the method you are building.
34297    ///
34298    /// See [`Self::add_scope()`] for details.
34299    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
34300    where
34301        I: IntoIterator<Item = St>,
34302        St: AsRef<str>,
34303    {
34304        self._scopes
34305            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34306        self
34307    }
34308
34309    /// Removes all scopes, and no default scope will be used either.
34310    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34311    /// for details).
34312    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
34313        self._scopes.clear();
34314        self
34315    }
34316}
34317
34318/// Lists information about the supported locations for this service.
34319///
34320/// A builder for the *locations.list* method supported by a *project* resource.
34321/// It is not used directly, but through a [`ProjectMethods`] instance.
34322///
34323/// # Example
34324///
34325/// Instantiate a resource method builder
34326///
34327/// ```test_harness,no_run
34328/// # extern crate hyper;
34329/// # extern crate hyper_rustls;
34330/// # extern crate google_networksecurity1 as networksecurity1;
34331/// # async fn dox() {
34332/// # use networksecurity1::{NetworkSecurity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34333///
34334/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34335/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34336/// #     secret,
34337/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34338/// # ).build().await.unwrap();
34339///
34340/// # let client = hyper_util::client::legacy::Client::builder(
34341/// #     hyper_util::rt::TokioExecutor::new()
34342/// # )
34343/// # .build(
34344/// #     hyper_rustls::HttpsConnectorBuilder::new()
34345/// #         .with_native_roots()
34346/// #         .unwrap()
34347/// #         .https_or_http()
34348/// #         .enable_http1()
34349/// #         .build()
34350/// # );
34351/// # let mut hub = NetworkSecurity::new(client, auth);
34352/// // You can configure optional parameters by calling the respective setters at will, and
34353/// // execute the final call using `doit()`.
34354/// // Values shown here are possibly random and not representative !
34355/// let result = hub.projects().locations_list("name")
34356///              .page_token("et")
34357///              .page_size(-12)
34358///              .filter("justo")
34359///              .doit().await;
34360/// # }
34361/// ```
34362pub struct ProjectLocationListCall<'a, C>
34363where
34364    C: 'a,
34365{
34366    hub: &'a NetworkSecurity<C>,
34367    _name: String,
34368    _page_token: Option<String>,
34369    _page_size: Option<i32>,
34370    _filter: Option<String>,
34371    _delegate: Option<&'a mut dyn common::Delegate>,
34372    _additional_params: HashMap<String, String>,
34373    _scopes: BTreeSet<String>,
34374}
34375
34376impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
34377
34378impl<'a, C> ProjectLocationListCall<'a, C>
34379where
34380    C: common::Connector,
34381{
34382    /// Perform the operation you have build so far.
34383    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
34384        use std::borrow::Cow;
34385        use std::io::{Read, Seek};
34386
34387        use common::{url::Params, ToParts};
34388        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34389
34390        let mut dd = common::DefaultDelegate;
34391        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34392        dlg.begin(common::MethodInfo {
34393            id: "networksecurity.projects.locations.list",
34394            http_method: hyper::Method::GET,
34395        });
34396
34397        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
34398            if self._additional_params.contains_key(field) {
34399                dlg.finished(false);
34400                return Err(common::Error::FieldClash(field));
34401            }
34402        }
34403
34404        let mut params = Params::with_capacity(6 + self._additional_params.len());
34405        params.push("name", self._name);
34406        if let Some(value) = self._page_token.as_ref() {
34407            params.push("pageToken", value);
34408        }
34409        if let Some(value) = self._page_size.as_ref() {
34410            params.push("pageSize", value.to_string());
34411        }
34412        if let Some(value) = self._filter.as_ref() {
34413            params.push("filter", value);
34414        }
34415
34416        params.extend(self._additional_params.iter());
34417
34418        params.push("alt", "json");
34419        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
34420        if self._scopes.is_empty() {
34421            self._scopes
34422                .insert(Scope::CloudPlatform.as_ref().to_string());
34423        }
34424
34425        #[allow(clippy::single_element_loop)]
34426        for &(find_this, param_name) in [("{+name}", "name")].iter() {
34427            url = params.uri_replacement(url, param_name, find_this, true);
34428        }
34429        {
34430            let to_remove = ["name"];
34431            params.remove_params(&to_remove);
34432        }
34433
34434        let url = params.parse_with_url(&url);
34435
34436        loop {
34437            let token = match self
34438                .hub
34439                .auth
34440                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34441                .await
34442            {
34443                Ok(token) => token,
34444                Err(e) => match dlg.token(e) {
34445                    Ok(token) => token,
34446                    Err(e) => {
34447                        dlg.finished(false);
34448                        return Err(common::Error::MissingToken(e));
34449                    }
34450                },
34451            };
34452            let mut req_result = {
34453                let client = &self.hub.client;
34454                dlg.pre_request();
34455                let mut req_builder = hyper::Request::builder()
34456                    .method(hyper::Method::GET)
34457                    .uri(url.as_str())
34458                    .header(USER_AGENT, self.hub._user_agent.clone());
34459
34460                if let Some(token) = token.as_ref() {
34461                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34462                }
34463
34464                let request = req_builder
34465                    .header(CONTENT_LENGTH, 0_u64)
34466                    .body(common::to_body::<String>(None));
34467
34468                client.request(request.unwrap()).await
34469            };
34470
34471            match req_result {
34472                Err(err) => {
34473                    if let common::Retry::After(d) = dlg.http_error(&err) {
34474                        sleep(d).await;
34475                        continue;
34476                    }
34477                    dlg.finished(false);
34478                    return Err(common::Error::HttpError(err));
34479                }
34480                Ok(res) => {
34481                    let (mut parts, body) = res.into_parts();
34482                    let mut body = common::Body::new(body);
34483                    if !parts.status.is_success() {
34484                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34485                        let error = serde_json::from_str(&common::to_string(&bytes));
34486                        let response = common::to_response(parts, bytes.into());
34487
34488                        if let common::Retry::After(d) =
34489                            dlg.http_failure(&response, error.as_ref().ok())
34490                        {
34491                            sleep(d).await;
34492                            continue;
34493                        }
34494
34495                        dlg.finished(false);
34496
34497                        return Err(match error {
34498                            Ok(value) => common::Error::BadRequest(value),
34499                            _ => common::Error::Failure(response),
34500                        });
34501                    }
34502                    let response = {
34503                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34504                        let encoded = common::to_string(&bytes);
34505                        match serde_json::from_str(&encoded) {
34506                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34507                            Err(error) => {
34508                                dlg.response_json_decode_error(&encoded, &error);
34509                                return Err(common::Error::JsonDecodeError(
34510                                    encoded.to_string(),
34511                                    error,
34512                                ));
34513                            }
34514                        }
34515                    };
34516
34517                    dlg.finished(true);
34518                    return Ok(response);
34519                }
34520            }
34521        }
34522    }
34523
34524    /// The resource that owns the locations collection, if applicable.
34525    ///
34526    /// Sets the *name* path property to the given value.
34527    ///
34528    /// Even though the property as already been set when instantiating this call,
34529    /// we provide this method for API completeness.
34530    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
34531        self._name = new_value.to_string();
34532        self
34533    }
34534    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
34535    ///
34536    /// Sets the *page token* query property to the given value.
34537    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
34538        self._page_token = Some(new_value.to_string());
34539        self
34540    }
34541    /// The maximum number of results to return. If not set, the service selects a default.
34542    ///
34543    /// Sets the *page size* query property to the given value.
34544    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
34545        self._page_size = Some(new_value);
34546        self
34547    }
34548    /// 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).
34549    ///
34550    /// Sets the *filter* query property to the given value.
34551    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
34552        self._filter = Some(new_value.to_string());
34553        self
34554    }
34555    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34556    /// while executing the actual API request.
34557    ///
34558    /// ````text
34559    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34560    /// ````
34561    ///
34562    /// Sets the *delegate* property to the given value.
34563    pub fn delegate(
34564        mut self,
34565        new_value: &'a mut dyn common::Delegate,
34566    ) -> ProjectLocationListCall<'a, C> {
34567        self._delegate = Some(new_value);
34568        self
34569    }
34570
34571    /// Set any additional parameter of the query string used in the request.
34572    /// It should be used to set parameters which are not yet available through their own
34573    /// setters.
34574    ///
34575    /// Please note that this method must not be used to set any of the known parameters
34576    /// which have their own setter method. If done anyway, the request will fail.
34577    ///
34578    /// # Additional Parameters
34579    ///
34580    /// * *$.xgafv* (query-string) - V1 error format.
34581    /// * *access_token* (query-string) - OAuth access token.
34582    /// * *alt* (query-string) - Data format for response.
34583    /// * *callback* (query-string) - JSONP
34584    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34585    /// * *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.
34586    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34587    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34588    /// * *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.
34589    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34590    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34591    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
34592    where
34593        T: AsRef<str>,
34594    {
34595        self._additional_params
34596            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34597        self
34598    }
34599
34600    /// Identifies the authorization scope for the method you are building.
34601    ///
34602    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34603    /// [`Scope::CloudPlatform`].
34604    ///
34605    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34606    /// tokens for more than one scope.
34607    ///
34608    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34609    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34610    /// sufficient, a read-write scope will do as well.
34611    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
34612    where
34613        St: AsRef<str>,
34614    {
34615        self._scopes.insert(String::from(scope.as_ref()));
34616        self
34617    }
34618    /// Identifies the authorization scope(s) for the method you are building.
34619    ///
34620    /// See [`Self::add_scope()`] for details.
34621    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
34622    where
34623        I: IntoIterator<Item = St>,
34624        St: AsRef<str>,
34625    {
34626        self._scopes
34627            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34628        self
34629    }
34630
34631    /// Removes all scopes, and no default scope will be used either.
34632    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34633    /// for details).
34634    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
34635        self._scopes.clear();
34636        self
34637    }
34638}